diff options
author | Alan Modra <amodra@gmail.com> | 2021-07-10 15:58:44 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2021-07-14 21:52:20 +0930 |
commit | 9cce9fab90e0951c6816d97801e124e392e74dd9 (patch) | |
tree | 30af6ff2fa37c54f9644201b08d17ede2f8fbc47 | |
parent | 51d29b8cacd75865a9ffc46cffffe1e47c33ccff (diff) | |
download | gdb-9cce9fab90e0951c6816d97801e124e392e74dd9.zip gdb-9cce9fab90e0951c6816d97801e124e392e74dd9.tar.gz gdb-9cce9fab90e0951c6816d97801e124e392e74dd9.tar.bz2 |
gas: default TC_VALIDATE_FIX_SUB to 0
gas/write.c provides a fallback TC_VALIDATE_FIX_SUB define that can be
a problem for some targets, the problem being that a non-zero
definition of TC_VALIDATE_FIX_SUB says that some uses of fx_subsy are
OK, in effect that the target will handle fx_subsy in md_apply_fix
and/or tc_gen_reloc. A lot of targets don't have the necessary
md_apply_fix and tc_gen_reloc support. So a safer default is to
disallow fx_subsy by default.
I've had a good look over target usage of fx_subsy, and think I've
caught all the cases where targets need TC_VALIDATE_FIX_SUB. Possible
failures would be limited to alpha, microblaze, ppc and s390 (the
targets that define UNDEFINED_DIFFERENCE_OK), or targets that generate
fixups with BFD_RELOC_GPREL32/16 and use a syntax explicitly showing
a difference expression.
* write.c (TC_VALIDATE_FIX_SUB): Default to 0.
* config/tc-hppa.h (TC_VALIDATE_FIX_SUB): Define.
* config/tc-microblaze.h (TC_VALIDATE_FIX_SUB): Define.
* config/tc-alpha.h (TC_VALIDATE_FIX_SUB): Define for ECOFF.
* config/tc-ppc.h (TC_VALIDATE_FIX_SUB): Don't define for ELF.
Do define for XCOFF.
-rw-r--r-- | gas/ChangeLog | 11 | ||||
-rw-r--r-- | gas/config/tc-alpha.h | 5 | ||||
-rw-r--r-- | gas/config/tc-hppa.h | 4 | ||||
-rw-r--r-- | gas/config/tc-microblaze.h | 3 | ||||
-rw-r--r-- | gas/config/tc-ppc.h | 6 | ||||
-rw-r--r-- | gas/write.c | 11 |
6 files changed, 27 insertions, 13 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog index 7aaf08f..fbb112f 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,12 @@ +2021-07-14 Alan Modra <amodra@gmail.com> + + * write.c (TC_VALIDATE_FIX_SUB): Default to 0. + * config/tc-hppa.h (TC_VALIDATE_FIX_SUB): Define. + * config/tc-microblaze.h (TC_VALIDATE_FIX_SUB): Define. + * config/tc-alpha.h (TC_VALIDATE_FIX_SUB): Define for ECOFF. + * config/tc-ppc.h (TC_VALIDATE_FIX_SUB): Don't define for ELF. + Do define for XCOFF. + 2021-07-14 Clément Chigot <clement.chigot@atos.net> * config/tc-ppc.c (ppc_change_debug_section): Update to @@ -470,7 +479,7 @@ * testsuite/gas/mips/mips2@cp3m.d: New test. * testsuite/gas/mips/r3000@cp3m.d: New test. * testsuite/gas/mips/r3900@cp3m.d: New test. - * testsuite/gas/mips/mips2@cp3d.d: New test. + * testsuite/gas/mips/mips2@cp3d.d: New test. * testsuite/gas/mips/cp0b.l: New test stderr output. * testsuite/gas/mips/cp0bl.l: New test stderr output. * testsuite/gas/mips/cp0c.l: New test stderr output. diff --git a/gas/config/tc-alpha.h b/gas/config/tc-alpha.h index b7d7e87..ed0ae63 100644 --- a/gas/config/tc-alpha.h +++ b/gas/config/tc-alpha.h @@ -116,6 +116,11 @@ extern void alpha_handle_align (struct frag *); #ifdef OBJ_ECOFF #define tc_frob_file_before_adjust() alpha_frob_file_before_adjust () extern void alpha_frob_file_before_adjust (void); + +#define TC_VALIDATE_FIX_SUB(FIX, SEG) \ + ((md_register_arithmetic || (SEG) != reg_section) \ + && ((FIX)->fx_r_type == BFD_RELOC_GPREL32 \ + || (FIX)->fx_r_type == BFD_RELOC_GPREL16)) #endif #define DIFF_EXPR_OK /* foo-. gets turned into PC relative relocs. */ diff --git a/gas/config/tc-hppa.h b/gas/config/tc-hppa.h index b418991..6842a7d 100644 --- a/gas/config/tc-hppa.h +++ b/gas/config/tc-hppa.h @@ -127,6 +127,10 @@ int hppa_fix_adjustable (struct fix *); /* Values passed to md_apply_fix don't include the symbol value. */ #define MD_APPLY_SYM_VALUE(FIX) 0 +/* The PA needs this for PIC code generation. */ +#define TC_VALIDATE_FIX_SUB(FIX, SEG) \ + (md_register_arithmetic || (SEG) != reg_section) + #ifdef OBJ_SOM /* If a symbol is imported, but never used, then the symbol should *not* end up in the symbol table. Likewise for absolute symbols diff --git a/gas/config/tc-microblaze.h b/gas/config/tc-microblaze.h index c6d33f8..b2868fe 100644 --- a/gas/config/tc-microblaze.h +++ b/gas/config/tc-microblaze.h @@ -51,6 +51,9 @@ extern bfd_reloc_code_real_type parse_cons_expression_microblaze || (FIX)->fx_r_type == BFD_RELOC_MICROBLAZE_64_GOTOFF \ || (FIX)->fx_r_type == BFD_RELOC_MICROBLAZE_32_GOTOFF) +#define TC_VALIDATE_FIX_SUB(FIX, SEG) \ + (md_register_arithmetic || (SEG) != reg_section) + #define tc_fix_adjustable(X) tc_microblaze_fix_adjustable(X) extern int tc_microblaze_fix_adjustable (struct fix *); diff --git a/gas/config/tc-ppc.h b/gas/config/tc-ppc.h index 790994e..4e175b0 100644 --- a/gas/config/tc-ppc.h +++ b/gas/config/tc-ppc.h @@ -285,8 +285,6 @@ extern int ppc_force_relocation (struct fix *); || (FIX)->fx_r_type == BFD_RELOC_PPC64_D34 \ || (FIX)->fx_r_type == BFD_RELOC_PPC64_D28)) -#define TC_VALIDATE_FIX_SUB(FIX, SEG) 0 - #endif /* OBJ_ELF */ #define RELOC_EXPANSION_POSSIBLE @@ -303,6 +301,10 @@ extern int ppc_force_relocation (struct fix *); /* XCOFF allows undefined differences which will be encoded with R_NEG relocations. */ #define UNDEFINED_DIFFERENCE_OK + +#define TC_VALIDATE_FIX_SUB(FIX, SEG) \ + (md_register_arithmetic || (SEG) != reg_section) + #endif /* OBJ_XCOFF */ /* Various frobbings of labels and their addresses. */ diff --git a/gas/write.c b/gas/write.c index 7dc78b7..2d67f16 100644 --- a/gas/write.c +++ b/gas/write.c @@ -69,16 +69,7 @@ #endif #ifndef TC_VALIDATE_FIX_SUB -#ifdef UNDEFINED_DIFFERENCE_OK -/* The PA needs this for PIC code generation. */ -#define TC_VALIDATE_FIX_SUB(FIX, SEG) \ - (md_register_arithmetic || (SEG) != reg_section) -#else -#define TC_VALIDATE_FIX_SUB(FIX, SEG) \ - ((md_register_arithmetic || (SEG) != reg_section) \ - && ((FIX)->fx_r_type == BFD_RELOC_GPREL32 \ - || (FIX)->fx_r_type == BFD_RELOC_GPREL16)) -#endif +#define TC_VALIDATE_FIX_SUB(FIX, SEG) 0 #endif #ifndef TC_LINKRELAX_FIXUP |