This is the mail archive of the binutils@sources.redhat.com 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]

Re: PATCH for i386: --no-copy-relocs


The aim of this patch which I committed a little while ago, is to fix
R_386_32 relocs to undefined weak syms.

I'm already having second thoughts about its correctness.  :-(  For one,
we will probably be marking symbols as dynamic that don't need to be
dynamic in non-shared links.  Secondly, marking undefined weak syms
as dynamic should probably happen somewhere in elflink.h for all
architectures.

The assumption I'm making is that an application linked against shared
libs such that it is left with undefined weak references should have
them satisfied by the dynamic linker if new libraries defining the
syms become available.  As of now, this works only because of hacks in
the backends like the one I've just added.

bfd/ChangeLog
	* elf32-i386.c (elf_i386_check_relocs <R_386_32, R_386_PC32>):
	Ensure syms are dynamic if we might be emitting a reloc.
	(allocate_plt_and_got_and_discard_relocs): Don't discard relocs
	for undefweak or undefined syms..
	(elf_i386_relocate_section <R_386_32, R_386_PC32>): .. and emit.

-- 
Alan Modra

Index: bfd/elf32-i386.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-i386.c,v
retrieving revision 1.34
diff -u -p -r1.34 elf32-i386.c
--- elf32-i386.c	2001/06/25 02:40:47	1.34
+++ elf32-i386.c	2001/06/25 06:52:52
@@ -725,6 +725,13 @@ elf_i386_check_relocs (abfd, info, sec, 
 		 this reloc.  */
 	      if (dynobj == NULL)
 		htab->root.dynobj = dynobj = abfd;
+
+	      if (h != NULL && h->dynindx == -1)
+		{
+		  if (! bfd_elf32_link_record_dynamic_symbol (info, h))
+		    return false;
+		}
+
 	      if (sreloc == NULL)
 		{
 		  const char *name;
@@ -1195,7 +1202,9 @@ allocate_plt_and_got_and_discard_relocs 
       || (!info->shared
 	  && (h->dynindx == -1
 	      || (h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) != 0
-	      || (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) == 0)))
+	      || ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) == 0
+		  && h->root.type != bfd_link_hash_undefweak
+		  && h->root.type != bfd_link_hash_undefined))))
     {
       struct elf_i386_link_hash_entry *eh;
       struct elf_i386_dyn_relocs *c;
@@ -1694,8 +1703,10 @@ elf_i386_relocate_section (output_bfd, i
 		  && h != NULL
 		  && h->dynindx != -1
 		  && (h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0
-		  && (h->elf_link_hash_flags
-		      & ELF_LINK_HASH_DEF_DYNAMIC) != 0))
+		  && ((h->elf_link_hash_flags
+		       & ELF_LINK_HASH_DEF_DYNAMIC) != 0
+		      || h->root.type == bfd_link_hash_undefweak
+		      || h->root.type == bfd_link_hash_undefined)))
 	    {
 	      Elf_Internal_Rel outrel;
 	      boolean skip, relocate;


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