Discussion:
[PATCH] Xbox PE subsystem support
Myria
2004-11-25 23:12:50 UTC
Permalink
This simple patch adds support for --subsystem:xbox to the ix86-pe emulation
of ld.

The OpenXDK project ( http://www.openxdk.org/ ) is a project to make an
open-source development kit for the Microsoft Xbox native OS. Among the
things needed, of course, is a compiler and linker. Due to the similarities
between Xbox and Win32, the PE build tools would work well, with few
changes.

This patch adds --subsystem:xbox, value 14, officially and publicly defined
as IMAGE_SUBSYSTEM_XBOX in Microsoft's winnt.h header file. It is known
that Microsoft's own Xbox Development Kit (XDK) compiles developers' games
into standard PE format, with subsystem 14. The resulting PE file is later
converted to the PE-like "XBE" format. We would like to continue with this
tradition; in fact, the current OpenXDK does the same already.

In addition, this patch adds support for arbitrary subsystem numbers,
like --subsystem=123. This is for future use so hopefully others in
unforeseen projects will not have to modify binutils to use a different
subsystem. When an arbitrary number is used that ld does not recognize, it
assumes the entry point is mainCRTStartup. If, however, the number is known
by ld, as in the user typing --subsystem:2 ("windows"), the entry point will
be set to the proper default. The subsystem number is handled as a "0" base
to strtoul, meaning it is decimal by default, and octal and hex can be used
by prepending 0 or 0x.

Finally, "xbox" is recognized as a target, being equivalent to
i686-pc-mingw32, whose settings are acceptable for OpenXDK. This gives the
rather convenient --target=xbox setting as well as executable names xbox-ld,
xbox-as, etc.

Full list of changes:

- /config.sub now recognizes "xbox" as an alias for i686-pc-mingw32
- ld now recognizes --subsystem:xbox as 14 with mainCRTStartup
- ld now allows numeric subsystem numbers like --subsystem:1234
- ld manpage and texinfo updated to note new --subsystem usages
- removed weird #if in pe.em that selected between 2 identical fragments

I'm new to this patch thing and binutils so I probably made a mistake
somewhere... Also, some of you might not like this patch. Any comments
would be appreciated. Thanks!

Melissa Mears
Andreas Schwab
2004-11-25 23:31:01 UTC
Permalink
Post by Myria
- /config.sub now recognizes "xbox" as an alias for i686-pc-mingw32
Please send patches for config.sub and config.guess to
<config-***@gnu.org>, as mentioned in their comments.

Andreas.
--
Andreas Schwab, SuSE Labs, ***@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
Christopher Faylor
2004-11-26 01:55:45 UTC
Permalink
[reply-to set]
Post by Myria
This simple patch adds support for --subsystem:xbox to the ix86-pe
emulation of ld.
The OpenXDK project ( http://www.openxdk.org/ ) is a project to make an
open-source development kit for the Microsoft Xbox native OS. Among the
things needed, of course, is a compiler and linker. Due to the
similarities between Xbox and Win32, the PE build tools would work well,
with few changes.
This patch adds --subsystem:xbox, value 14, officially and publicly defined
as IMAGE_SUBSYSTEM_XBOX in Microsoft's winnt.h header file. It is known
that Microsoft's own Xbox Development Kit (XDK) compiles developers' games
into standard PE format, with subsystem 14. The resulting PE file is later
converted to the PE-like "XBE" format. We would like to continue with this
tradition; in fact, the current OpenXDK does the same already.
In addition, this patch adds support for arbitrary subsystem numbers,
like --subsystem=123. This is for future use so hopefully others in
unforeseen projects will not have to modify binutils to use a different
subsystem. When an arbitrary number is used that ld does not recognize, it
assumes the entry point is mainCRTStartup. If, however, the number is
known by ld, as in the user typing --subsystem:2 ("windows"), the entry
point will be set to the proper default. The subsystem number is handled
as a "0" base to strtoul, meaning it is decimal by default, and octal and
hex can be used by prepending 0 or 0x.
Finally, "xbox" is recognized as a target, being equivalent to
i686-pc-mingw32, whose settings are acceptable for OpenXDK. This gives the
rather convenient --target=xbox setting as well as executable names
xbox-ld, xbox-as, etc.
- /config.sub now recognizes "xbox" as an alias for i686-pc-mingw32
- ld now recognizes --subsystem:xbox as 14 with mainCRTStartup
- ld now allows numeric subsystem numbers like --subsystem:1234
- ld manpage and texinfo updated to note new --subsystem usages
- removed weird #if in pe.em that selected between 2 identical fragments
I'm new to this patch thing and binutils so I probably made a mistake
somewhere... Also, some of you might not like this patch. Any comments
would be appreciated. Thanks!
FWIW, I like the patch. One minor thing is that you submitted the
ChangeLog as a diff. ChangeLogs change enough that you can be sure that
your patch will never install correctly by the time it is accepted. So,
the convention is to provide ChangeLog changes as just the clause that
you want to go into the ChangeLog

Other than that very minor point, as the recent proud owner of an Xbox
I'd like to see this in binutils, even if the Xbox is eventually
destined to be running linux.

I don't know if you'd need an assigment with the FSF for this change but
I suspect that it is large enough that you probably would.

cgf
Nick Clifton
2004-11-26 09:49:41 UTC
Permalink
Hi Melissa,
Post by Myria
This simple patch adds support for --subsystem:xbox to the ix86-pe
emulation of ld.
Thanks very much for submitting this patch. There were a couple of
problems with it, such as the ChangeLog entry not actually mentioning
that the ld.texinfo file had been changed, or the fact that it included
a patch to ld.info which is a generated file in the build directory and
not a source file, but these were very minor points.
Post by Myria
* emultempl/pe.em: Add --subsystem:xbox as well as
--subsystem:%d.
* ld.texinfo: (ld_options): Document acceptance of subsystem
xbox and numeric subsystems.
Approved and applied.

Cheers
Nick

Loading...