x86: Force relocation against local absolute symbol
authorH.J. Lu <hjl.tools@gmail.com>
Wed, 1 Apr 2020 12:40:45 +0000 (05:40 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Wed, 1 Apr 2020 12:41:06 +0000 (05:41 -0700)
Define TC_FORCE_RELOCATION_ABS to force relocation against local
absolute symbol.

PR gas/25756
* config/tc-i386.h (TC_FORCE_RELOCATION_ABS): New.
* testsuite/gas/i386/localpic.s: Add a test for relocation
against local absolute symbol.
* testsuite/gas/i386/x86-64-localpic.s: Likewise.
* testsuite/gas/i386/localpic.d: Updated.
* testsuite/gas/i386/x86-64-localpic.d: Likewise.
* testsuite/gas/i386/ilp32/x86-64-localpic.d: Likewise.

gas/ChangeLog
gas/config/tc-i386.h
gas/testsuite/gas/i386/ilp32/x86-64-localpic.d
gas/testsuite/gas/i386/localpic.d
gas/testsuite/gas/i386/localpic.s
gas/testsuite/gas/i386/x86-64-localpic.d
gas/testsuite/gas/i386/x86-64-localpic.s

index 2d68a2741d3628a9fb192095ce367f1333697fc7..ef0217e5d70aa1a83da637d91428ff686311b6f2 100644 (file)
@@ -1,3 +1,14 @@
+2020-04-01  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR gas/25756
+       * config/tc-i386.h (TC_FORCE_RELOCATION_ABS): New.
+       * testsuite/gas/i386/localpic.s: Add a test for relocation
+       against local absolute symbol.
+       * testsuite/gas/i386/x86-64-localpic.s: Likewise.
+       * testsuite/gas/i386/localpic.d: Updated.
+       * testsuite/gas/i386/x86-64-localpic.d: Likewise.
+       * testsuite/gas/i386/ilp32/x86-64-localpic.d: Likewise.
+
 2020-04-01  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
 
        PR gas/25732
index 93678c22822b5baf6a3c55e1a7948d3545b56d91..cb426b5b911de13dafd8fb8445353c03f0591176 100644 (file)
@@ -180,6 +180,14 @@ extern int tc_i386_fix_adjustable (struct fix *);
    || (FIX)->fx_r_type == BFD_RELOC_X86_64_GOTPCRELX           \
    || (FIX)->fx_r_type == BFD_RELOC_X86_64_REX_GOTPCRELX)
 
+#define TC_FORCE_RELOCATION_ABS(FIX)                           \
+  (TC_FORCE_RELOCATION (FIX)                                   \
+   || (FIX)->fx_r_type == BFD_RELOC_386_GOT32                  \
+   || (FIX)->fx_r_type == BFD_RELOC_386_GOT32X                 \
+   || (FIX)->fx_r_type == BFD_RELOC_X86_64_GOTPCREL            \
+   || (FIX)->fx_r_type == BFD_RELOC_X86_64_GOTPCRELX           \
+   || (FIX)->fx_r_type == BFD_RELOC_X86_64_REX_GOTPCRELX)
+
 extern int i386_parse_name (char *, expressionS *, char *);
 #define md_parse_name(s, e, m, c) i386_parse_name (s, e, c)
 
index e9b77f2b171c4b2a302751ac81d793a3be328cdf..d0cc4e8efc9ca79844887141e100262a59eecdc6 100644 (file)
@@ -3,9 +3,11 @@
 #readelf: -rsW
 #name: x86-64 (ILP32) local PIC
 
-Relocation section '.rela.text' at offset 0x[0-9a-f]+ contains 1 entry:
+Relocation section '.rela.text' at offset 0x[0-9a-f]+ contains 2 entries:
  +Offset +Info +Type +Sym. Value +Symbol's Name \+ Addend
 [0-9a-f]+ +[0-9a-f]+ R_X86_64_REX_GOTPCRELX +[0-9a-f]+ +foo - 4
+[0-9a-f]+ +[0-9a-f]+ R_X86_64_REX_GOTPCRELX +[0-9a-f]+ +bar - 4
 #...
  +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +NOTYPE +LOCAL +DEFAULT +[0-9]+ +foo
+ +[0-9]+: +fffffff0 +[0-9a-f]+ +NOTYPE +LOCAL +DEFAULT +ABS +bar
 #pass
index 88d3566412f2199c4f74a7a262a58e60635a0f47..b06137f437fe1947d2ac72958293fd828ed2f739 100644 (file)
@@ -2,9 +2,11 @@
 #readelf: -rs
 #name: i386 local PIC
 
-Relocation section '.rel.text' at offset 0x[0-9a-f]+ contains 1 entry:
+Relocation section '.rel.text' at offset 0x[0-9a-f]+ contains 2 entries:
  Offset     Info    Type            Sym.Value  Sym. Name
 [0-9a-f]+ +[0-9a-f]+ R_386_GOT32X +[0-9a-f]+ +foo
+[0-9a-f]+ +[0-9a-f]+ R_386_GOT32X +[0-9a-f]+ +bar
 #...
  +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +NOTYPE +LOCAL +DEFAULT +[0-9]+ +foo
+ +[0-9]+: +fffffff0 +[0-9a-f]+ +NOTYPE +LOCAL +DEFAULT +ABS +bar
 #pass
index e63394445eef9eadcab3760ef035d8feacc432ed..f57fb18638a48b966d46aa194da3b803571d5ffc 100644 (file)
@@ -3,3 +3,5 @@ foo:
        .long 0
        .text
 movl   foo@GOT(%ecx), %eax
+movl   bar@GOT(%ecx), %eax
+       bar = 0xfffffff0
index 9f8b43edb04f597253583aa876cd9aeeaa228efd..62030d410ad90268a4edc1b136407fc31212ef21 100644 (file)
@@ -2,9 +2,11 @@
 #readelf: -rsW
 #name: x86-64 local PIC
 
-Relocation section '.rela.text' at offset 0x[0-9a-f]+ contains 1 entry:
+Relocation section '.rela.text' at offset 0x[0-9a-f]+ contains 2 entries:
  +Offset +Info +Type +Symbol's Value +Symbol's Name \+ Addend
 [0-9a-f]+ +[0-9a-f]+ R_X86_64_REX_GOTPCRELX +[0-9a-f]+ +foo - 4
+[0-9a-f]+ +[0-9a-f]+ R_X86_64_REX_GOTPCRELX +[0-9a-f]+ +bar - 4
 #...
  +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +NOTYPE +LOCAL +DEFAULT +[0-9]+ +foo
+ +[0-9]+: +0+fffffff0 +[0-9a-f]+ +NOTYPE +LOCAL +DEFAULT +ABS +bar
 #pass
index c73a7c563bcc80750027c807d751a88dc6069680..beda94dc2f3e397ed1253ed4c426559d27c93703 100644 (file)
@@ -2,3 +2,5 @@
 foo:
        .quad 0
        movq    foo@GOTPCREL(%rip), %rax
+       movq    bar@GOTPCREL(%rip), %rax
+       bar = 0xfffffff0
This page took 0.029702 seconds and 4 git commands to generate.