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]

[patch] [rfa] Fix ld "weak symbols" test for sh-elf.


This is a fix to the "weak symbols" test in ld.  Comment in patch should
clarify.  It does not handle brokenness (if any) for other object formats,
particularly COFF.  (There's a big scary comment with scary COFF-specific
kludges in bfd_install_relocation.)  Note that sh emits non-zero stuff
in-place in the object file for relocations, despite being RELA.

Ok to commit?

2000-10-29  Hans-Peter Nilsson  <hp@bitrange.com>

	* config/tc-sh.c (md_apply_fix): For ELF, do not "adjust back" VAL
	for weak symbols.

Index: tc-sh.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-sh.c,v
retrieving revision 1.25
diff -p -c -r1.25 tc-sh.c
*** tc-sh.c	2000/10/25 19:15:33	1.25
--- tc-sh.c	2000/10/29 16:51:23
*************** md_apply_fix (fixP, val)
*** 2767,2774 ****
    /* The function adjust_reloc_syms won't convert a reloc against a weak
       symbol into a reloc against a section, but bfd_install_relocation
       will screw up if the symbol is defined, so we have to adjust val here
!      to avoid the screw up later.  */
!   if (fixP->fx_addsy != NULL
        && S_IS_WEAK (fixP->fx_addsy))
      val -= S_GET_VALUE  (fixP->fx_addsy);
  #endif
--- 2764,2780 ----
    /* The function adjust_reloc_syms won't convert a reloc against a weak
       symbol into a reloc against a section, but bfd_install_relocation
       will screw up if the symbol is defined, so we have to adjust val here
!      to avoid the screw up later.
! 
!      For ordinary relocs, this does not happen for ELF, since for ELF,
!      bfd_install_relocation uses the "special function" field of the
!      howto, and does not execute the code that needs to be undone, as long
!      as the special function does not return bfd_reloc_continue.
!      It can happen for GOT- and PLT-type relocs the way they are
!      described in elf32-sh.c as they use bfd_elf_generic_reloc, but it
!      doesn't matter here since those relocs don't use VAL; see below.  */
!   if (OUTPUT_FLAVOR != bfd_target_elf_flavour
!       && fixP->fx_addsy != NULL
        && S_IS_WEAK (fixP->fx_addsy))
      val -= S_GET_VALUE  (fixP->fx_addsy);
  #endif

brgds, H-P



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