[binutils-gdb] x86: Resolve PLT32 reloc aganst local symbol to section

H.J.Lu hjl@sourceware.org
Thu Feb 13 22:08:00 GMT 2020


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=292676c15a615b5a95bede9ee91004d3f7ee7dfd

commit 292676c15a615b5a95bede9ee91004d3f7ee7dfd
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Thu Feb 13 13:44:17 2020 -0800

    x86: Resolve PLT32 reloc aganst local symbol to section
    
    Since PLT entry isn't needed for branch to local symbol, we can resolve
    R_386_PLT32/R_X86_64_PLT32 relocation aganst local symbol to section,
    similar to R_386_PC32/R_X86_64_PC32.
    
    2020-02-13  Fangrui Song   <maskray@google.com>
    	    H.J. Lu  <hongjiu.lu@intel.com>
    
    	PR gas/25551
    	* config/tc-i386.c (tc_i386_fix_adjustable): Don't check
    	BFD_RELOC_386_PLT32 nor BFD_RELOC_X86_64_PLT32.
    	* testsuite/gas/i386/i386.exp: Run relax-5 and x86-64-relax-4.
    	* testsuite/gas/i386/relax-5.d: New file.
    	* testsuite/gas/i386/relax-5.s: Likewise.
    	* testsuite/gas/i386/x86-64-relax-4.d: Likewise.
    	* testsuite/gas/i386/x86-64-relax-4.s: Likewise.

Diff:
---
 gas/ChangeLog                           | 12 ++++++++++++
 gas/config/tc-i386.c                    |  2 --
 gas/testsuite/gas/i386/i386.exp         |  2 ++
 gas/testsuite/gas/i386/relax-5.d        | 15 +++++++++++++++
 gas/testsuite/gas/i386/relax-5.s        |  8 ++++++++
 gas/testsuite/gas/i386/x86-64-relax-4.d | 17 +++++++++++++++++
 gas/testsuite/gas/i386/x86-64-relax-4.s |  8 ++++++++
 7 files changed, 62 insertions(+), 2 deletions(-)

diff --git a/gas/ChangeLog b/gas/ChangeLog
index 7f110e9..8d5426d 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,15 @@
+2020-02-13  Fangrui Song   <maskray@google.com>
+	    H.J. Lu  <hongjiu.lu@intel.com>
+
+	PR gas/25551
+	* config/tc-i386.c (tc_i386_fix_adjustable): Don't check
+	BFD_RELOC_386_PLT32 nor BFD_RELOC_X86_64_PLT32.
+	* testsuite/gas/i386/i386.exp: Run relax-5 and x86-64-relax-4.
+	* testsuite/gas/i386/relax-5.d: New file.
+	* testsuite/gas/i386/relax-5.s: Likewise.
+	* testsuite/gas/i386/x86-64-relax-4.d: Likewise.
+	* testsuite/gas/i386/x86-64-relax-4.s: Likewise.
+
 2020-02-13  Jan Beulich  <jbeulich@suse.com>
 
 	* config/tc-i386.c (cpu_noarch): Use CPU_ANY_SSE4_FLAGS in
diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c
index 6b923cc..8e422fd 100644
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -3398,7 +3398,6 @@ tc_i386_fix_adjustable (fixS *fixP ATTRIBUTE_UNUSED)
   if (fixP->fx_r_type == BFD_RELOC_SIZE32
       || fixP->fx_r_type == BFD_RELOC_SIZE64
       || fixP->fx_r_type == BFD_RELOC_386_GOTOFF
-      || fixP->fx_r_type == BFD_RELOC_386_PLT32
       || fixP->fx_r_type == BFD_RELOC_386_GOT32
       || fixP->fx_r_type == BFD_RELOC_386_GOT32X
       || fixP->fx_r_type == BFD_RELOC_386_TLS_GD
@@ -3411,7 +3410,6 @@ tc_i386_fix_adjustable (fixS *fixP ATTRIBUTE_UNUSED)
       || fixP->fx_r_type == BFD_RELOC_386_TLS_LE
       || fixP->fx_r_type == BFD_RELOC_386_TLS_GOTDESC
       || fixP->fx_r_type == BFD_RELOC_386_TLS_DESC_CALL
-      || fixP->fx_r_type == BFD_RELOC_X86_64_PLT32
       || fixP->fx_r_type == BFD_RELOC_X86_64_GOT32
       || fixP->fx_r_type == BFD_RELOC_X86_64_GOTPCREL
       || fixP->fx_r_type == BFD_RELOC_X86_64_GOTPCRELX
diff --git a/gas/testsuite/gas/i386/i386.exp b/gas/testsuite/gas/i386/i386.exp
index 2ca8a94..8cace3d 100644
--- a/gas/testsuite/gas/i386/i386.exp
+++ b/gas/testsuite/gas/i386/i386.exp
@@ -580,6 +580,7 @@ if [expr ([istarget "i*86-*-*"] ||  [istarget "x86_64-*-*"]) && [gas_32_check]]
 
 	run_dump_test "relax-3"
 	run_dump_test "relax-4"
+	run_dump_test "relax-5"
 
 	run_dump_test "got"
 	run_dump_test "got-no-relax"
@@ -1135,6 +1136,7 @@ if [expr ([istarget "i*86-*-*"] || [istarget "x86_64-*-*"]) && [gas_64_check]] t
 
 	run_dump_test "x86-64-relax-2"
 	run_dump_test "x86-64-relax-3"
+	run_dump_test "x86-64-relax-4"
 
 	run_dump_test "x86-64-jump"
 	run_dump_test "x86-64-branch-2"
diff --git a/gas/testsuite/gas/i386/relax-5.d b/gas/testsuite/gas/i386/relax-5.d
new file mode 100644
index 0000000..bccfe68
--- /dev/null
+++ b/gas/testsuite/gas/i386/relax-5.d
@@ -0,0 +1,15 @@
+#objdump: -dwr
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+0+ <printk>:
+ +[a-f0-9]+:	c3                   	ret    
+
+Disassembly of section .init.text:
+
+0+ <foo>:
+ +[a-f0-9]+:	e8 fb ff ff ff       	call   0 <foo>	1: R_386_PLT32	.text
+ +[a-f0-9]+:	e8 fc ff ff ff       	call   6 <foo\+0x6>	6: R_386_PC32	.text
+#pass
diff --git a/gas/testsuite/gas/i386/relax-5.s b/gas/testsuite/gas/i386/relax-5.s
new file mode 100644
index 0000000..35d5769
--- /dev/null
+++ b/gas/testsuite/gas/i386/relax-5.s
@@ -0,0 +1,8 @@
+	.section .init.text,"ax",@progbits
+	.global foo
+foo:
+	call	printk@PLT
+	call	printk
+	.text
+printk:
+	ret
diff --git a/gas/testsuite/gas/i386/x86-64-relax-4.d b/gas/testsuite/gas/i386/x86-64-relax-4.d
new file mode 100644
index 0000000..234e165
--- /dev/null
+++ b/gas/testsuite/gas/i386/x86-64-relax-4.d
@@ -0,0 +1,17 @@
+#objdump: -drw
+#notarget: *-*-solaris*
+
+.*: +file format .*
+
+
+Disassembly of section .text:
+
+0+ <printk>:
+ +[a-f0-9]+:	c3                   	retq   
+
+Disassembly of section .init.text:
+
+0+ <foo>:
+ +[a-f0-9]+:	e8 00 00 00 00       	callq  5 <foo\+0x5>	1: R_X86_64_PLT32	.text-0x4
+ +[a-f0-9]+:	48 8d 05 00 00 00 00 	lea    0x0\(%rip\),%rax        # c <foo\+0xc>	8: R_X86_64_PC32	.text-0x4
+#pass
diff --git a/gas/testsuite/gas/i386/x86-64-relax-4.s b/gas/testsuite/gas/i386/x86-64-relax-4.s
new file mode 100644
index 0000000..683d3e2
--- /dev/null
+++ b/gas/testsuite/gas/i386/x86-64-relax-4.s
@@ -0,0 +1,8 @@
+	.section .init.text,"ax",@progbits
+	.global foo
+foo:
+	call	printk
+	lea	printk(%rip), %rax
+	.text
+printk:
+	ret



More information about the Binutils-cvs mailing list