aboutsummaryrefslogtreecommitdiff
path: root/gas/config
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2021-12-16 16:40:57 +0000
committerNick Clifton <nickc@redhat.com>2021-12-16 16:40:57 +0000
commitf3be70df1b1681ad1b9b0490587011bde433d220 (patch)
tree1d1938d029b210dc78c70ce4fba57a254add490b /gas/config
parent61ab1364c7efa3934e0ca62af444e6e6e34f219e (diff)
downloadgdb-f3be70df1b1681ad1b9b0490587011bde433d220.zip
gdb-f3be70df1b1681ad1b9b0490587011bde433d220.tar.gz
gdb-f3be70df1b1681ad1b9b0490587011bde433d220.tar.bz2
Fix AVR assembler so that it creates relocs that will work with linker relaxation.
PR 28686 gas * config/tc-avr.h (tc_fix_adjustable): Define. * config/tc-avr.c (avr_fix_adjustable): New function. * testsuite/gas/all/gas.exp: Skip tests that need adjustable fixups. * testsuite/gas/elf/elf.exp: Likewise. * testsuite/gas/avr/diffreloc_withrelax.d: Adjust expected output. * testsuite/gas/avr/pc-relative-reloc.d: Adjust expected output. ld * testsuite/ld-avr/avr-prop-7.d: Adjust expected output. * testsuite/ld-avr/avr-prop-8.d: Likewise. * testsuite/ld-avr/pr13402.d: Likewise.
Diffstat (limited to 'gas/config')
-rw-r--r--gas/config/tc-avr.c26
-rw-r--r--gas/config/tc-avr.h3
2 files changed, 29 insertions, 0 deletions
diff --git a/gas/config/tc-avr.c b/gas/config/tc-avr.c
index e731ea9..f5fe659 100644
--- a/gas/config/tc-avr.c
+++ b/gas/config/tc-avr.c
@@ -2820,3 +2820,29 @@ avr_pre_output_hook (void)
if (avr_opt.have_gccisr)
bfd_map_over_sections (stdoutput, avr_check_gccisr_done, NULL);
}
+
+/* Return false if the fixup in fixp should be left alone and not
+ adjusted. */
+
+bool
+avr_fix_adjustable (struct fix *fixp)
+{
+ if (! linkrelax || fixp->fx_addsy == NULL)
+ return true;
+
+ /* Do not adjust relocations involving symbols in code sections,
+ because it breaks linker relaxations. This could be fixed in the
+ linker, but this fix is simpler, and it pretty much only affects
+ object size a little bit. */
+ if (S_GET_SEGMENT (fixp->fx_addsy)->flags & SEC_CODE)
+ return false;
+
+ /* Likewise, do not adjust symbols that won't be merged, or debug
+ symbols, because they too break relaxation. We do want to adjust
+ other mergeable symbols, like .rodata, because code relaxations
+ need section-relative symbols to properly relax them. */
+ if (! (S_GET_SEGMENT (fixp->fx_addsy)->flags & SEC_MERGE))
+ return false;
+
+ return true;
+}
diff --git a/gas/config/tc-avr.h b/gas/config/tc-avr.h
index 5862697..cb9e5bb 100644
--- a/gas/config/tc-avr.h
+++ b/gas/config/tc-avr.h
@@ -247,3 +247,6 @@ extern void avr_frag_init (fragS *);
#define tc_line_separator_chars avr_line_separator_chars
extern const char *avr_line_separator_chars;
+
+#define tc_fix_adjustable(FIX) avr_fix_adjustable (FIX)
+extern bool avr_fix_adjustable (struct fix *);