Patchwork collect2 should ignore AIX shared objects marked F_LOADONLY

login
register
mail settings
Submitter David Edelsohn
Date Feb. 3, 2013, 2:29 p.m.
Message ID <CAGWvnymb8c2OLb1bAvNHZndHxOUBNRBXfVpbMWcEWGxMnm+9vA@mail.gmail.com>
Download mbox | patch
Permalink /patch/217793/
State New
Headers show

Comments

David Edelsohn - Feb. 3, 2013, 2:29 p.m.
Although AIX now supports shared objects with the ".so" suffix, AIX's
native support for shared objects are special object files in archive
files.  Shared object versioning is supported with multiple shared
objects in a single archive file.  Shared object files providing
earlier versions of symbols normally have the F_LOADONLY flag set in
the header and only the most recent version is used for newly linked
applications.

Andrew Dixie pointed out that GCC collect2 is scanning all versions of
shared objects instead of only the ones that are set for new linking.

The patch below updates GCC_CHECK_HDR to skip object files marked F_LOADONLY.

Bootstrapped on powerpc-ibm-aix7.1.0.0

        * collect2.c (GCC_CHECK_HDR): Do not scan objects with F_LOADONLY
        flag set.

Patch

Index: collect2.c
===================================================================
--- collect2.c  (revision 195687)
+++ collect2.c  (working copy)
@@ -2763,12 +2763,14 @@ 
 /* 0757 = U803XTOCMAGIC (AIX 4.3) and 0767 = U64_TOCMAGIC (AIX V5) */
 #if TARGET_AIX_VERSION >= 51
 #   define GCC_CHECK_HDR(X) \
-     ((HEADER (X).f_magic == U802TOCMAGIC && ! aix64_flag) \
-      || (HEADER (X).f_magic == 0767 && aix64_flag))
+     (((HEADER (X).f_magic == U802TOCMAGIC && ! aix64_flag) \
+       || (HEADER (X).f_magic == 0767 && aix64_flag)) \
+      && !(HEADER (X).f_flags & F_LOADONLY))
 #else
 #   define GCC_CHECK_HDR(X) \
-     ((HEADER (X).f_magic == U802TOCMAGIC && ! aix64_flag) \
-      || (HEADER (X).f_magic == 0757 && aix64_flag))
+     (((HEADER (X).f_magic == U802TOCMAGIC && ! aix64_flag) \
+       || (HEADER (X).f_magic == 0757 && aix64_flag)) \
+      && !(HEADER (X).f_flags & F_LOADONLY))
 #endif

 #endif