This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
gas on Mac OS X
- From: Martin Schaffner <schaffner at gmx dot li>
- To: binutils at sources dot redhat dot com
- Cc: Aurelien Chanudet <aurelien dot chanudet at m4x dot org>
- Date: Wed, 21 Apr 2004 16:28:32 +0100
- Subject: gas on Mac OS X
I started to port the GNU assembler to the powerpc-apple-darwin*
target, with a lot of help from Aurelien Chanudet (he coded probably
more than half of everything so far).
The work is as far as that gas parses an assembler file of a hello
world program correctly. But now I have problems continuing (see
section "Practical problems" of this mail).
First, I'll present what we already did. All the files I refer to in
this mail are here:
http://membres.lycos.fr/schaffner/prog/binutils/
Additional files
----------------
* obj-mach-o.{h,c} adds (incomplete) mach-o support to gas. Put into
src/gas/config/. I consider there files safe to apply to the cvs,
because files with these names are certainly necessary for mach-o
support, and as long as the gas directory is not configured/compiled
when targetting darwin, it doesn't matter if it contains work in
progress. It would also make it easier to create diffs (cvs diff -uN
lists new files with a question mark...)
* mach-o-reloc.c adds (incomplete) support for mach-o relocations to
bfd. Put into src/bfd/. I'm not sure this file is really necessary, or
if the contained functionality belongs into a different file. Please
don't put it into cvs.
Patches to work on
------------------
* gas-apple.ptch is what apple added to gas-1.38 for their version of
binutils, "cctools".
* apple-gdb.patch is what apple added to gdb to run on Mac OS X (this
diff is between binutils cvs of 2003-1-28, and a checkout of
"muon-branch gdb" from anoncvs.opensource.apple.com.
* binutils-darwin-2004-4-21.patch is a diff from today's cvs to the
darwin supporting version on my hard disk. This patch requires all
three additional files.
* binutils-darwin-activate.patch actives darwin support for gas, the
"gas" directory will be configured after this patch. It can only be
commited when all problems are sorted out, but it is useful for
development.
* quoted_names.ptch adds support for quoted identifiers to gas. The
support is wrong in that the quotes get added to the name.
Patches to review and apply
---------------------------
* binutils-darwin-2004-4-21-safe.patch contains the portion of our work
that I consider safe to apply right away. Depends on the files
gas/config/obj-mach-o.{c,h}. ChangeLog:
2004-04-21 Martin Schaffner <schaffner@gmx.li>
* bfd/mach-o.c: define MACH_O_MAGIC, move and rename macros for
sections to bfd/mach-o.h
* bfd/mach-o.h: add macros for mach-o sections
* gas/Makefile.{in,am}, gas/configure{,.in}: add
config/obj-mach-o.{h,c}
* binutils-add-comments.ptch has nothing to do with darwin, but adds
some comments. ChangeLog:
2004-04-21 Martin Schaffner <schaffner@gmx.li>
* gas/write.c, gas/config/tc-ppc.h: comment #endif with
controlling macro
* binutils-darwin-add-reloc-types.patch adds relocation type
definitions for mach-o. ChangeLog:
2004-04-21 Martin Schaffner <schaffner@gmx.li>
* bfd/bfd-in2.h, bfd/libbfd.h, bfd/reloc.c: define
Mach-O-specific relocation types:
BFD_RELOC_LO16_DS, BFD_RELOC_LO16_DS_BASEREL,
BFD_RELOC_MACH_O_PAIR, BFD_RELOC_MACH_O_PB_LA_PTR,
BFD_RELOC_MACH_O_JBSR
* binutils-darwin-parse.patch (depends on the previous) adds support
for the assembler operators lo16(), hi16(), ha16(). ChangeLog:
2004-04-21 Martin Schaffner <schaffner@gmx.li>
* gas/config/tc-ppc.c: add support for Mach-O-specific assembly
code
Practical problems
------------------
* Indirect symbols. Mach-O supports so called "indirect symbols", which
are something different than the indirect symbols of ELF. Is there a
terminology to distinguish these two concepts? Maybe in gcc? We could
call the ones in Mach-o "mach-o-indirect symbols"...
Anyway, to support these there has to be an interface between bfd and
gas. This design has to be carefully thought out. Maybe someone can
help me.
* Weak references. These too are not the same thing as ELF's weak
symbols.
More info:
http://developer.apple.com/documentation/DeveloperTools/Tools-date.html
http://developer.apple.com/techpubs/macosx/DeveloperTools/MachORuntime/
MachORuntime.pdf
Copyright problems
------------------
* Aurelien Chanudet tells me he filed copyright assignment papers to
FSF.
* I applied for such papers but didn't get them yet.
* I often peeked at (or downright copied) code from apple, both
released under the Apple public source license (APSL), and under the
GNU GPL.
For the GPL'd code, didn't Apple file a copyright assigment to the FSF?
For the APSL code, according to the FSF it is illegal to distribute
code containing both GPL-licensed and APSL-licensed parts. OTOH, Apple
releases their fork of the GNU assembler as part of the cctools under
the APSL. I wrote Apple about this, after which they seperated their
gas package from the cctools package, but because their gas depends on
some files in cctools, they merged it again later on.
--
Martin Schaffner