xtensa: fix signedness of gas relocations
authorMax Filippov <jcmvbkbc@gmail.com>
Tue, 2 Feb 2016 14:11:38 +0000 (17:11 +0300)
committerMax Filippov <jcmvbkbc@gmail.com>
Wed, 3 Feb 2016 17:44:57 +0000 (20:44 +0300)
Change 1058c7532d0b "Use signed data type for R_XTENSA_DIFF* relocation
offsets." changed signedness of BFD_RELOC_XTENSA_DIFF* relocations
substituted for BFD_RELOC_*. This made it impossible to encode arbitrary
8-, 16- and 32-bit values, which broke e.g. debug info encoding by .loc
directive. Revert this part and add test.

gas/
2016-02-03  Max Filippov  <jcmvbkbc@gmail.com>
* config/tc-xtensa.c (md_apply_fix): Mark BFD_RELOC_XTENSA_DIFF*
substitutions for BFD_RELOC_* as unsigned.
* gas/testsuite/gas/xtensa/all.exp: Add loc to list of xtensa
tests.
* gas/testsuite/gas/xtensa/loc.d: New file: loc test result
patterns.
* gas/testsuite/gas/xtensa/loc.s: New file: loc test.

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

index da426fc93d2a752ffbde2218a717b3a3331c12d0..e147013b2a2ef4bef08eeb07672be97dfd63deeb 100644 (file)
@@ -1,3 +1,13 @@
+2016-02-03  Max Filippov  <jcmvbkbc@gmail.com>
+
+       * config/tc-xtensa.c (md_apply_fix): Mark BFD_RELOC_XTENSA_DIFF*
+       substitutions for BFD_RELOC_* as unsigned.
+       * gas/testsuite/gas/xtensa/all.exp: Add loc to list of xtensa
+       tests.
+       * gas/testsuite/gas/xtensa/loc.d: New file: loc test result
+       patterns.
+       * gas/testsuite/gas/xtensa/loc.s: New file: loc test.
+
 2016-02-03  Kevin Buettner  <kevinb@redhat.com>
 
        * config/tc-msp430.h (DWARF2_ADDR_SIZE): Set to 4.
index a1198715e08a616d7527da8436e1d9b76b901261..36a06cc78e0ea2645c7d538df236186a50cef056 100644 (file)
@@ -5961,15 +5961,15 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg)
            {
            case BFD_RELOC_8:
              fixP->fx_r_type = BFD_RELOC_XTENSA_DIFF8;
-             fixP->fx_signed = 1;
+             fixP->fx_signed = 0;
              break;
            case BFD_RELOC_16:
              fixP->fx_r_type = BFD_RELOC_XTENSA_DIFF16;
-             fixP->fx_signed = 1;
+             fixP->fx_signed = 0;
              break;
            case BFD_RELOC_32:
              fixP->fx_r_type = BFD_RELOC_XTENSA_DIFF32;
-             fixP->fx_signed = 1;
+             fixP->fx_signed = 0;
              break;
            default:
              break;
index 31b725bfe47acc51f4943e17e8e8dd445a4c9663..7ff7bd779d38f0ea7e234b5102401a309ede48ad 100644 (file)
@@ -101,6 +101,7 @@ if [istarget xtensa*-*-*] then {
     run_dump_test "trampoline"
     run_dump_test "first_frag_align"
     run_dump_test "auto-litpools"
+    run_dump_test "loc"
 }
 
 if [info exists errorInfo] then {
diff --git a/gas/testsuite/gas/xtensa/loc.d b/gas/testsuite/gas/xtensa/loc.d
new file mode 100644 (file)
index 0000000..71983cc
--- /dev/null
@@ -0,0 +1,10 @@
+#as:
+#objdump: -r
+#name: .loc directive relocs
+
+.*: +file format .*xtensa.*
+
+RELOCATION RECORDS FOR \[\.debug_line\]:
+#...
+.*R_XTENSA_DIFF16.*\.text\+0x00009c42
+#...
diff --git a/gas/testsuite/gas/xtensa/loc.s b/gas/testsuite/gas/xtensa/loc.s
new file mode 100644 (file)
index 0000000..029e14e
--- /dev/null
@@ -0,0 +1,7 @@
+       .text
+       .file 1 "loc.s"
+       .loc 1 3
+       nop
+       .space 40000
+       .loc 1 5
+       nop