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: PR 6848: Not all targets generate relocs against kept symbols.


Hi Alan,

  Your fix for PR 6848 has introduced new testsuite failures for
  various ports, most notably the FRV:
  
FAIL: FRV TLS relocs, static linking
FAIL: FRV TLS relocs, dynamic linking
FAIL: FRV TLS relocs, pie linking
FAIL: FRV TLS relocs, shared linking
FAIL: FRV TLS relocs, shared linking with local binding
FAIL: FRV TLS relocs, static linking with relaxation
FAIL: FRV TLS relocs, dynamic linking with relaxation
FAIL: FRV TLS relocs, pie linking with relaxation
FAIL: FRV TLS relocs, shared linking with relaxation
FAIL: FRV TLS relocs with addends, dynamic linking
FAIL: FRV TLS relocs with addends, shared linking
FAIL: FRV TLS relocs with addends, shared linking with static TLS
FAIL: FRV TLS relocs with addends, dynamic linking, relaxing
FAIL: FRV TLS relocs with addends, shared linking, relaxing
FAIL: FRV TLS relocs with addends, shared linking with static TLS, relaxing

  and the MMIX:

FAIL: gas/mmix/err-bpo6.s (test for excess errors)
FAIL: gas/mmix/basep-1
FAIL: gas/mmix/basep-10
FAIL: gas/mmix/basep-1b
FAIL: gas/mmix/basep-2
FAIL: gas/mmix/basep-2b
FAIL: gas/mmix/basep-3
FAIL: gas/mmix/basep-3b
FAIL: gas/mmix/basep-7
FAIL: gas/mmix/basep-9
FAIL: gas/mmix/greg4
FAIL: gas/mmix/greg5
FAIL: gas/mmix/greg6
FAIL: gas/mmix/greg7
FAIL: gas/mmix/greg8

  I think that we need a target specific escape mechanism to allow
  relocs against unemitted symbols in certain cases.  Something like
  the patch below.  What do you think ?

Cheers
  Nick

Index: gas/write.c
===================================================================
RCS file: /cvs/src/src/gas/write.c,v
retrieving revision 1.118
diff -c -3 -p -r1.118 write.c
*** gas/write.c	20 Aug 2008 13:43:32 -0000	1.118
--- gas/write.c	14 Sep 2008 09:00:41 -0000
*************** fix_segment (bfd *abfd ATTRIBUTE_UNUSED,
*** 1078,1083 ****
--- 1078,1087 ----
    fixup_segment (seginfo->fix_root, sec);
  }
  
+ #ifndef tc_allow_reloc_against_unemitted_symbol
+ #define tc_allow_reloc_against_unemitted_symbol(reloc, sym) false
+ #endif
+ 
  static void
  install_reloc (asection *sec, arelent *reloc, fragS *fragp,
  	       char *file, unsigned int line)
*************** install_reloc (asection *sec, arelent *r
*** 1091,1098 ****
        && (sym->flags & BSF_KEEP) == 0
        && ((sym->flags & BSF_SECTION_SYM) == 0
  	  || !EMIT_SECTION_SYMBOLS
! 	  || !bfd_is_abs_section (sym->section)))
!     as_bad_where (file, line, _("redefined symbol cannot be used on reloc"));
  
    s = bfd_install_relocation (stdoutput, reloc,
  			      fragp->fr_literal, fragp->fr_address,
--- 1095,1103 ----
        && (sym->flags & BSF_KEEP) == 0
        && ((sym->flags & BSF_SECTION_SYM) == 0
  	  || !EMIT_SECTION_SYMBOLS
! 	  || !bfd_is_abs_section (sym->section))
!       && ! tc_allow_reloc_against_unemitted_symbol (reloc, sym))
!     as_bad_where (file, line, _("redefined symbol '%s' cannot be used on reloc"), sym->name);
  
    s = bfd_install_relocation (stdoutput, reloc,
  			      fragp->fr_literal, fragp->fr_address,
Index: gas/config/tc-frv.h
===================================================================
RCS file: /cvs/src/src/gas/config/tc-frv.h,v
retrieving revision 1.12
diff -c -3 -p -r1.12 tc-frv.h
*** gas/config/tc-frv.h	12 Aug 2008 23:39:30 -0000	1.12
--- gas/config/tc-frv.h	14 Sep 2008 09:00:41 -0000
*************** extern void frv_frob_file (void);
*** 122,124 ****
--- 122,127 ----
  	}								\
      }									\
   while (0)
+ 
+ /* TLS relocs resolve to a dollar label, which is OK, since the linker will adjust them.  */
+ #define tc_allow_reloc_against_unemitted_symbol(reloc, sym) (strchr (sym->name, '\001'))
Index: gas/config/tc-mmix.h
===================================================================
RCS file: /cvs/src/src/gas/config/tc-mmix.h,v
retrieving revision 1.12
diff -c -3 -p -r1.12 tc-mmix.h
*** gas/config/tc-mmix.h	3 Jul 2007 11:01:04 -0000	1.12
--- gas/config/tc-mmix.h	14 Sep 2008 09:00:41 -0000
*************** extern void mmix_md_do_align (int, char 
*** 224,226 ****
--- 224,233 ----
  
  /* This target is buggy, and sets fix size too large.  */
  #define TC_FX_SIZE_SLACK(FIX) 6
+ 
+ #include "elf/mmix.h"
+ 
+ /* Allow relocs against the MMIX reg contents symbol - it will be
+    created by the linker.  */
+ #define tc_allow_reloc_against_unemitted_symbol(reloc, sym) \
+   (strcmp (sym->name, MMIX_REG_CONTENTS_SECTION_NAME) == 0)
Index: gas/doc/internals.texi
===================================================================
RCS file: /cvs/src/src/gas/doc/internals.texi,v
retrieving revision 1.60
diff -c -3 -p -r1.60 internals.texi
*** gas/doc/internals.texi	12 Aug 2008 23:39:31 -0000	1.60
--- gas/doc/internals.texi	14 Sep 2008 09:00:42 -0000
*************** poorly, as @code{bfd_install_relocation}
*** 1354,1359 ****
--- 1354,1369 ----
  instances of @code{tc_gen_reloc} have been written to work around the problems,
  which in turns makes it difficult to fix @code{bfd_install_relocation}.
  
+ @item tc_allow_reloc_against_unemitted_symbol (@var{reloc}, @var{sym})
+ @cindex tc_allow_reloc_against_unemitted_symbol
+ Define this macro if it is permissable for GAS to generate @var{reloc} against
+ symbol @var{sym} even though this symbol is not going to be emitted into the
+ symbol table of the object file.  GAs will normally refuse to emit a reloc
+ against a symbol which is not going to be in the symbol table, but this macro
+ allows targets to override this behaviour for specific relocations and symbols.
+ This may be necessary if the relocation ignores the symbol, or if the symbol is
+ going to be created by the linker.
+ 
  @item RELOC_EXPANSION_POSSIBLE
  @cindex RELOC_EXPANSION_POSSIBLE
  If you define this macro, it means that @code{tc_gen_reloc} may return multiple


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