Allow target files access to default TC_FORCE_RELOCATION defines

* write.c (GENERIC_FORCE_RELOCATION_LOCAL): Define.
	(TC_FORCE_RELOCATION_LOCAL): Use it.
	(GENERIC_FORCE_RELOCATION_SUB_SAME): Define.
	(TC_FORCE_RELOCATION_SUB_SAME): Use it.
	* config/tc-arm.h (TC_FORCE_RELOCATION_LOCAL,
	TC_FORCE_RELOCATION_SUB_SAME): Use GENERIC defines.
	* config/tc-aarch64.h: Similarly.
	* config/tc-avr.h: Similarly.
	* config/tc-cris.h: Similarly.
	* config/tc-i386.h: Similarly.
	* config/tc-i960.h: Similarly.
	* config/tc-ia64.h: Similarly.
	* config/tc-microblaze.h: Similarly.
	* config/tc-mips.h: Similarly.
	* config/tc-msp430.h: Similarly.
	* config/tc-nds32.h: Similarly.
	* config/tc-pru.h: Similarly.
	* config/tc-riscv.h: Similarly.
	* config/tc-rl78.h: Similarly.
	* config/tc-s390.h: Similarly.
	* config/tc-sh.h: Similarly.
	* config/tc-sh64.h: Similarly.
	* config/tc-sparc.h: Similarly.
	* config/tc-xtensa.h: Similarly.
	* config/tc-mn10300.h: Similarly.
	(GENERIC_FORCE_RELOCATION_LOCAL): Define.
	* config/tc-msp430.c (msp430_force_relocation_local): Modify to
	be addition to rather than replacement of standard
	TC_FORCE_RELOCATION_LOCAL.
This commit is contained in:
Alan Modra 2017-05-16 08:43:24 +09:30
parent bc4e12ded1
commit 91cb9803fc
23 changed files with 103 additions and 63 deletions

View File

@ -1,3 +1,35 @@
2017-05-16 Alan Modra <amodra@gmail.com>
* write.c (GENERIC_FORCE_RELOCATION_LOCAL): Define.
(TC_FORCE_RELOCATION_LOCAL): Use it.
(GENERIC_FORCE_RELOCATION_SUB_SAME): Define.
(TC_FORCE_RELOCATION_SUB_SAME): Use it.
* config/tc-arm.h (TC_FORCE_RELOCATION_LOCAL,
TC_FORCE_RELOCATION_SUB_SAME): Use GENERIC defines.
* config/tc-aarch64.h: Similarly.
* config/tc-avr.h: Similarly.
* config/tc-cris.h: Similarly.
* config/tc-i386.h: Similarly.
* config/tc-i960.h: Similarly.
* config/tc-ia64.h: Similarly.
* config/tc-microblaze.h: Similarly.
* config/tc-mips.h: Similarly.
* config/tc-msp430.h: Similarly.
* config/tc-nds32.h: Similarly.
* config/tc-pru.h: Similarly.
* config/tc-riscv.h: Similarly.
* config/tc-rl78.h: Similarly.
* config/tc-s390.h: Similarly.
* config/tc-sh.h: Similarly.
* config/tc-sh64.h: Similarly.
* config/tc-sparc.h: Similarly.
* config/tc-xtensa.h: Similarly.
* config/tc-mn10300.h: Similarly.
(GENERIC_FORCE_RELOCATION_LOCAL): Define.
* config/tc-msp430.c (msp430_force_relocation_local): Modify to
be addition to rather than replacement of standard
TC_FORCE_RELOCATION_LOCAL.
2017-05-15 Nick Clifton <nickc@redhat.com>
PR gas/21458

View File

@ -109,10 +109,9 @@ void aarch64_copy_symbol_attributes (symbolS *, symbolS *);
pcrel, but it is easier to be safe than sorry. */
#define TC_FORCE_RELOCATION_LOCAL(FIX) \
(!(FIX)->fx_pcrel \
(GENERIC_FORCE_RELOCATION_LOCAL (FIX) \
|| (FIX)->fx_r_type == BFD_RELOC_64 \
|| (FIX)->fx_r_type == BFD_RELOC_32 \
|| TC_FORCE_RELOCATION (FIX))
|| (FIX)->fx_r_type == BFD_RELOC_32)
#define TC_CONS_FIX_NEW(f,w,s,e,r) cons_fix_new_aarch64 ((f), (w), (s), (e))

View File

@ -200,17 +200,17 @@ void arm_copy_symbol_attributes (symbolS *, symbolS *);
pcrel, but it is easier to be safe than sorry. */
#define TC_FORCE_RELOCATION_LOCAL(FIX) \
(!(FIX)->fx_pcrel \
(GENERIC_FORCE_RELOCATION_LOCAL (FIX) \
|| (FIX)->fx_r_type == BFD_RELOC_ARM_GOT32 \
|| (FIX)->fx_r_type == BFD_RELOC_32 \
|| ((FIX)->fx_addsy != NULL && S_IS_WEAK ((FIX)->fx_addsy)) \
|| TC_FORCE_RELOCATION (FIX))
|| ((FIX)->fx_addsy != NULL \
&& S_IS_WEAK ((FIX)->fx_addsy)))
/* Force output of R_ARM_REL32 relocations against thumb function symbols.
This is needed to ensure the low bit is handled correctly. */
#define TC_FORCE_RELOCATION_SUB_SAME(FIX, SEG) \
(THUMB_IS_FUNC ((FIX)->fx_addsy) \
|| !SEG_NORMAL (SEG))
(GENERIC_FORCE_RELOCATION_SUB_SAME (FIX, SEG) \
|| THUMB_IS_FUNC ((FIX)->fx_addsy))
#define TC_FORCE_RELOCATION_ABS(FIX) \
(((FIX)->fx_pcrel \

View File

@ -123,7 +123,8 @@ extern void avr_cons_fix_new (fragS *,int, int, expressionS *,
even when the value can be resolved locally. Do that if linkrelax is turned on */
#define TC_FORCE_RELOCATION(fix) avr_force_relocation (fix)
#define TC_FORCE_RELOCATION_SUB_SAME(fix, seg) \
(! SEG_NORMAL (seg) || avr_force_relocation (fix))
(GENERIC_FORCE_RELOCATION_SUB_SAME (fix, seg) \
|| avr_force_relocation (fix))
extern int avr_force_relocation (struct fix *);
/* Values passed to md_apply_fix don't include the symbol value. */

View File

@ -93,9 +93,8 @@ extern int md_cris_force_relocation (struct fix *);
/* Make sure we don't resolve fixups for which we want to emit dynamic
relocations. */
#define TC_FORCE_RELOCATION_LOCAL(FIX) \
(!(FIX)->fx_pcrel \
|| IS_CRIS_PIC_RELOC ((FIX)->fx_r_type) \
|| TC_FORCE_RELOCATION (FIX))
(GENERIC_FORCE_RELOCATION_LOCAL (FIX) \
|| IS_CRIS_PIC_RELOC ((FIX)->fx_r_type))
/* For some reloc types, don't adjust fixups by reducing to a section
symbol. */

View File

@ -171,12 +171,11 @@ extern int tc_i386_fix_adjustable (struct fix *);
they are not pcrel. .*/
#define TC_FORCE_RELOCATION_LOCAL(FIX) \
(!(FIX)->fx_pcrel \
(GENERIC_FORCE_RELOCATION_LOCAL (FIX) \
|| (FIX)->fx_r_type == BFD_RELOC_386_PLT32 \
|| (FIX)->fx_r_type == BFD_RELOC_386_GOTPC \
|| (FIX)->fx_r_type == BFD_RELOC_X86_64_GOTPCRELX \
|| (FIX)->fx_r_type == BFD_RELOC_X86_64_REX_GOTPCRELX \
|| TC_FORCE_RELOCATION (FIX))
|| (FIX)->fx_r_type == BFD_RELOC_X86_64_REX_GOTPCRELX)
extern int i386_parse_name (char *, expressionS *, char *);
#define md_parse_name(s, e, m, c) i386_parse_name (s, e, c)

View File

@ -122,8 +122,8 @@ struct relocation_info
/* Makes no sense to use the difference of 2 arbitrary symbols
as the target of a call instruction. */
#define TC_FORCE_RELOCATION_SUB_SAME(FIX, SEG) \
((FIX)->fx_tcbit \
|| ! SEG_NORMAL (SEG) \
(GENERIC_FORCE_RELOCATION_SUB_SAME (FIX, SEG) \
|| (FIX)->fx_tcbit \
|| TC_FORCE_RELOCATION (FIX))
/* reloc_callj() may replace a 'call' with a 'calls' or a
@ -136,8 +136,7 @@ extern int reloc_callj (struct fix *);
|| reloc_callj (FIX))
#define TC_FORCE_RELOCATION_LOCAL(FIX) \
(!(FIX)->fx_pcrel \
|| TC_FORCE_RELOCATION (FIX) \
(GENERIC_FORCE_RELOCATION_LOCAL (FIX) \
|| reloc_callj (FIX))
#ifdef OBJ_COFF

View File

@ -320,9 +320,8 @@ typedef struct unwind_record
#define TC_FORCE_RELOCATION_LOCAL(FIX) \
((FIX)->fx_r_type != BFD_RELOC_UNUSED \
&& (!(FIX)->fx_pcrel \
|| (FIX)->fx_r_type == BFD_RELOC_IA64_PLTOFF22 \
|| TC_FORCE_RELOCATION (FIX)))
&& (GENERIC_FORCE_RELOCATION_LOCAL (FIX) \
|| (FIX)->fx_r_type == BFD_RELOC_IA64_PLTOFF22))
/* VMS backtraces expect dwarf version 3. */
#ifdef TE_VMS

View File

@ -44,13 +44,12 @@ extern bfd_reloc_code_real_type parse_cons_expression_microblaze
#define TC_FORCE_RELOCATION_SECTION(FIXP,SEG) 1
#define UNDEFINED_DIFFERENCE_OK 1
#define TC_FORCE_RELOCATION_LOCAL(FIX) \
(!(FIX)->fx_pcrel \
|| (FIX)->fx_r_type == BFD_RELOC_MICROBLAZE_64_GOT \
|| (FIX)->fx_r_type == BFD_RELOC_MICROBLAZE_64_PLT \
#define TC_FORCE_RELOCATION_LOCAL(FIX) \
(GENERIC_FORCE_RELOCATION_LOCAL (FIX) \
|| (FIX)->fx_r_type == BFD_RELOC_MICROBLAZE_64_GOT \
|| (FIX)->fx_r_type == BFD_RELOC_MICROBLAZE_64_PLT \
|| (FIX)->fx_r_type == BFD_RELOC_MICROBLAZE_64_GOTOFF \
|| (FIX)->fx_r_type == BFD_RELOC_MICROBLAZE_32_GOTOFF \
|| TC_FORCE_RELOCATION (FIX))
|| (FIX)->fx_r_type == BFD_RELOC_MICROBLAZE_32_GOTOFF)
#define tc_fix_adjustable(X) tc_microblaze_fix_adjustable(X)
extern int tc_microblaze_fix_adjustable (struct fix *);

View File

@ -140,7 +140,8 @@ extern int mips_fix_adjustable (struct fix *);
extern int mips_force_relocation (struct fix *);
#define TC_FORCE_RELOCATION_SUB_SAME(FIX, SEG) \
(! SEG_NORMAL (SEG) || mips_force_relocation (FIX))
(GENERIC_FORCE_RELOCATION_SUB_SAME (FIX, SEG) \
|| mips_force_relocation (FIX))
#define TC_FORCE_RELOCATION_ABS(FIX) mips_force_relocation_abs (FIX)
extern bfd_boolean mips_force_relocation_abs (struct fix *);

View File

@ -28,12 +28,20 @@
#define TC_FORCE_RELOCATION(FIX) mn10300_force_relocation (FIX)
extern bfd_boolean mn10300_force_relocation (struct fix *);
/* tc-mn10300.c uses TC_FORCE_RELOCATION_LOCAL, a macro that should
only appear in write.c. The use is likely incorrect. Duplicating
the definition here rather than expanding it in
TC_FORCE_RELOCATION_LOCAL at least ensures write.c changes will be
flagged immediately with a compile error. */
#define GENERIC_FORCE_RELOCATION_LOCAL(FIX) \
(!(FIX)->fx_pcrel \
|| TC_FORCE_RELOCATION (FIX))
#define TC_FORCE_RELOCATION_LOCAL(FIX) \
(!(FIX)->fx_pcrel \
(GENERIC_FORCE_RELOCATION_LOCAL (FIX) \
|| (FIX)->fx_r_type == BFD_RELOC_32_PLT_PCREL \
|| (FIX)->fx_r_type == BFD_RELOC_MN10300_GOT32 \
|| (FIX)->fx_r_type == BFD_RELOC_32_GOT_PCREL \
|| TC_FORCE_RELOCATION (FIX))
|| (FIX)->fx_r_type == BFD_RELOC_32_GOT_PCREL)
#define md_parse_name(NAME, EXPRP, MODE, NEXTCHARP) \
mn10300_parse_name ((NAME), (EXPRP), (MODE), (NEXTCHARP))
@ -63,8 +71,8 @@ void mn10300_cons_fix_new (fragS *, int, int, expressionS *,
linker, but this fix is simpler, and it pretty much only affects
object size a little bit. */
#define TC_FORCE_RELOCATION_SUB_SAME(FIX, SEC) \
(((SEC)->flags & SEC_CODE) != 0 \
|| ! SEG_NORMAL (SEC) \
(GENERIC_FORCE_RELOCATION_SUB_SAME (FIX, SEC) \
|| ((SEC)->flags & SEC_CODE) != 0 \
|| (FIX)->fx_r_type == BFD_RELOC_MN10300_ALIGN \
|| TC_FORCE_RELOCATION (FIX))

View File

@ -3950,7 +3950,7 @@ md_pcrel_from_section (fixS * fixp, segT sec)
return fixp->fx_frag->fr_address + fixp->fx_where;
}
/* Replaces standard TC_FORCE_RELOCATION_LOCAL.
/* Addition to the standard TC_FORCE_RELOCATION_LOCAL.
Now it handles the situation when relocations
have to be passed to linker. */
int
@ -3964,8 +3964,7 @@ msp430_force_relocation_local (fixS *fixp)
&& !msp430_enable_relax)
return 1;
return (!fixp->fx_pcrel
|| generic_force_reloc (fixp));
return 0;
}

View File

@ -116,8 +116,9 @@ extern long md_pcrel_from_section (struct fix *, segT);
msp430_relax_frag (SEG, FRAGP, STRETCH)
extern long msp430_relax_frag (segT, fragS *, long);
#define TC_FORCE_RELOCATION_LOCAL(FIX) \
msp430_force_relocation_local (FIX)
#define TC_FORCE_RELOCATION_LOCAL(FIX) \
(GENERIC_FORCE_RELOCATION_LOCAL (FIX) \
|| msp430_force_relocation_local (FIX))
extern int msp430_force_relocation_local (struct fix *);
/* We need to add reference symbols for .data/.bss. */
@ -159,9 +160,9 @@ extern bfd_boolean msp430_allow_local_subtract (expressionS *, expressionS *, se
linker, but this fix is simpler, and it pretty much only affects
object size a little bit. */
#define TC_FORCE_RELOCATION_SUB_SAME(FIX, SEC) \
( ((SEC)->flags & SEC_CODE) != 0 \
(GENERIC_FORCE_RELOCATION_SUB_SAME (FIX, SEC) \
|| ((SEC)->flags & SEC_CODE) != 0 \
|| ((SEC)->flags & SEC_DEBUGGING) != 0 \
|| ! SEG_NORMAL (SEC) \
|| TC_FORCE_RELOCATION (FIX))
/* We validate subtract arguments within tc_gen_reloc(),

View File

@ -91,7 +91,8 @@ extern void tc_nds32_frame_initial_instructions (void);
/* For DIFF relocations. The default behavior is inconsistent with the
asm internal document. */
#define TC_FORCE_RELOCATION_SUB_SAME(FIX, SEC) \
(! SEG_NORMAL (SEC) || TC_FORCE_RELOCATION (FIX))
(GENERIC_FORCE_RELOCATION_SUB_SAME (FIX, SEC) \
|| TC_FORCE_RELOCATION (FIX))
#define TC_FORCE_RELOCATION(fix) nds32_force_relocation (fix)
#define TC_VALIDATE_FIX_SUB(FIX,SEG) nds32_validate_fix_sub (FIX,SEG)
#define SET_SECTION_RELOCS(sec, relocs, n) nds32_set_section_relocs (sec, relocs, n)

View File

@ -97,7 +97,7 @@ extern void pru_cons_fix_new (struct frag *frag, int where,
linkrelax is turned on. */
#define TC_FORCE_RELOCATION(fix) pru_force_relocation (fix)
#define TC_FORCE_RELOCATION_SUB_SAME(fix, seg) \
(! SEG_NORMAL (seg) || pru_force_relocation (fix))
(GENERIC_FORCE_RELOCATION_SUB_SAME (fix, seg) || pru_force_relocation (fix))
extern int pru_force_relocation (struct fix *);
/* Do not use PC relative fixups and relocations for

View File

@ -87,7 +87,9 @@ extern void riscv_pre_output_hook (void);
/* Postpone text-section label subtraction calculation until linking, since
linker relaxations might change the deltas. */
#define TC_FORCE_RELOCATION_SUB_SAME(FIX, SEG) ((SEG)->flags & SEC_CODE)
#define TC_FORCE_RELOCATION_SUB_SAME(FIX, SEG) \
(GENERIC_FORCE_RELOCATION_SUB_SAME (FIX, SEG) \
|| ((SEG)->flags & SEC_CODE) != 0)
#define TC_FORCE_RELOCATION_SUB_LOCAL(FIX, SEG) 1
#define TC_VALIDATE_FIX_SUB(FIX, SEG) 1
#define TC_FORCE_RELOCATION_LOCAL(FIX) 1

View File

@ -93,9 +93,9 @@ extern void rl78_elf_final_processing (void);
linker, but this fix is simpler, and it pretty much only affects
object size a little bit. */
#define TC_FORCE_RELOCATION_SUB_SAME(FIX, SEC) \
( ((SEC)->flags & SEC_CODE) != 0 \
(GENERIC_FORCE_RELOCATION_SUB_SAME (FIX, SEC) \
|| ((SEC)->flags & SEC_CODE) != 0 \
|| ((SEC)->flags & SEC_DEBUGGING) != 0 \
|| ! SEG_NORMAL (SEC) \
|| TC_FORCE_RELOCATION (FIX))
#define DWARF2_USE_FIXED_ADVANCE_PC 1

View File

@ -28,7 +28,8 @@ extern int tc_s390_force_relocation (struct fix *);
/* Don't resolve foo@PLT-bar to offset@PLT. */
#define TC_FORCE_RELOCATION_SUB_SAME(FIX, SEG) \
(! SEG_NORMAL (SEG) || TC_FORCE_RELOCATION (FIX))
(GENERIC_FORCE_RELOCATION_SUB_SAME (FIX, SEG) \
|| TC_FORCE_RELOCATION (FIX))
#define tc_fix_adjustable(X) tc_s390_fix_adjustable(X)
extern int tc_s390_fix_adjustable (struct fix *);

View File

@ -77,7 +77,7 @@ extern int sh_force_relocation (struct fix *);
|| (FIX)->fx_r_type == BFD_RELOC_8))
#define TC_FORCE_RELOCATION_SUB_SAME(FIX, SEC) \
(! SEG_NORMAL (SEC) \
(GENERIC_FORCE_RELOCATION_SUB_SAME (FIX, SEC) \
|| TC_FORCE_RELOCATION (FIX) \
|| (sh_relax && SWITCH_TABLE (FIX)))
@ -204,11 +204,10 @@ extern bfd_boolean sh_fix_adjustable (struct fix *);
can only be determined at link time. */
#define TC_FORCE_RELOCATION_LOCAL(FIX) \
(!(FIX)->fx_pcrel \
(GENERIC_FORCE_RELOCATION_LOCAL (FIX) \
|| (FIX)->fx_r_type == BFD_RELOC_32_PLT_PCREL \
|| (FIX)->fx_r_type == BFD_RELOC_32_GOT_PCREL \
|| (FIX)->fx_r_type == BFD_RELOC_SH_GOTPC \
|| TC_FORCE_RELOCATION (FIX))
|| (FIX)->fx_r_type == BFD_RELOC_SH_GOTPC)
#define TC_FORCE_RELOCATION_SUB_LOCAL(FIX, SEG) \
((!md_register_arithmetic && (SEG) == reg_section) \

View File

@ -78,7 +78,7 @@ extern int sh64_target_mach (void);
#undef TC_FORCE_RELOCATION_LOCAL
#define TC_FORCE_RELOCATION_LOCAL(FIX) \
(!(FIX)->fx_pcrel \
(GENERIC_FORCE_RELOCATION_LOCAL (FIX) \
|| (FIX)->fx_r_type == BFD_RELOC_32_PLT_PCREL \
|| (FIX)->fx_r_type == BFD_RELOC_SH_PLT_LOW16 \
|| (FIX)->fx_r_type == BFD_RELOC_SH_PLT_MEDLOW16 \
@ -102,12 +102,11 @@ extern int sh64_target_mach (void);
|| (FIX)->fx_r_type == BFD_RELOC_SH_GOTPC_LOW16 \
|| (FIX)->fx_r_type == BFD_RELOC_SH_GOTPC_MEDLOW16 \
|| (FIX)->fx_r_type == BFD_RELOC_SH_GOTPC_MEDHI16 \
|| (FIX)->fx_r_type == BFD_RELOC_SH_GOTPC_HI16 \
|| TC_FORCE_RELOCATION (FIX))
|| (FIX)->fx_r_type == BFD_RELOC_SH_GOTPC_HI16)
#undef TC_FORCE_RELOCATION_SUB_SAME
#define TC_FORCE_RELOCATION_SUB_SAME(FIX, SEC) \
(! SEG_NORMAL (SEC) \
(GENERIC_FORCE_RELOCATION_SUB_SAME (FIX, SEC) \
|| TC_FORCE_RELOCATION (FIX) \
|| (sh_relax && SWITCH_TABLE (FIX)) \
|| *symbol_get_tc ((FIX)->fx_addsy) != NULL)

View File

@ -94,10 +94,9 @@ extern void sparc_handle_align (struct frag *);
the .o file. */
#define TC_FORCE_RELOCATION_LOCAL(FIX) \
(!(FIX)->fx_pcrel \
(GENERIC_FORCE_RELOCATION_LOCAL (FIX) \
|| (sparc_pic_code \
&& S_IS_EXTERNAL ((FIX)->fx_addsy)) \
|| TC_FORCE_RELOCATION (FIX))
&& S_IS_EXTERNAL ((FIX)->fx_addsy)))
#endif
#ifdef OBJ_ELF

View File

@ -345,7 +345,8 @@ extern char *xtensa_section_rename (const char *);
#define TC_FRAG_INIT(frag) xtensa_frag_init (frag)
#define TC_FORCE_RELOCATION(fix) xtensa_force_relocation (fix)
#define TC_FORCE_RELOCATION_SUB_SAME(fix, seg) \
(! SEG_NORMAL (seg) || xtensa_force_relocation (fix))
(GENERIC_FORCE_RELOCATION_SUB_SAME (fix, seg) \
|| xtensa_force_relocation (fix))
#define TC_VALIDATE_FIX_SUB(fix, seg) xtensa_validate_fix_sub (fix)
#define NO_PSEUDO_DOT xtensa_check_inside_bundle ()
#define tc_canonicalize_symbol_name(s) xtensa_section_rename (s)

View File

@ -37,15 +37,17 @@
(TC_FORCE_RELOCATION (FIX))
#endif
#ifndef TC_FORCE_RELOCATION_LOCAL
#define TC_FORCE_RELOCATION_LOCAL(FIX) \
#define GENERIC_FORCE_RELOCATION_LOCAL(FIX) \
(!(FIX)->fx_pcrel \
|| TC_FORCE_RELOCATION (FIX))
#ifndef TC_FORCE_RELOCATION_LOCAL
#define TC_FORCE_RELOCATION_LOCAL GENERIC_FORCE_RELOCATION_LOCAL
#endif
#define GENERIC_FORCE_RELOCATION_SUB_SAME(FIX, SEG) \
(!SEG_NORMAL (SEG))
#ifndef TC_FORCE_RELOCATION_SUB_SAME
#define TC_FORCE_RELOCATION_SUB_SAME(FIX, SEG) \
(! SEG_NORMAL (SEG))
#define TC_FORCE_RELOCATION_SUB_SAME GENERIC_FORCE_RELOCATION_SUB_SAME
#endif
#ifndef md_register_arithmetic