]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Fix alignment for the first section frag on xtensa
authorMax Filippov <jcmvbkbc@gmail.com>
Tue, 15 Apr 2014 15:12:46 +0000 (19:12 +0400)
committerMax Filippov <jcmvbkbc@gmail.com>
Tue, 22 Apr 2014 18:53:49 +0000 (22:53 +0400)
Linking object files produced by partial linking with link-time
relaxation enabled sometimes fails with the following error message:

dangerous relocation: call8: misaligned call target: (.text.unlikely+0x63)

This happens because no basic block with an XTENSA_PROP_ALIGN flag in the
property table is generated for the first basic block, even if the
.align directive is present.
It was believed that the first frag alignment could be derived from the
section alignment, but this was not implemented for the partial linking
case: after partial linking first frag of a section may become not
first, but no additional alignment frag is inserted before it.
Basic block for such frag may be merged with previous basic block into
extended basic block during relaxation pass losing its alignment
restrictions.

Fix this by always recording alignment for the first section frag.

2014-04-22  Max Filippov  <jcmvbkbc@gmail.com>

gas/
    * config/tc-xtensa.c (xtensa_handle_align): record alignment for the
    first section frag.

gas/testsuite/
    * gas/xtensa/all.exp: Add test for the first section frag alignment.
    * gas/xtensa/first_frag_align.d: First section frag alignment expected
    dump.
    * gas/xtensa/first_frag_align.s: First section frag alignment test
    source.

gas/ChangeLog
gas/config/tc-xtensa.c
gas/testsuite/ChangeLog
gas/testsuite/gas/xtensa/all.exp
gas/testsuite/gas/xtensa/first_frag_align.d [new file with mode: 0644]
gas/testsuite/gas/xtensa/first_frag_align.s [new file with mode: 0644]

index 1416f86d8edeb3a146fb4d251dcfe50a62bf0958..12b6694c4e6cf9967a932a62311492f47cda2a05 100644 (file)
@@ -1,3 +1,8 @@
+2014-04-22  Max Filippov  <jcmvbkbc@gmail.com>
+
+       * config/tc-xtensa.c (xtensa_handle_align): record alignment for the
+       first section frag.
+
 2014-04-22  Christian Svensson  <blue@cmd.nu>
 
        * Makefile.am: Remove openrisc and or32 support.  Add support for or1k.
index ea23c9653230167ee966e8d216baf2928408e8df..58ace3809e87ab59f403aee933eb8996613d34eb 100644 (file)
@@ -5609,7 +5609,6 @@ xtensa_handle_align (fragS *fragP)
       && ! fragP->tc_frag_data.is_literal
       && (fragP->fr_type == rs_align
          || fragP->fr_type == rs_align_code)
-      && fragP->fr_address + fragP->fr_fix > 0
       && fragP->fr_offset > 0
       && now_seg != bss_section)
     {
index cb0bf195459a447d5b818053b8435795ad303580..ace547bc8421390292ce2b016c7dc96fc78d679c 100644 (file)
@@ -1,3 +1,11 @@
+2014-04-22  Max Filippov  <jcmvbkbc@gmail.com>
+
+       * gas/xtensa/all.exp: Add test for the first section frag alignment.
+       * gas/xtensa/first_frag_align.d: First section frag alignment expected
+       dump.
+       * gas/xtensa/first_frag_align.s: First section frag alignment test
+       source.
+
 2014-04-22  Christian Svensson  <blue@cmd.nu>
 
        * Makefile.am: Remove openrisc and or32 support.  Add support for or1k.
index 3683b78f4adc2ad60ea48e22c775130365b6b190..b1e6c8264331729d2195e1dffd40ba6a200335dc 100644 (file)
@@ -99,6 +99,7 @@ if [istarget xtensa*-*-*] then {
     run_dump_test "weak-call"
     run_dump_test "jlong"
     run_dump_test "trampoline"
+    run_dump_test "first_frag_align"
 }
 
 if [info exists errorInfo] then {
diff --git a/gas/testsuite/gas/xtensa/first_frag_align.d b/gas/testsuite/gas/xtensa/first_frag_align.d
new file mode 100644 (file)
index 0000000..aafcb41
--- /dev/null
@@ -0,0 +1,9 @@
+#as:
+#objdump: -s
+#name: record alignment for the first section frag
+
+.*: +file format .*xtensa.*
+#...
+Contents of section .xt.prop:
+ 0000 00000000 00000000 00002804 .*
+#...
diff --git a/gas/testsuite/gas/xtensa/first_frag_align.s b/gas/testsuite/gas/xtensa/first_frag_align.s
new file mode 100644 (file)
index 0000000..c120af0
--- /dev/null
@@ -0,0 +1,5 @@
+       .text
+       .align  4
+f1:
+       entry   a1, 32
+       retw