aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2012-08-31 04:26:17 +0000
committerH.J. Lu <hjl.tools@gmail.com>2012-08-31 04:26:17 +0000
commit80d873266deca488bd8059e32780e8ce3ef6191d (patch)
tree3c0be3e693f706776a6a402516a1f013d75b1d2d /ld
parent11cba4accf7f9a82fdb7902f0e36521038eda205 (diff)
downloadgdb-80d873266deca488bd8059e32780e8ce3ef6191d.zip
gdb-80d873266deca488bd8059e32780e8ce3ef6191d.tar.gz
gdb-80d873266deca488bd8059e32780e8ce3ef6191d.tar.bz2
Convert mov to lea for loading local function address
bfd/ * elf32-i386.c (elf_i386_relocate_section): Convert "mov foo@GOT(%reg), %reg" to "lea foo@GOTOFF(%reg), %reg" for local symbols. * elf64-x86-64.c (elf_x86_64_relocate_section): Convert "mov foo@GOTPCREL(%rip), %reg" to "lea foo(%rip), %reg" for local symbols. ld/testsuite/ * ld-i386/i386.exp: Run lea1a, lea1b, lea1c. * ld-x86-64/x86-64.exp: Run lea1a, lea1b, lea1c, lea1d, lea1e, lea1f. * ld-i386/lea1.s: New file. * ld-i386/lea1a.d: Likewise. * ld-i386/lea1b.d: Likewise. * ld-i386/lea1c.d: Likewise. * ld-x86-64/lea1.s: Likewise. * ld-x86-64/lea1a.d: Likewise. * ld-x86-64/lea1b.d: Likewise. * ld-x86-64/lea1c.d: Likewise. * ld-x86-64/lea1d.d: Likewise. * ld-x86-64/lea1e.d: Likewise. * ld-x86-64/lea1f.d: Likewise.
Diffstat (limited to 'ld')
-rw-r--r--ld/testsuite/ChangeLog18
-rw-r--r--ld/testsuite/ld-i386/i386.exp3
-rw-r--r--ld/testsuite/ld-i386/lea1.s11
-rw-r--r--ld/testsuite/ld-i386/lea1a.d13
-rw-r--r--ld/testsuite/ld-i386/lea1b.d13
-rw-r--r--ld/testsuite/ld-i386/lea1c.d13
-rw-r--r--ld/testsuite/ld-x86-64/lea1.s11
-rw-r--r--ld/testsuite/ld-x86-64/lea1a.d13
-rw-r--r--ld/testsuite/ld-x86-64/lea1b.d13
-rw-r--r--ld/testsuite/ld-x86-64/lea1c.d13
-rw-r--r--ld/testsuite/ld-x86-64/lea1d.d13
-rw-r--r--ld/testsuite/ld-x86-64/lea1e.d13
-rw-r--r--ld/testsuite/ld-x86-64/lea1f.d13
-rw-r--r--ld/testsuite/ld-x86-64/x86-64.exp6
14 files changed, 166 insertions, 0 deletions
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index 5537d0a..bab65e4 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,5 +1,23 @@
2012-08-30 H.J. Lu <hongjiu.lu@intel.com>
+ * ld-i386/i386.exp: Run lea1a, lea1b, lea1c.
+ * ld-x86-64/x86-64.exp: Run lea1a, lea1b, lea1c, lea1d, lea1e,
+ lea1f.
+
+ * ld-i386/lea1.s: New file.
+ * ld-i386/lea1a.d: Likewise.
+ * ld-i386/lea1b.d: Likewise.
+ * ld-i386/lea1c.d: Likewise.
+ * ld-x86-64/lea1.s: Likewise.
+ * ld-x86-64/lea1a.d: Likewise.
+ * ld-x86-64/lea1b.d: Likewise.
+ * ld-x86-64/lea1c.d: Likewise.
+ * ld-x86-64/lea1d.d: Likewise.
+ * ld-x86-64/lea1e.d: Likewise.
+ * ld-x86-64/lea1f.d: Likewise.
+
+2012-08-30 H.J. Lu <hongjiu.lu@intel.com>
+
PR ld/14525
* ld-elf/elf.exp: Run pr14525.
diff --git a/ld/testsuite/ld-i386/i386.exp b/ld/testsuite/ld-i386/i386.exp
index 03367ca..b7e8042 100644
--- a/ld/testsuite/ld-i386/i386.exp
+++ b/ld/testsuite/ld-i386/i386.exp
@@ -233,6 +233,9 @@ run_dump_test "pr12718"
run_dump_test "pr12921"
run_dump_test "pr12570a"
run_dump_test "pr12570b"
+run_dump_test "lea1a"
+run_dump_test "lea1b"
+run_dump_test "lea1c"
if { !([istarget "i?86-*-linux*"]
|| [istarget "i?86-*-gnu*"]
diff --git a/ld/testsuite/ld-i386/lea1.s b/ld/testsuite/ld-i386/lea1.s
new file mode 100644
index 0000000..6afad88
--- /dev/null
+++ b/ld/testsuite/ld-i386/lea1.s
@@ -0,0 +1,11 @@
+ .text
+ .globl foo
+ .type foo, @function
+foo:
+ ret
+ .size foo, .-foo
+ .globl _start
+ .type _start, @function
+_start:
+ movl foo@GOT(%ecx), %eax
+ .size _start, .-_start
diff --git a/ld/testsuite/ld-i386/lea1a.d b/ld/testsuite/ld-i386/lea1a.d
new file mode 100644
index 0000000..45b4965
--- /dev/null
+++ b/ld/testsuite/ld-i386/lea1a.d
@@ -0,0 +1,13 @@
+#source: lea1.s
+#as: --32
+#ld: -Bsymbolic -shared -melf_i386
+#objdump: -dw
+
+.*: +file format .*
+
+
+Disassembly of section .text:
+
+#...
+[ ]*[a-f0-9]+: 8d 81 ([0-9a-f]{2} ){4} * lea -0x[a-f0-9]+\(%ecx\),%eax
+#pass
diff --git a/ld/testsuite/ld-i386/lea1b.d b/ld/testsuite/ld-i386/lea1b.d
new file mode 100644
index 0000000..9ad4464
--- /dev/null
+++ b/ld/testsuite/ld-i386/lea1b.d
@@ -0,0 +1,13 @@
+#source: lea1.s
+#as: --32
+#ld: -pie -melf_i386
+#objdump: -dw
+
+.*: +file format .*
+
+
+Disassembly of section .text:
+
+#...
+[ ]*[a-f0-9]+: 8d 81 ([0-9a-f]{2} ){4} * lea -0x[a-f0-9]+\(%ecx\),%eax
+#pass
diff --git a/ld/testsuite/ld-i386/lea1c.d b/ld/testsuite/ld-i386/lea1c.d
new file mode 100644
index 0000000..5ba8275
--- /dev/null
+++ b/ld/testsuite/ld-i386/lea1c.d
@@ -0,0 +1,13 @@
+#source: lea1.s
+#as: --32
+#ld: -melf_i386
+#objdump: -dw
+
+.*: +file format .*
+
+
+Disassembly of section .text:
+
+#...
+[ ]*[a-f0-9]+: 8d 81 ([0-9a-f]{2} ){4} * lea -0x[a-f0-9]+\(%ecx\),%eax
+#pass
diff --git a/ld/testsuite/ld-x86-64/lea1.s b/ld/testsuite/ld-x86-64/lea1.s
new file mode 100644
index 0000000..4dce487
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/lea1.s
@@ -0,0 +1,11 @@
+ .text
+ .globl foo
+ .type foo, @function
+foo:
+ ret
+ .size foo, .-foo
+ .globl _start
+ .type _start, @function
+_start:
+ movq foo@GOTPCREL(%rip), %rax
+ .size _start, .-_start
diff --git a/ld/testsuite/ld-x86-64/lea1a.d b/ld/testsuite/ld-x86-64/lea1a.d
new file mode 100644
index 0000000..b48f253
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/lea1a.d
@@ -0,0 +1,13 @@
+#source: lea1.s
+#as: --64
+#ld: -Bsymbolic -shared -melf_x86_64
+#objdump: -dw
+
+.*: +file format .*
+
+
+Disassembly of section .text:
+
+#...
+[ ]*[a-f0-9]+: 48 8d 05 ([0-9a-f]{2} ){4} * lea -0x[a-f0-9]+\(%rip\),%rax # [a-f0-9]+ <foo>
+#pass
diff --git a/ld/testsuite/ld-x86-64/lea1b.d b/ld/testsuite/ld-x86-64/lea1b.d
new file mode 100644
index 0000000..9ee7220
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/lea1b.d
@@ -0,0 +1,13 @@
+#source: lea1.s
+#as: --64
+#ld: -pie -melf_x86_64
+#objdump: -dw
+
+.*: +file format .*
+
+
+Disassembly of section .text:
+
+#...
+[ ]*[a-f0-9]+: 48 8d 05 ([0-9a-f]{2} ){4} * lea -0x[a-f0-9]+\(%rip\),%rax # [a-f0-9]+ <foo>
+#pass
diff --git a/ld/testsuite/ld-x86-64/lea1c.d b/ld/testsuite/ld-x86-64/lea1c.d
new file mode 100644
index 0000000..6ff1618
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/lea1c.d
@@ -0,0 +1,13 @@
+#source: lea1.s
+#as: --64
+#ld: -melf_x86_64
+#objdump: -dw
+
+.*: +file format .*
+
+
+Disassembly of section .text:
+
+#...
+[ ]*[a-f0-9]+: 48 8d 05 ([0-9a-f]{2} ){4} * lea -0x[a-f0-9]+\(%rip\),%rax # [a-f0-9]+ <foo>
+#pass
diff --git a/ld/testsuite/ld-x86-64/lea1d.d b/ld/testsuite/ld-x86-64/lea1d.d
new file mode 100644
index 0000000..d117f6b
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/lea1d.d
@@ -0,0 +1,13 @@
+#source: lea1.s
+#as: --x32
+#ld: -Bsymbolic -shared -melf32_x86_64
+#objdump: -dw
+
+.*: +file format .*
+
+
+Disassembly of section .text:
+
+#...
+[ ]*[a-f0-9]+: 48 8d 05 ([0-9a-f]{2} ){4} * lea -0x[a-f0-9]+\(%rip\),%rax # [a-f0-9]+ <foo>
+#pass
diff --git a/ld/testsuite/ld-x86-64/lea1e.d b/ld/testsuite/ld-x86-64/lea1e.d
new file mode 100644
index 0000000..bde3e6f
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/lea1e.d
@@ -0,0 +1,13 @@
+#source: lea1.s
+#as: --x32
+#ld: -pie -melf32_x86_64
+#objdump: -dw
+
+.*: +file format .*
+
+
+Disassembly of section .text:
+
+#...
+[ ]*[a-f0-9]+: 48 8d 05 ([0-9a-f]{2} ){4} * lea -0x[a-f0-9]+\(%rip\),%rax # [a-f0-9]+ <foo>
+#pass
diff --git a/ld/testsuite/ld-x86-64/lea1f.d b/ld/testsuite/ld-x86-64/lea1f.d
new file mode 100644
index 0000000..568143a
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/lea1f.d
@@ -0,0 +1,13 @@
+#source: lea1.s
+#as: --x32
+#ld: -melf32_x86_64
+#objdump: -dw
+
+.*: +file format .*
+
+
+Disassembly of section .text:
+
+#...
+[ ]*[a-f0-9]+: 48 8d 05 ([0-9a-f]{2} ){4} * lea -0x[a-f0-9]+\(%rip\),%rax # [a-f0-9]+ <foo>
+#pass
diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp
index 1eb1b1c..1db81c8 100644
--- a/ld/testsuite/ld-x86-64/x86-64.exp
+++ b/ld/testsuite/ld-x86-64/x86-64.exp
@@ -276,6 +276,12 @@ run_dump_test "pr13082-5a"
run_dump_test "pr13082-5b"
run_dump_test "pr13082-6a"
run_dump_test "pr13082-6b"
+run_dump_test "lea1a"
+run_dump_test "lea1b"
+run_dump_test "lea1c"
+run_dump_test "lea1d"
+run_dump_test "lea1e"
+run_dump_test "lea1f"
# Must be native with the C compiler
if { [isnative] && [which $CC] != 0 } {