This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[committed] Make XCOFF __rtinit symbols C_HIDEXT


As mentioned in an earlier message, we currently add __rtinit to the
static symbol table.  This causes problems when linking a shared object
statically; the shared object's __rtinit clashes with the linker-created
one.

The native linker doesn't add __rtinit to the static symbol table at all.
I wondered about doing the same thing, but having the symbol helps to
make the objdump output easier to read.  (We do test for this already.)
I therefore kept the symbol, but made it C_HIDEXT rather than C_EXT.
The .loader entry isn't affected.

Tested on powerpc-ibm-aix6.1 and applied.

Richard


bfd/
	* xcofflink.c (bfd_link_input_bfd): Treat __rtinit as C_HIDEXT
	rather than C_EXT.

ld/testsuite/
	* ld-powerpc/aix-gc-1.nd: New test.
	* ld-powerpc/aix52.exp: Run it.

Index: bfd/xcofflink.c
===================================================================
--- bfd/xcofflink.c	2009-04-01 19:03:28.000000000 +0100
+++ bfd/xcofflink.c	2009-04-01 19:03:34.000000000 +0100
@@ -4287,6 +4287,7 @@ #define N_BTSHFT n_btshft
 
   esym = (bfd_byte *) obj_coff_external_syms (input_bfd);
   esym_end = esym + obj_raw_syment_count (input_bfd) * isymesz;
+  sym_hash = obj_xcoff_sym_hashes (input_bfd);
   isymp = finfo->internal_syms;
   indexp = finfo->sym_indices;
   csectpp = xcoff_data (input_bfd)->csects;
@@ -4334,6 +4335,16 @@ #define N_BTSHFT n_btshft
 		}
 	    }
 
+	  /* Make __rtinit C_HIDEXT rather than C_EXT.  This avoids
+	     multiple definition problems when linking a shared object
+	     statically.  (The native linker doesn't enter __rtinit into
+	     the normal table at all, but having a local symbol can make
+	     the objdump output easier to read.)  */
+	  if (isym.n_sclass == C_EXT
+	      && *sym_hash
+	      && ((*sym_hash)->flags & XCOFF_RTINIT) != 0)
+	    isym.n_sclass = C_HIDEXT;
+
 	  /* The value of a C_FILE symbol is the symbol index of the
 	     next C_FILE symbol.  The value of the last C_FILE symbol
 	     is -1.  We try to get this right, below, just before we
@@ -4662,6 +4673,7 @@ #define N_BTSHFT n_btshft
 	    }
 	}
 
+      sym_hash += add;
       indexp += add;
       isymp += add;
       csectpp += add;
Index: ld/testsuite/ld-powerpc/aix-gc-1.nd
===================================================================
--- /dev/null	2009-04-01 18:14:04.503808585 +0100
+++ ld/testsuite/ld-powerpc/aix-gc-1.nd	2009-04-01 19:03:34.000000000 +0100
@@ -0,0 +1,3 @@
+#...
+0*20000008 d __rtinit
+#pass
Index: ld/testsuite/ld-powerpc/aix52.exp
===================================================================
--- ld/testsuite/ld-powerpc/aix52.exp	2009-04-01 19:03:20.000000000 +0100
+++ ld/testsuite/ld-powerpc/aix52.exp	2009-04-01 19:03:34.000000000 +0100
@@ -131,7 +131,8 @@ set aix52tests {
     {"Garbage collection test 1"
      "-shared -binitfini:init_function:fini_function -bE:aix-gc-1.ex"
      "" {aix-gc-1.s}
-     {{objdump {-dz -j.text -j.data} aix-gc-1-SIZE.dd}}
+     {{objdump {-dz -j.text -j.data} aix-gc-1-SIZE.dd}
+      {nm {} aix-gc-1.nd}}
      "aix-gc-1.so"}
 
     {"Glink test 1"


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]