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]

Re: [PATCH][RFC] Explicitly set ELF symbol size to zero for undefined symbols -- libbfd, gold


On Mon, Jul 21, 2008 at 09:09:34AM -0700, Matt Thomas wrote:
> This won't solve the problem because the backends can set the section
> to SHN_UNDEF in finish_dynamic_symbol (see elf64-x86_64.c).

Yes, my suggestion fails for some symbols.  (It's really the backend
changing h->root.u.def.section to .plt in allocate_dynrelocs that
causes you to miss the code path setting st_size to zero.)

The following modification of Simon's original patch ought to work.
Please verify and commit.

2008-07-22  Simon Baldwin  <simonb@google.com>

	* elflink.c (elf_link_output_extsym): Set st_size to zero for
	symbols from dynamic libraries.

Index: bfd/elflink.c
===================================================================
RCS file: /cvs/src/src/bfd/elflink.c,v
retrieving revision 1.304
diff -u -p -r1.304 elflink.c
--- bfd/elflink.c	29 Apr 2008 11:53:45 -0000	1.304
+++ bfd/elflink.c	22 Jul 2008 02:36:25 -0000
@@ -8618,6 +8618,15 @@ elf_link_output_extsym (struct elf_link_
       sym.st_info = ELF_ST_INFO (bindtype, ELF_ST_TYPE (sym.st_info));
     }
 
+  /* If this is a symbol defined in a dynamic library, don't use the
+     symbol size from the dynamic library.  Relinking an executable
+     against a new library may introduce gratuitous changes in the
+     executable's symbols if we keep the size.  */
+  if (sym.st_shndx == SHN_UNDEF
+      && !h->def_regular
+      && h->def_dynamic)
+    sym.st_size = 0;
+
   /* If a non-weak symbol with non-default visibility is not defined
      locally, it is a fatal error.  */
   if (! finfo->info->relocatable

-- 
Alan Modra
Australia Development Lab, IBM


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