public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [0/21] Add support for AIX 6
@ 2009-03-10 13:58 Richard Sandiford
  2009-03-10 14:00 ` [1/21] Fix handling of archive tests Richard Sandiford
                   ` (21 more replies)
  0 siblings, 22 replies; 50+ messages in thread
From: Richard Sandiford @ 2009-03-10 13:58 UTC (permalink / raw)
  To: binutils

This series of patches adds support for AIX 6.  In truth, only one patch
is actually specific to version 6; the rest fix problems with the existing
AIX 4 and AIX 5 code.  The aim of many of the patches is to resolve the
failures mentioned in the following libtool message:

*** Warning: the GNU linker, at least up to release 2.9.1, is reported
*** to be unable to reliably create shared libraries on AIX.
*** Therefore, libtool is disabling shared libraries support.  If you
*** really care for shared libraries, you may want to modify your PATH
*** so that a non-GNU linker is found, and then restart.

With some libtool and gcc patches, a cross toolchain produced good
GCC testresults, and we've been able to use it in-house to build our
applications.  (The build includes both shared libraries and executables.)
I'm sure there are other issues that I haven't fixed here though.

One of the big issues was: how should we handle archives and symbol
resolution?  On AIX, it is possible to link dynamically against both
shared objects _and_ archives that contain shared objects.  The latter
are more commonly used.  For example, whereas GNU systems have a separate
shared C library (libc.so.X) and static-only archive (libc_nonshared.a),
AIX has a single libc.a that contains both the shared object and the
static-only objects.

This causes problems with things like:

   gnu-ld bar.o -lfoo frob.o

in cases where the user is expecting "foo" to be a shared library.
The executable should link dynamically against foo regardless of
whether foo appears to be needed; you would use:

   gnu-ld bar.o --as-needed -lfoo --no-as-needed frob.o

if you wanted "foo" to behave more like an archive.  However, if shared
library "foo" _is_ an archive, the first command behaves like the second.
You would need:

   gnu-ld bar.o --whole-archive -lfoo --no-whole-archive frob.o

to get the normal ELF behaviour.

This means, for example, that:

   gnu-ld ... -lpthread ... objects ...

fails with a shared libpthread.a, but:

   gnu-ld ... objects ... -lpthread ...

works.

Now the AIX linker appears to apply something like --whole-archive
semantics to _all_ archives.  So, for example:

----------------------------------------------------------------------
#!/bin/bash
set -eu
cat <<EOF > a.c
int x = 1;
EOF
cat <<EOF > b.c
int x = 2;
int main (void) { return x; }
EOF
gcc -c a.c -o a.o
rm -f libfoo.a
ar rc libfoo.a a.o
gcc -L. -lfoo b.c
./a.out || echo $?
rm -f a.out a.c a.o b.c libfoo.a
----------------------------------------------------------------------

prints "2" on your typical ELF target, and on AIX when using the
GNU linker.  But when using the native AIX linker it produces:

----------------------------------------------------------------------
ld: 0711-224 WARNING: Duplicate symbol: x
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
1
----------------------------------------------------------------------

This means that "ld -lpthread ..." works as expected when using the
native linker.  However, the knock-on conseequences might surprise some
users if we did the same thing in the GNU linker.

Also, when resolving symbols, the native linker does not care whether
a definition comes from a direct relocatable object, a direct shared
object, or an archive member.  Strong definitions in shared objects
can override weak definitions in the main objects.  If shared object A
comes before relocatable object B, a weak definition in A trumps a weak
definition in B.  A strong definition in A also trumps a strong
definition in B, albeit with a multiple-definition warning.

I couldn't decide whether to make the GNU linker behave like the AIX
linker or not.  In the end, I left things as they are for no other
reason than it's what we've always done.

All patches in the series were tested against the binutils and
gcc testsuites.

As far as copyright goes: I did this work for Transitive after
they were bought by IBM, and my name has been added to the IBM
copyright assignment.  This work is therefore covered by that.

Richard

^ permalink raw reply	[flat|nested] 50+ messages in thread

end of thread, other threads:[~2009-03-14  9:42 UTC | newest]

Thread overview: 50+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-10 13:58 [0/21] Add support for AIX 6 Richard Sandiford
2009-03-10 14:00 ` [1/21] Fix handling of archive tests Richard Sandiford
2009-03-12 16:15   ` Nick Clifton
2009-03-10 14:01 ` [2/21] Add support for AIX 6 Richard Sandiford
2009-03-12 16:17   ` Nick Clifton
2009-03-10 14:04 ` [3/21] Keep .text, .data and .bss on AIX Richard Sandiford
2009-03-12 16:36   ` Nick Clifton
2009-03-13  9:43     ` Richard Sandiford
2009-03-13 11:42       ` Nick Clifton
2009-03-14  9:42         ` Richard Sandiford
2009-03-10 14:05 ` [4/21] Fix o_cputype for 64-bit XCOFF objects Richard Sandiford
2009-03-12 16:38   ` Nick Clifton
2009-03-10 14:07 ` [5/21] Set config.dynamic_link for AIX Richard Sandiford
2009-03-12 16:39   ` Nick Clifton
2009-03-10 14:08 ` [6/21] XCOFF R_POS and R_NEG relocations against absolute symbols Richard Sandiford
2009-03-13 14:33   ` Nick Clifton
2009-03-10 14:13 ` [7/21] Handle relative branches to absolute addresses Richard Sandiford
2009-03-13 14:37   ` Nick Clifton
2009-03-10 14:13 ` [0/21] Add support for AIX 6 Ian Lance Taylor
2009-03-10 15:22   ` Richard Sandiford
2009-03-10 15:45   ` Michael Haubenwallner
2009-03-10 16:30     ` Ian Lance Taylor
2009-03-10 14:15 ` [8/21] bfd_install_relocation strikes again Richard Sandiford
2009-03-13 14:48   ` Nick Clifton
2009-03-10 14:22 ` [9/21] Implicitly import undefined symbols Richard Sandiford
2009-03-13 14:55   ` Nick Clifton
2009-03-10 14:25 ` [10/21] Fix the csect handling of XTY_ER symbols Richard Sandiford
2009-03-13 14:57   ` Nick Clifton
2009-03-10 14:29 ` [11/21] Cope with TOCs bigger than 32k, and other TC0 fixes Richard Sandiford
2009-03-13 14:59   ` Nick Clifton
2009-03-10 14:34 ` [12/21] Trim XCOFF symbols earlier in the link process Richard Sandiford
2009-03-13 15:01   ` Nick Clifton
2009-03-10 14:36 ` [13/21] Fix counting of line-number entries Richard Sandiford
2009-03-13 15:04   ` Nick Clifton
2009-03-10 14:38 ` [14/21] Treat absolute imports as XTY_ER/XMC_XO Richard Sandiford
2009-03-13 15:11   ` Nick Clifton
2009-03-10 14:40 ` [15/21] Avoid writing duplicate XCOFF symbols Richard Sandiford
2009-03-13 15:12   ` Nick Clifton
2009-03-10 14:45 ` [16/21] Add AIX weak support Richard Sandiford
2009-03-13 15:17   ` Nick Clifton
2009-03-10 14:46 ` [17/21] Suppor garbage collection without an entry point Richard Sandiford
2009-03-13 15:22   ` Nick Clifton
2009-03-10 14:49 ` [18/21] Add -bexpall and -bexpfull Richard Sandiford
2009-03-13 15:21   ` Nick Clifton
2009-03-10 14:50 ` [19/21] Give imported function descriptors class XMC_DS Richard Sandiford
2009-03-13 15:24   ` Nick Clifton
2009-03-10 14:51 ` [20/21] Fix free() of in-use memory when handling archives Richard Sandiford
2009-03-13 15:24   ` Nick Clifton
2009-03-10 14:53 ` [21/21] GAS testsuite fix Richard Sandiford
2009-03-13 15:25   ` Nick Clifton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).