]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Fix AVR assembler so that it creates relocs that will work with linker relaxation.
authorNick Clifton <nickc@redhat.com>
Thu, 16 Dec 2021 16:40:57 +0000 (16:40 +0000)
committerNick Clifton <nickc@redhat.com>
Thu, 16 Dec 2021 16:40:57 +0000 (16:40 +0000)
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.

gas/ChangeLog
gas/config/tc-avr.c
gas/config/tc-avr.h
gas/testsuite/gas/all/gas.exp
gas/testsuite/gas/avr/diffreloc_withrelax.d
gas/testsuite/gas/avr/pc-relative-reloc.d
gas/testsuite/gas/elf/elf.exp
ld/ChangeLog
ld/testsuite/ld-avr/avr-prop-7.d
ld/testsuite/ld-avr/avr-prop-8.d
ld/testsuite/ld-avr/pr13402.d

index c2886ee75573fa44f0ff950bf78e1a9ec0c19b2f..77888663077f7ded905531adc6cdc5455c504b65 100644 (file)
@@ -1,3 +1,13 @@
+2021-12-16  Nick Clifton  <nickc@redhat.com>
+
+       PR 28686
+       * 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.
+
 2021-11-26  Tom de Vries  <tdevries@suse.de>
 
        PR 28629
index e731ea9b7d9d482e43aeb54d0bcad8c7d29fc51e..f5fe659130f8212ee33e14f487efc7e3ddd718d4 100644 (file)
@@ -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;
+}
index 58626970fa897121ffdd17b40b0914a09db9dcac..cb9e5bb3dfc71184677558880f8db399df9c7c30 100644 (file)
@@ -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 *);
index 5eee4f8abfab75685e25ef3717cbd365e8193e9e..5a08027d4340fabab30f160be56e63fd61337459 100644 (file)
@@ -166,11 +166,11 @@ switch -glob $target_triplet {
        # symbols on relocs.
        setup_xfail "m68hc1*-*-*" "m6811-*-*" "m6812-*-*" "rl78-*-*"
        setup_xfail "riscv*-*-*" "rx-*-*" "vax*-*-*" "xgate*-*-*" "z8k-*-*"
-       setup_xfail "loongarch*-*-*"
+       setup_xfail "loongarch*-*-*" "avr-*-*"
        run_dump_test redef2
        setup_xfail "m68hc1*-*-*" "m6811-*-*" "m6812-*-*" "rl78-*-*"
        setup_xfail "riscv*-*-*" "rx-*-*" "vax*-*-*" "xgate*-*-*" "z8k-*-*"
-       setup_xfail "loongarch*-*-*"
+       setup_xfail "loongarch*-*-*" "avr-*-*"
        # rs6000-aix disallows redefinition via .comm.
        if [is_xcoff_format] {
            setup_xfail *-*-*
index 6d5bd2ee01eaa0989f2feac5a059530fba39ea01..9d59e054ec46d205ff681fbfbea291e41ab22ef5 100644 (file)
@@ -8,9 +8,9 @@
 
 RELOCATION RECORDS FOR \[.text\]:
 OFFSET   TYPE              VALUE 
-00000000 R_AVR_CALL        .text
+00000000 R_AVR_CALL        L1
 
 
 RELOCATION RECORDS FOR \[.data\]:
 OFFSET   TYPE              VALUE 
-00000000 R_AVR_DIFF16      .text\+0x00000004
+00000000 R_AVR_DIFF16      L2
index cc22b0bf3666eebdd85cee3b4e64deba6a585cfa..30d0df6202a1e327d13c59a0e0d61465e6002cf3 100644 (file)
@@ -12,7 +12,7 @@ RELOCATION RECORDS FOR \[.text.main\]:
 
 RELOCATION RECORDS FOR \[.debug_line\]:
 OFFSET   TYPE              VALUE 
-00000000 R_AVR_32_PCREL    .debug_line_end-0x00000004
+00000000 R_AVR_32_PCREL    .Ldebug_line_end-0x00000004
 
 
 RELOCATION RECORDS FOR \[.debug_line.text.main\]:
index 08105f88419c5d3ac76a192f652646ced85c1215..c172ba3d27a952e4d48511d541e502ff63c6ce10 100644 (file)
@@ -184,7 +184,7 @@ if { [is_elf_format] } then {
            # against ordinary symbols into relocations against section symbols.
            # This is usually revealed by the error message:
            #  symbol `sym' required but not present
-           setup_xfail "m681*-*-*" "m68hc*-*-*" "xgate-*-*" "vax-*-*"
+           setup_xfail "m681*-*-*" "m68hc*-*-*" "xgate-*-*" "vax-*-*" "avr-*-*"
            run_dump_test redef
            run_dump_test equ-reloc
        }
index 7795217dedc2a8acfc94e24861cc7b1e8cb43332..a0ab861bb4adb24248bfcdeb2baded6aa5f93931 100644 (file)
@@ -1,3 +1,10 @@
+2021-12-16  Nick Clifton  <nickc@redhat.com>
+
+       PR 28686
+       * testsuite/ld-avr/avr-prop-7.d: Adjust expected output.
+       * testsuite/ld-avr/avr-prop-8.d: Likewise.
+       * testsuite/ld-avr/pr13402.d: Likewise.
+
 2021-11-30  Nick Clifton  <nickc@redhat.com>
 
        * scripttempl/pru.sc (.pru_irq_map): Define output section.
index 9f2cea902e052c1125dfc4f1d6be906bd335f81e..ebcb9dc2455c5f81a88c8f44fcc7dd60463fe8d7 100644 (file)
@@ -9,7 +9,7 @@
 00000000 <__ctors_end>:
    0:  04 d0           rcall   .+8             ; 0xa <foo>
    2:  00 00           nop
-   4:  00 00           nop
+#...
    6:  86 e0           ldi     r24, 0x06       ; 6
-   8:  f0 f7           brcc    .-4             ; 0x6 <__ctors_end\+0x6>
+   8:  f0 f7           brcc    .-4             ; 0x6 <.*>
 #...
index 2905f9880e9fd5fd99353917981558ca4a3e7ba5..b0122be36083d031d17ec201b54570ee29170d5f 100644 (file)
@@ -9,5 +9,6 @@
 00000000 <__ctors_end>:
    0:  ff cf           rjmp    .-2             ; 0x0 <__ctors_end>
    2:  fe df           rcall   .-4             ; 0x0 <__ctors_end>
-   4:  f8 f7           brcc    .-2             ; 0x4 <__ctors_end\+0x4>
+#...
+   4:  f8 f7           brcc    .-2             ; 0x4 <.*>
 #...
index 6663950559e8eb65871fc738eaa5a30d68b1b300..a8fd63430ff68e212e075750c5d181ee05acace4 100644 (file)
@@ -8,9 +8,11 @@
 #...
 main:
 call a
-   0:  02 d0           rcall   .+4             ; 0x6 <_etext>
 call b
-   2:  01 d0           rcall   .+2             ; 0x6 <_etext>
+   0:  02 d0           rcall   .+4             ; 0x6 <_etext>
+#...
 call c
+   2:  01 d0           rcall   .+2             ; 0x6 <_etext>
+#...
    4:  00 d0           rcall   .+0             ; 0x6 <_etext>
 #...