public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* ppc32 broken with cvs head
@ 2003-03-05 17:55 Olaf Hering
  2003-03-05 21:45 ` Olaf Hering
  2003-03-06 11:33 ` Alan Modra
  0 siblings, 2 replies; 4+ messages in thread
From: Olaf Hering @ 2003-03-05 17:55 UTC (permalink / raw)
  To: binutils

Hi,

I get these link errors in many packages with binutils cvs, todays
version and the one from Feb 28. The plain binutils-2.13.90.0.18 works
fine.

gcc ../obj_s/tset.o ../obj_s/dump_entry.o -L../lib -lncurses       -o tset
/usr/lib/gcc-lib/powerpc-suse-linux/3.2.2/../../../../powerpc-suse-linux/bin/ld: ../obj_s/tset.o(.got2+0x5c): unresolvable relocation against symbol `environ@@GLIBC_2.0'
collect2: ld returned 1 exit status
make[1]: *** [tset] Error 1
make[1]: Leaving directory `/usr/src/packages/BUILD/ncurses-5.3/progs'


ld -v ; gcc -v  
GNU ld version 2.13.90 20030305
Reading specs from /usr/lib/gcc-lib/powerpc-suse-linux/3.2.2/specs
Configured with: /usr/src/packages/BUILD/gcc-3.2.2/gcc-3.2.2/configure --enable-threads=posix --prefix=/usr --with-local-prefix=/usr/local --infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/lib --enable-languages=c,c++,f77,objc,java,ada --enable-libgcj --with-gxx-include-dir=/usr/include/g++ --with-slibdir=/lib --with-system-zlib --enable-shared --enable-__cxa_atexit powerpc-suse-linux
Thread model: posix
gcc version 3.2.2 20030227 (prerelease) (SuSE Linux)

glibc 2.3.2

Anyone else seeing this? Do I need special config options now?
I use --prefix=/usr --enable-shared --with-gnu-ld --with-gnu-as
--libdir=/usr/lib --infodir=/usr/share/info --ma ndir=/usr/share/man
--host=powerpc-suse-linux --enable-targets=powerpc64-suse-linux


Gruss Olaf

-- 
A: No.
Q: Should I include quotations after my reply?

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

* Re: ppc32 broken with cvs head
  2003-03-05 17:55 ppc32 broken with cvs head Olaf Hering
@ 2003-03-05 21:45 ` Olaf Hering
  2003-03-06 11:33 ` Alan Modra
  1 sibling, 0 replies; 4+ messages in thread
From: Olaf Hering @ 2003-03-05 21:45 UTC (permalink / raw)
  To: binutils

 On Wed, Mar 05, Olaf Hering wrote:

> Hi,
> 
> I get these link errors in many packages with binutils cvs, todays
> version and the one from Feb 28. The plain binutils-2.13.90.0.18 works
> fine.
> 
> gcc ../obj_s/tset.o ../obj_s/dump_entry.o -L../lib -lncurses       -o tset
> /usr/lib/gcc-lib/powerpc-suse-linux/3.2.2/../../../../powerpc-suse-linux/bin/ld: ../obj_s/tset.o(.got2+0x5c): unresolvable relocation against symbol `environ@@GLIBC_2.0'
> collect2: ld returned 1 exit status
> make[1]: *** [tset] Error 1
> make[1]: Leaving directory `/usr/src/packages/BUILD/ncurses-5.3/progs'

It seems that it is not caused by a miscompiled glibc package, building
ncurses with the current cvs fails as well.

Gruss Olaf

-- 
A: No.
Q: Should I include quotations after my reply?

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

* Re: ppc32 broken with cvs head
  2003-03-05 17:55 ppc32 broken with cvs head Olaf Hering
  2003-03-05 21:45 ` Olaf Hering
@ 2003-03-06 11:33 ` Alan Modra
  2003-03-06 23:25   ` Alan Modra
  1 sibling, 1 reply; 4+ messages in thread
From: Alan Modra @ 2003-03-06 11:33 UTC (permalink / raw)
  To: Olaf Hering; +Cc: binutils

On Wed, Mar 05, 2003 at 06:54:45PM +0100, Olaf Hering wrote:
> unresolvable relocation against symbol `environ@@GLIBC_2.0'

A testcase for this is

cat > env.c <<EOF
extern char *environ;
int main (void) { return *environ; }
EOF
gcc -o env env.c -fPIC -O

The quick fix is to "#define ELIMINATE_COPY_RELOCS 0" at
elf32-ppc.c:2458.  I'm afraid the ELIMINATE_COPY_RELOCS code is
broken, and has been broken on x86 for a long time too.  In fact,
it's quite surprising that no one has reported a bug in the x86
code.  Maybe it's just harder to trigger there.

I'll work on a more comprehensive fix soon.  Meanwhile the following
will fix the problem, and tidy a few other small things.

	* elf32-ppc.c (ppc_elf_create_linker_section): Don't capitalize
	error messages.
	(ELIMINATE_COPY_RELOCS): Define to zero.
	(ppc_elf_relocate_section): Don't deref htab->tls_sec when calculating
	TLSLD relocs.  Report reloc types on a number of errors.  Optimize
	LOCAL24PC check for non-local syms.  Don't capitalize error messages.
	* elf64-ppc.c (ELIMINATE_COPY_RELOCS): Define to zero.
	(ppc64_elf_relocate_section): Don't deref htab->tls_sec when
	calculating TLSLD relocs.  Report reloc types on a number of errors.
	Don't capitalize error messages.

Index: bfd/elf32-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-ppc.c,v
retrieving revision 1.68
diff -u -p -r1.68 elf32-ppc.c
--- bfd/elf32-ppc.c	20 Feb 2003 09:10:18 -0000	1.68
+++ bfd/elf32-ppc.c	6 Mar 2003 11:14:19 -0000
@@ -2300,7 +2300,7 @@ ppc_elf_create_linker_section (abfd, inf
       switch (which)
 	{
 	default:
-	  (*_bfd_error_handler) (_("%s: Unknown special linker type %d"),
+	  (*_bfd_error_handler) (_("%s: unknown special linker type %d"),
 				 bfd_get_filename (abfd),
 				 (int) which);
 
@@ -2455,7 +2455,7 @@ ppc_elf_create_dynamic_sections (abfd, i
    copying dynamic variables from a shared lib into an app's dynbss
    section, and instead use a dynamic relocation to point into the
    shared lib.  */
-#define ELIMINATE_COPY_RELOCS 1
+#define ELIMINATE_COPY_RELOCS 0
 
 /* Adjust a symbol defined by a dynamic object and referenced by a
    regular object.  The current definition is in some section of the
@@ -4824,22 +4824,21 @@ ppc_elf_relocate_section (output_bfd, in
 		      {
 			bfd_vma value = relocation;
 
-			if ((tls_ty & (TLS_GD | TLS_TPREL | TLS_DTPREL
-				       | TLS_TPRELGD)) != 0)
+			if (tls_ty == (TLS_TLS | TLS_LD))
+			  value = 1;
+			else if (tls_ty != 0)
 			  {
 			    value -= htab->tls_sec->vma + DTP_OFFSET;
-			    if ((tls_ty & TLS_TPREL) != 0)
+			    if (tls_ty == (TLS_TLS | TLS_TPREL))
 			      value += DTP_OFFSET - TP_OFFSET;
-			  }
 
-			if (tls_ty == (TLS_TLS | TLS_GD))
-			  {
-			    bfd_put_32 (output_bfd, value,
-					htab->got->contents + off + 4);
-			    value = 1;
+			    if (tls_ty == (TLS_TLS | TLS_GD))
+			      {
+				bfd_put_32 (output_bfd, value,
+					    htab->got->contents + off + 4);
+				value = 1;
+			      }
 			  }
-			else if (tls_ty == (TLS_TLS | TLS_LD))
-			  value = 1;
 			bfd_put_32 (output_bfd, value,
 				    htab->got->contents + off);
 		      }
@@ -4887,10 +4886,11 @@ ppc_elf_relocate_section (output_bfd, in
 	       got at entry m+n bears little relation to the entry m.  */
 	    if (addend != 0)
 	      (*_bfd_error_handler)
-		(_("%s(%s+0x%lx): non-zero addend on got reloc against `%s'"),
+		(_("%s(%s+0x%lx): non-zero addend on %s reloc against `%s'"),
 		 bfd_archive_filename (input_bfd),
 		 bfd_get_section_name (input_bfd, input_section),
 		 (long) rel->r_offset,
+		 howto->name,
 		 sym_name);
 	  }
 	break;
@@ -4899,10 +4899,7 @@ ppc_elf_relocate_section (output_bfd, in
 	case R_PPC_LOCAL24PC:
 	  /* It makes no sense to point a local relocation
 	     at a symbol not in this object.  */
-	  if (h != NULL
-	      && (h->root.type == bfd_link_hash_defined
-		  || h->root.type == bfd_link_hash_defweak)
-	      && sec->output_section == NULL)
+	  if (unresolved_reloc)
 	    {
 	      if (! (*info->callbacks->undefined_symbol) (info,
 							  h->root.root.string,
@@ -5037,8 +5034,6 @@ ppc_elf_relocate_section (output_bfd, in
 
 	      if (skip)
 		memset (&outrel, 0, sizeof outrel);
-	      /* h->dynindx may be -1 if this symbol was marked to
-		 become local.  */
 	      else if (h != NULL
 		       && !SYMBOL_REFERENCES_LOCAL (info, h))
 		{
@@ -5175,7 +5170,7 @@ ppc_elf_relocate_section (output_bfd, in
 		   || (strncmp (name, ".sbss", 5) == 0
 		       && (name[5] == 0 || name[5] == '.'))))
 	      {
-		(*_bfd_error_handler) (_("%s: The target (%s) of a %s relocation is in the wrong output section (%s)"),
+		(*_bfd_error_handler) (_("%s: the target (%s) of a %s relocation is in the wrong output section (%s)"),
 				       bfd_archive_filename (input_bfd),
 				       sym_name,
 				       howto->name,
@@ -5199,7 +5194,7 @@ ppc_elf_relocate_section (output_bfd, in
 	    if (! (strncmp (name, ".sdata2", 7) == 0
 		   || strncmp (name, ".sbss2", 6) == 0))
 	      {
-		(*_bfd_error_handler) (_("%s: The target (%s) of a %s relocation is in the wrong output section (%s)"),
+		(*_bfd_error_handler) (_("%s: the target (%s) of a %s relocation is in the wrong output section (%s)"),
 				       bfd_archive_filename (input_bfd),
 				       sym_name,
 				       howto->name,
@@ -5256,7 +5251,7 @@ ppc_elf_relocate_section (output_bfd, in
 
 	    else
 	      {
-		(*_bfd_error_handler) (_("%s: The target (%s) of a %s relocation is in the wrong output section (%s)"),
+		(*_bfd_error_handler) (_("%s: the target (%s) of a %s relocation is in the wrong output section (%s)"),
 				       bfd_archive_filename (input_bfd),
 				       sym_name,
 				       howto->name,
@@ -5310,7 +5305,7 @@ ppc_elf_relocate_section (output_bfd, in
 	case R_PPC_EMB_RELST_HA:
 	case R_PPC_EMB_BIT_FLD:
 	  (*_bfd_error_handler)
-	    (_("%s: Relocation %s is not yet supported for symbol %s."),
+	    (_("%s: relocation %s is not yet supported for symbol %s."),
 	     bfd_archive_filename (input_bfd),
 	     howto->name,
 	     sym_name);
@@ -5339,7 +5334,7 @@ ppc_elf_relocate_section (output_bfd, in
 	case R_PPC_EMB_NADDR16_HA:
 	case R_PPC_EMB_RELST_HA:
 	  /* It's just possible that this symbol is a weak symbol
-	     that's not actually defined anywhere. In that case,
+	     that's not actually defined anywhere.  In that case,
 	     'sec' would be NULL, and we should leave the symbol
 	     alone (it will be set to zero elsewhere in the link).  */
 	  if (sec != NULL)
@@ -5363,10 +5358,11 @@ ppc_elf_relocate_section (output_bfd, in
 	       && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0))
 	{
 	  (*_bfd_error_handler)
-	    (_("%s(%s+0x%lx): unresolvable relocation against symbol `%s'"),
+	    (_("%s(%s+0x%lx): unresolvable %s relocation against symbol `%s'"),
 	     bfd_archive_filename (input_bfd),
 	     bfd_get_section_name (input_bfd, input_section),
 	     (long) rel->r_offset,
+	     howto->name,
 	     sym_name);
 	  ret = FALSE;
 	}
@@ -5412,10 +5408,10 @@ ppc_elf_relocate_section (output_bfd, in
 	  else
 	    {
 	      (*_bfd_error_handler)
-		(_("%s(%s+0x%lx): reloc against `%s': error %d"),
+		(_("%s(%s+0x%lx): %s reloc against `%s': error %d"),
 		 bfd_archive_filename (input_bfd),
 		 bfd_get_section_name (input_bfd, input_section),
-		 (long) rel->r_offset, sym_name, (int) r);
+		 (long) rel->r_offset, howto->name, sym_name, (int) r);
 	      ret = FALSE;
 	    }
 	}
Index: bfd/elf64-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-ppc.c,v
retrieving revision 1.89
diff -u -p -r1.89 elf64-ppc.c
--- bfd/elf64-ppc.c	19 Feb 2003 11:44:15 -0000	1.89
+++ bfd/elf64-ppc.c	6 Mar 2003 11:27:04 -0000
@@ -2545,7 +2545,7 @@ struct plt_entry
    copying dynamic variables from a shared lib into an app's dynbss
    section, and instead use a dynamic relocation to point into the
    shared lib.  */
-#define ELIMINATE_COPY_RELOCS 1
+#define ELIMINATE_COPY_RELOCS 0
 
 /* Section name for stubs is the associated section name plus this
    string.  */
@@ -7670,21 +7670,22 @@ ppc64_elf_relocate_section (output_bfd, 
 		else
 		  {
 		    relocation += rel->r_addend;
-		    if (tls_type != 0)
+		    if (tls_type == (TLS_TLS | TLS_LD))
+		      relocation = 1;
+		    else if (tls_type != 0)
 		      {
 			relocation -= htab->tls_sec->vma + DTP_OFFSET;
-			if ((tls_type & TLS_TPREL) != 0)
+			if (tls_type == (TLS_TLS | TLS_TPREL))
 			  relocation += DTP_OFFSET - TP_OFFSET;
-		      }
 
-		    if ((tls_type & TLS_GD) != 0)
-		      {
-			bfd_put_64 (output_bfd, relocation,
-				    htab->sgot->contents + off + 8);
-			relocation = 1;
+			if (tls_type == (TLS_TLS | TLS_GD))
+			  {
+			    bfd_put_64 (output_bfd, relocation,
+					htab->sgot->contents + off + 8);
+			    relocation = 1;
+			  }
 		      }
-		    else if (tls_type == (TLS_TLS | TLS_LD))
-		      relocation = 1;
+
 		    bfd_put_64 (output_bfd, relocation,
 				htab->sgot->contents + off);
 		  }
@@ -7981,7 +7982,7 @@ ppc64_elf_relocate_section (output_bfd, 
 	  /* These ones haven't been implemented yet.  */
 
 	  (*_bfd_error_handler)
-	    (_("%s: Relocation %s is not supported for symbol %s."),
+	    (_("%s: relocation %s is not supported for symbol %s."),
 	     bfd_archive_filename (input_bfd),
 	     ppc64_elf_howto_table[(int) r_type]->name, sym_name);
 
@@ -8095,10 +8096,11 @@ ppc64_elf_relocate_section (output_bfd, 
 	       && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0))
 	{
 	  (*_bfd_error_handler)
-	    (_("%s(%s+0x%lx): unresolvable relocation against symbol `%s'"),
+	    (_("%s(%s+0x%lx): unresolvable %s relocation against symbol `%s'"),
 	     bfd_archive_filename (input_bfd),
 	     bfd_get_section_name (input_bfd, input_section),
 	     (long) rel->r_offset,
+	     ppc64_elf_howto_table[(int) r_type]->name,
 	     h->root.root.string);
 	  ret = FALSE;
 	}
@@ -8140,10 +8142,13 @@ ppc64_elf_relocate_section (output_bfd, 
 	  else
 	    {
 	      (*_bfd_error_handler)
-		(_("%s(%s+0x%lx): reloc against `%s': error %d"),
+		(_("%s(%s+0x%lx): %s reloc against `%s': error %d"),
 		 bfd_archive_filename (input_bfd),
 		 bfd_get_section_name (input_bfd, input_section),
-		 (long) rel->r_offset, sym_name, (int) r);
+		 (long) rel->r_offset,
+		 ppc64_elf_howto_table[(int) r_type]->name,
+		 sym_name,
+		 (int) r);
 	      ret = FALSE;
 	    }
 	}


-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

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

* Re: ppc32 broken with cvs head
  2003-03-06 11:33 ` Alan Modra
@ 2003-03-06 23:25   ` Alan Modra
  0 siblings, 0 replies; 4+ messages in thread
From: Alan Modra @ 2003-03-06 23:25 UTC (permalink / raw)
  To: Olaf Hering, binutils

On Thu, Mar 06, 2003 at 10:02:58PM +1030, Alan Modra wrote:
> On Wed, Mar 05, 2003 at 06:54:45PM +0100, Olaf Hering wrote:
> > unresolvable relocation against symbol `environ@@GLIBC_2.0'
> 
> A testcase for this is
> 
> cat > env.c <<EOF
> extern char *environ;
> int main (void) { return *environ; }
> EOF
> gcc -o env env.c -fPIC -O
> 
> The quick fix is to "#define ELIMINATE_COPY_RELOCS 0" at
> elf32-ppc.c:2458.  I'm afraid the ELIMINATE_COPY_RELOCS code is
> broken, and has been broken on x86 for a long time too.  In fact,
> it's quite surprising that no one has reported a bug in the x86
> code.  Maybe it's just harder to trigger there.

The fix was easy.  I've introduced an ELIMINATE_COPY_RELOCS define
for x86 too, mostly just to document the code.

	* elf32-ppc.c (ELIMINATE_COPY_RELOCS): Define as one.
	(ppc_elf_adjust_dynamic_symbol): For weak symbols, copy
	ELF_LINK_NON_GOT_REF from weakdef.
	* elf64-ppc.c (ELIMINATE_COPY_RELOCS): Define as one.
	(ppc64_elf_adjust_dynamic_symbol): For weak symbols, copy
	ELF_LINK_NON_GOT_REF from weakdef.
	* elf32-i386.c (ELIMINATE_COPY_RELOCS): Define as one.  Use throughout.
	(elf_i386_adjust_dynamic_symbol): For weak symbols, copy
	ELF_LINK_NON_GOT_REF from weakdef.

Index: bfd/elf32-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-ppc.c,v
retrieving revision 1.69
diff -u -p -r1.69 elf32-ppc.c
--- bfd/elf32-ppc.c	6 Mar 2003 11:32:43 -0000	1.69
+++ bfd/elf32-ppc.c	6 Mar 2003 23:15:56 -0000
@@ -2455,7 +2455,7 @@ ppc_elf_create_dynamic_sections (abfd, i
    copying dynamic variables from a shared lib into an app's dynbss
    section, and instead use a dynamic relocation to point into the
    shared lib.  */
-#define ELIMINATE_COPY_RELOCS 0
+#define ELIMINATE_COPY_RELOCS 1
 
 /* Adjust a symbol defined by a dynamic object and referenced by a
    regular object.  The current definition is in some section of the
@@ -2525,6 +2525,10 @@ ppc_elf_adjust_dynamic_symbol (info, h)
 		  || h->weakdef->root.type == bfd_link_hash_defweak);
       h->root.u.def.section = h->weakdef->root.u.def.section;
       h->root.u.def.value = h->weakdef->root.u.def.value;
+      if (ELIMINATE_COPY_RELOCS)
+	h->elf_link_hash_flags
+	  = ((h->elf_link_hash_flags & ~ELF_LINK_NON_GOT_REF)
+	     | (h->weakdef->elf_link_hash_flags & ELF_LINK_NON_GOT_REF));
       return TRUE;
     }
 
Index: bfd/elf64-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-ppc.c,v
retrieving revision 1.90
diff -u -p -r1.90 elf64-ppc.c
--- bfd/elf64-ppc.c	6 Mar 2003 11:32:43 -0000	1.90
+++ bfd/elf64-ppc.c	6 Mar 2003 23:15:59 -0000
@@ -2545,7 +2545,7 @@ struct plt_entry
    copying dynamic variables from a shared lib into an app's dynbss
    section, and instead use a dynamic relocation to point into the
    shared lib.  */
-#define ELIMINATE_COPY_RELOCS 0
+#define ELIMINATE_COPY_RELOCS 1
 
 /* Section name for stubs is the associated section name plus this
    string.  */
@@ -4518,6 +4518,10 @@ ppc64_elf_adjust_dynamic_symbol (info, h
 		  || h->weakdef->root.type == bfd_link_hash_defweak);
       h->root.u.def.section = h->weakdef->root.u.def.section;
       h->root.u.def.value = h->weakdef->root.u.def.value;
+      if (ELIMINATE_COPY_RELOCS)
+	h->elf_link_hash_flags
+	  = ((h->elf_link_hash_flags & ~ELF_LINK_NON_GOT_REF)
+	     | (h->weakdef->elf_link_hash_flags & ELF_LINK_NON_GOT_REF));
       return TRUE;
     }
 
Index: bfd/elf32-i386.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-i386.c,v
retrieving revision 1.95
diff -u -p -r1.95 elf32-i386.c
--- bfd/elf32-i386.c	19 Feb 2003 14:14:16 -0000	1.95
+++ bfd/elf32-i386.c	6 Mar 2003 23:15:52 -0000
@@ -506,6 +506,12 @@ elf_i386_grok_psinfo (abfd, note)
 
 #define ELF_DYNAMIC_INTERPRETER "/usr/lib/libc.so.1"
 
+/* If ELIMINATE_COPY_RELOCS is non-zero, the linker will try to avoid
+   copying dynamic variables from a shared lib into an app's dynbss
+   section, and instead use a dynamic relocation to point into the
+   shared lib.  */
+#define ELIMINATE_COPY_RELOCS 1
+
 /* The size in bytes of an entry in the procedure linkage table.  */
 
 #define PLT_ENTRY_SIZE 16
@@ -1106,7 +1112,8 @@ elf_i386_check_relocs (abfd, info, sec, 
 			   || h->root.type == bfd_link_hash_defweak
 			   || (h->elf_link_hash_flags
 			       & ELF_LINK_HASH_DEF_REGULAR) == 0))))
-	      || (!info->shared
+	      || (ELIMINATE_COPY_RELOCS
+		  && !info->shared
 		  && (sec->flags & SEC_ALLOC) != 0
 		  && h != NULL
 		  && (h->root.type == bfd_link_hash_defweak
@@ -1372,8 +1379,6 @@ elf_i386_adjust_dynamic_symbol (info, h)
      struct elf_link_hash_entry *h;
 {
   struct elf_i386_link_hash_table *htab;
-  struct elf_i386_link_hash_entry * eh;
-  struct elf_i386_dyn_relocs *p;
   asection *s;
   unsigned int power_of_two;
 
@@ -1418,6 +1423,10 @@ elf_i386_adjust_dynamic_symbol (info, h)
 		  || h->weakdef->root.type == bfd_link_hash_defweak);
       h->root.u.def.section = h->weakdef->root.u.def.section;
       h->root.u.def.value = h->weakdef->root.u.def.value;
+      if (ELIMINATE_COPY_RELOCS || info->nocopyreloc)
+	h->elf_link_hash_flags
+	  = ((h->elf_link_hash_flags & ~ELF_LINK_NON_GOT_REF)
+	     | (h->weakdef->elf_link_hash_flags & ELF_LINK_NON_GOT_REF));
       return TRUE;
     }
 
@@ -1443,20 +1452,26 @@ elf_i386_adjust_dynamic_symbol (info, h)
       return TRUE;
     }
 
-  eh = (struct elf_i386_link_hash_entry *) h;
-  for (p = eh->dyn_relocs; p != NULL; p = p->next)
+  if (ELIMINATE_COPY_RELOCS)
     {
-      s = p->sec->output_section;
-      if (s != NULL && (s->flags & SEC_READONLY) != 0)
-	break;
-    }
+      struct elf_i386_link_hash_entry * eh;
+      struct elf_i386_dyn_relocs *p;
 
-  /* If we didn't find any dynamic relocs in read-only sections, then
-     we'll be keeping the dynamic relocs and avoiding the copy reloc.  */
-  if (p == NULL)
-    {
-      h->elf_link_hash_flags &= ~ELF_LINK_NON_GOT_REF;
-      return TRUE;
+      eh = (struct elf_i386_link_hash_entry *) h;
+      for (p = eh->dyn_relocs; p != NULL; p = p->next)
+	{
+	  s = p->sec->output_section;
+	  if (s != NULL && (s->flags & SEC_READONLY) != 0)
+	    break;
+	}
+
+      /* If we didn't find any dynamic relocs in read-only sections, then
+	 we'll be keeping the dynamic relocs and avoiding the copy reloc.  */
+      if (p == NULL)
+	{
+	  h->elf_link_hash_flags &= ~ELF_LINK_NON_GOT_REF;
+	  return TRUE;
+	}
     }
 
   /* We must allocate the symbol in our .dynbss section, which will
@@ -1676,7 +1691,7 @@ allocate_dynrelocs (h, inf)
 	    }
 	}
     }
-  else
+  else if (ELIMINATE_COPY_RELOCS)
     {
       /* For the non-shared case, discard space for relocs against
 	 symbols which turn out to need copy relocs or are not
@@ -2412,7 +2427,8 @@ elf_i386_relocate_section (output_bfd, i
 		       && (! info->symbolic
 			   || (h->elf_link_hash_flags
 			       & ELF_LINK_HASH_DEF_REGULAR) == 0))))
-	      || (!info->shared
+	      || (ELIMINATE_COPY_RELOCS
+		  && !info->shared
 		  && h != NULL
 		  && h->dynindx != -1
 		  && (h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

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

end of thread, other threads:[~2003-03-06 23:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-05 17:55 ppc32 broken with cvs head Olaf Hering
2003-03-05 21:45 ` Olaf Hering
2003-03-06 11:33 ` Alan Modra
2003-03-06 23:25   ` Alan Modra

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).