This is the mail archive of the binutils@sourceware.cygnus.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]

elf st_other ramblings and patch.



I'm working on the last change to the elf picoJava port.  I need to do
some nasty relaxing in the linker to fix up the text when the caller
sends a different number of arguments than the callee expects.
(This happens all the time, eg a call to main).

To pass argument information from gcc to the linker I'm using the
st_other field in each function's symbol.

This all works wonderfully, save for when there's a weak symbol in a
library with an st_other field set, and there's a defined symbol in
the program being linked, and the library and the .o file disagree on
argument counts.

Eg, perl in spec95 defines a regexec which takes 7 arguments.  The
regexec in glibc takes 5 arguments.  So initially there's a symbol for
regexec with an st_other of 7, then later on the linker notices the
weak symbol in glibc and overwrites the st_other field attached to the
strong definition of regexec with the value from the weak symbol, even
though the weak definition won't be used with that name.

The current behavior does seem odd.  This is a patch which changes it.
I don't know for sure if this will break any of the other occult uses
of st_other and I don't really grok this new fangled weak stuff. Yet.

Steve

1999-09-28  Steve Chamberlain  <sac@pobox.com>

	*  elflink.h (elf_link_add_object_symbols): Don't overwrite the
	st_other field of a symbol if the existing symbol is defined and
	the new symbol is weak.

bash$ cvs -z9 diff -c3p elflink.h
Index: elflink.h
===================================================================
RCS file: /cvs/binutils/binutils/bfd/elflink.h,v
retrieving revision 1.34
diff -c -3 -p -r1.34 elflink.h
*** elflink.h	1999/09/10 04:22:23	1.34
--- elflink.h	1999/09/28 23:23:27
*************** elf_link_add_object_symbols (abfd, info)
*** 1414,1420 ****
  	    }
  
  	  if (sym.st_other != 0
! 	      && (definition || h->other == 0))
  	    h->other = sym.st_other;
  
  	  /* Set a flag in the hash table entry indicating the type of
--- 1414,1421 ----
  	    }
  
  	  if (sym.st_other != 0
! 	      && (definition || h->other == 0)
! 	      && !(bind == STB_WEAK && h->root.type == bfd_link_hash_defined))
  	    h->other = sym.st_other;
  
  	  /* Set a flag in the hash table entry indicating the type of





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