diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2008-03-16 22:26:23 +0000 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2008-03-16 22:26:23 +0000 |
commit | 41bed6dd8a0e8e81d94fa4d1e552ed3b3c7f206f (patch) | |
tree | 4bedfd82ca5af4b5edaf96e2e066f13a2bcc5b48 /ld | |
parent | f01be29bbc6ef5fd011675bd0da09ab1f7aea030 (diff) | |
download | gdb-41bed6dd8a0e8e81d94fa4d1e552ed3b3c7f206f.zip gdb-41bed6dd8a0e8e81d94fa4d1e552ed3b3c7f206f.tar.gz gdb-41bed6dd8a0e8e81d94fa4d1e552ed3b3c7f206f.tar.bz2 |
bfd/
2008-03-16 H.J. Lu <hongjiu.lu@intel.com>
PR ld/5789
PR ld/5943
* elf32-i386.c (elf_i386_relocate_section): Issue an error
for R_386_GOTOFF relocaton against undefined hidden/internal
symbols when building a shared object.
* elf64-x86-64.c (elf64_x86_64_relocate_section): Issue an
error for R_X86_64_PC8/R_X86_64_PC16/R_X86_64_PC32
relocaton against undefined hidden/internal symbols when
building a shared object.
(elf64_x86_64_finish_dynamic_symbol): Return FALSE when symbol
is referenced locally, but isn't defined in a regular file.
ld/testsuite/
2008-03-16 H.J. Lu <hongjiu.lu@intel.com>
PR ld/5789
PR ld/5943
* ld-i386/hidden1.d: New.
* ld-i386/hidden1.s: Likewise.
* ld-i386/hidden2.d: Likewise.
* ld-i386/hidden2.s: Likewise.
* ld-i386/hidden3.d: Likewise.
* ld-i386/hidden4.s: Likewise.
* ld-i386/protected1.d: Likewise.
* ld-i386/protected1.s: Likewise.
* ld-i386/protected2.d: Likewise.
* ld-i386/protected2.s: Likewise.
* ld-i386/protected3.d: Likewise.
* ld-i386/protected3.s: Likewise.
* ld-x86-64/hidden1.d: Likewise.
* ld-x86-64/hidden1.s: Likewise.
* ld-x86-64/hidden2.d: Likewise.
* ld-x86-64/hidden2.s: Likewise.
* ld-x86-64/hidden3.d: Likewise.
* ld-x86-64/hidden3.s: Likewise.
* ld-x86-64/protected1.d: Likewise.
* ld-x86-64/protected1.s: Likewise.
* ld-x86-64/protected2.d: Likewise.
* ld-x86-64/protected2.s: Likewise.
* ld-x86-64/protected3.d: Likewise.
* ld-x86-64/protected3.s: Likewise.
* ld-i386/i386.exp: Run hidden1, hidden2, hidden3, protected1,
protected2 and protected3.
* ld-x86-64/x86-64.exp: Likewise.
Diffstat (limited to 'ld')
27 files changed, 281 insertions, 0 deletions
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index 9ddae66..2f5fab8 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,36 @@ +2008-03-16 H.J. Lu <hongjiu.lu@intel.com> + + PR ld/5789 + PR ld/5943 + * ld-i386/hidden1.d: New. + * ld-i386/hidden1.s: Likewise. + * ld-i386/hidden2.d: Likewise. + * ld-i386/hidden2.s: Likewise. + * ld-i386/hidden3.d: Likewise. + * ld-i386/hidden4.s: Likewise. + * ld-i386/protected1.d: Likewise. + * ld-i386/protected1.s: Likewise. + * ld-i386/protected2.d: Likewise. + * ld-i386/protected2.s: Likewise. + * ld-i386/protected3.d: Likewise. + * ld-i386/protected3.s: Likewise. + * ld-x86-64/hidden1.d: Likewise. + * ld-x86-64/hidden1.s: Likewise. + * ld-x86-64/hidden2.d: Likewise. + * ld-x86-64/hidden2.s: Likewise. + * ld-x86-64/hidden3.d: Likewise. + * ld-x86-64/hidden3.s: Likewise. + * ld-x86-64/protected1.d: Likewise. + * ld-x86-64/protected1.s: Likewise. + * ld-x86-64/protected2.d: Likewise. + * ld-x86-64/protected2.s: Likewise. + * ld-x86-64/protected3.d: Likewise. + * ld-x86-64/protected3.s: Likewise. + + * ld-i386/i386.exp: Run hidden1, hidden2, hidden3, protected1, + protected2 and protected3. + * ld-x86-64/x86-64.exp: Likewise. + 2008-03-14 Alan Modra <amodra@bigpond.net.au> * ld-spu/ovl2.s: Make setjmp global. diff --git a/ld/testsuite/ld-i386/hidden1.d b/ld/testsuite/ld-i386/hidden1.d new file mode 100644 index 0000000..5ace20d --- /dev/null +++ b/ld/testsuite/ld-i386/hidden1.d @@ -0,0 +1,3 @@ +#as: --32 +#ld: -shared -melf_i386 +#error: .*relocation R_386_GOTOFF against undefined hidden symbol `foo' can not be used when making a shared object diff --git a/ld/testsuite/ld-i386/hidden1.s b/ld/testsuite/ld-i386/hidden1.s new file mode 100644 index 0000000..2c1ce93 --- /dev/null +++ b/ld/testsuite/ld-i386/hidden1.s @@ -0,0 +1,9 @@ + .text +.globl bar + .type bar, @function +bar: + leal foo@GOTOFF(%ecx), %eax + ret + .size bar, .-bar + .weak foo + .hidden foo diff --git a/ld/testsuite/ld-i386/hidden2.d b/ld/testsuite/ld-i386/hidden2.d new file mode 100644 index 0000000..90bc438 --- /dev/null +++ b/ld/testsuite/ld-i386/hidden2.d @@ -0,0 +1,13 @@ +#as: --32 +#ld: -shared -melf_i386 +#objdump: -drw + +.*: +file format .* + + +Disassembly of section .text: + +[a-f0-9]+ <bar>: +[ ]*[a-f0-9]+: e8 cf fe ff ff call 0 <bar-0x[a-f0-9]+> +[ ]*[a-f0-9]+: c3 ret +#pass diff --git a/ld/testsuite/ld-i386/hidden2.s b/ld/testsuite/ld-i386/hidden2.s new file mode 100644 index 0000000..03e2ce7 --- /dev/null +++ b/ld/testsuite/ld-i386/hidden2.s @@ -0,0 +1,9 @@ + .text +.globl bar + .type bar, @function +bar: + call foo + ret + .size bar, .-bar + .weak foo + .hidden foo diff --git a/ld/testsuite/ld-i386/hidden3.d b/ld/testsuite/ld-i386/hidden3.d new file mode 100644 index 0000000..5ace20d --- /dev/null +++ b/ld/testsuite/ld-i386/hidden3.d @@ -0,0 +1,3 @@ +#as: --32 +#ld: -shared -melf_i386 +#error: .*relocation R_386_GOTOFF against undefined hidden symbol `foo' can not be used when making a shared object diff --git a/ld/testsuite/ld-i386/hidden3.s b/ld/testsuite/ld-i386/hidden3.s new file mode 100644 index 0000000..221b159 --- /dev/null +++ b/ld/testsuite/ld-i386/hidden3.s @@ -0,0 +1,8 @@ + .text +.globl bar + .type bar, @function +bar: + leal foo@GOTOFF(%ecx), %eax + ret + .size bar, .-bar + .hidden foo diff --git a/ld/testsuite/ld-i386/i386.exp b/ld/testsuite/ld-i386/i386.exp index 10f90ce..6f75f3a 100644 --- a/ld/testsuite/ld-i386/i386.exp +++ b/ld/testsuite/ld-i386/i386.exp @@ -132,3 +132,9 @@ run_dump_test "tlsie2" run_dump_test "tlsie3" run_dump_test "tlsie4" run_dump_test "tlsie5" +run_dump_test "hidden1" +run_dump_test "hidden2" +run_dump_test "hidden3" +run_dump_test "protected1" +run_dump_test "protected2" +run_dump_test "protected3" diff --git a/ld/testsuite/ld-i386/protected1.d b/ld/testsuite/ld-i386/protected1.d new file mode 100644 index 0000000..a3cb5ce --- /dev/null +++ b/ld/testsuite/ld-i386/protected1.d @@ -0,0 +1,3 @@ +#as: --32 +#ld: -shared -melf_i386 +#error: .*relocation R_386_GOTOFF against protected function `foo' can not be used when making a shared object diff --git a/ld/testsuite/ld-i386/protected1.s b/ld/testsuite/ld-i386/protected1.s new file mode 100644 index 0000000..2edaeb2 --- /dev/null +++ b/ld/testsuite/ld-i386/protected1.s @@ -0,0 +1,13 @@ + .text +.globl foo + .protected foo + .type foo, @function +foo: + ret + .size foo, .-foo +.globl bar + .type bar, @function +bar: + leal foo@GOTOFF(%ecx), %eax + ret + .size bar, .-bar diff --git a/ld/testsuite/ld-i386/protected2.d b/ld/testsuite/ld-i386/protected2.d new file mode 100644 index 0000000..ba53e59 --- /dev/null +++ b/ld/testsuite/ld-i386/protected2.d @@ -0,0 +1,16 @@ +#as: --32 +#ld: -shared -melf_i386 +#objdump: -drw + +.*: +file format .* + + +Disassembly of section .text: + +0+[a-f0-9]+ <foo>: +[ ]*[a-f0-9]+: c3 ret + +0+[a-f0-9]+ <bar>: +[ ]*[a-f0-9]+: e8 fa ff ff ff call [a-f0-9]+ <foo> +[ ]*[a-f0-9]+: c3 ret +#pass diff --git a/ld/testsuite/ld-i386/protected2.s b/ld/testsuite/ld-i386/protected2.s new file mode 100644 index 0000000..61e5aec --- /dev/null +++ b/ld/testsuite/ld-i386/protected2.s @@ -0,0 +1,13 @@ + .text +.globl foo + .protected foo + .type foo, @function +foo: + ret + .size foo, .-foo +.globl bar + .type bar, @function +bar: + call foo + ret + .size bar, .-bar diff --git a/ld/testsuite/ld-i386/protected3.d b/ld/testsuite/ld-i386/protected3.d new file mode 100644 index 0000000..e42185a --- /dev/null +++ b/ld/testsuite/ld-i386/protected3.d @@ -0,0 +1,13 @@ +#as: --32 +#ld: -shared -melf_i386 +#objdump: -drw + +.*: +file format .* + + +Disassembly of section .text: + +0+[a-f0-9]+ <bar>: +[ ]*[a-f0-9]+: 8b 81 0c 00 00 00 mov 0x[a-f0-9]+\(%ecx\),%eax +[ ]*[a-f0-9]+: c3 ret +#pass diff --git a/ld/testsuite/ld-i386/protected3.s b/ld/testsuite/ld-i386/protected3.s new file mode 100644 index 0000000..7a605a2 --- /dev/null +++ b/ld/testsuite/ld-i386/protected3.s @@ -0,0 +1,15 @@ + .protected foo +.globl foo + .data + .align 4 + .type foo, @object + .size foo, 4 +foo: + .long 1 + .text +.globl bar + .type bar, @function +bar: + movl foo@GOTOFF(%ecx), %eax + ret + .size bar, .-bar diff --git a/ld/testsuite/ld-x86-64/hidden1.d b/ld/testsuite/ld-x86-64/hidden1.d new file mode 100644 index 0000000..c4c843b --- /dev/null +++ b/ld/testsuite/ld-x86-64/hidden1.d @@ -0,0 +1,3 @@ +#as: --64 +#ld: -shared -melf_x86_64 +#error: .*relocation R_X86_64_PC32 against undefined hidden symbol `foo' can not be used when making a shared object diff --git a/ld/testsuite/ld-x86-64/hidden1.s b/ld/testsuite/ld-x86-64/hidden1.s new file mode 100644 index 0000000..ba7f88b --- /dev/null +++ b/ld/testsuite/ld-x86-64/hidden1.s @@ -0,0 +1,9 @@ + .text +.globl bar + .type bar, @function +bar: + leaq foo(%rip), %rax + ret + .size bar, .-bar + .weak foo + .hidden foo diff --git a/ld/testsuite/ld-x86-64/hidden2.d b/ld/testsuite/ld-x86-64/hidden2.d new file mode 100644 index 0000000..0d89e6e --- /dev/null +++ b/ld/testsuite/ld-x86-64/hidden2.d @@ -0,0 +1,13 @@ +#as: --64 +#ld: -shared -melf_x86_64 +#objdump: -drw + +.*: +file format .* + + +Disassembly of section .text: + +[a-f0-9]+ <bar>: +[ ]*[a-f0-9]+: e8 33 fe ff ff callq 0 <bar-0x[a-f0-9]+> +[ ]*[a-f0-9]+: c3 retq +#pass diff --git a/ld/testsuite/ld-x86-64/hidden2.s b/ld/testsuite/ld-x86-64/hidden2.s new file mode 100644 index 0000000..03e2ce7 --- /dev/null +++ b/ld/testsuite/ld-x86-64/hidden2.s @@ -0,0 +1,9 @@ + .text +.globl bar + .type bar, @function +bar: + call foo + ret + .size bar, .-bar + .weak foo + .hidden foo diff --git a/ld/testsuite/ld-x86-64/hidden3.d b/ld/testsuite/ld-x86-64/hidden3.d new file mode 100644 index 0000000..c4c843b --- /dev/null +++ b/ld/testsuite/ld-x86-64/hidden3.d @@ -0,0 +1,3 @@ +#as: --64 +#ld: -shared -melf_x86_64 +#error: .*relocation R_X86_64_PC32 against undefined hidden symbol `foo' can not be used when making a shared object diff --git a/ld/testsuite/ld-x86-64/hidden3.s b/ld/testsuite/ld-x86-64/hidden3.s new file mode 100644 index 0000000..75482aa --- /dev/null +++ b/ld/testsuite/ld-x86-64/hidden3.s @@ -0,0 +1,8 @@ + .text +.globl bar + .type bar, @function +bar: + leaq foo(%rip), %rax + ret + .size bar, .-bar + .hidden foo diff --git a/ld/testsuite/ld-x86-64/protected1.d b/ld/testsuite/ld-x86-64/protected1.d new file mode 100644 index 0000000..783b85a --- /dev/null +++ b/ld/testsuite/ld-x86-64/protected1.d @@ -0,0 +1,3 @@ +#as: --64 +#ld: -shared -melf_x86_64 +#error: .*relocation R_X86_64_PC32 against protected symbol `foo' can not be used when making a shared object diff --git a/ld/testsuite/ld-x86-64/protected1.s b/ld/testsuite/ld-x86-64/protected1.s new file mode 100644 index 0000000..31368aa --- /dev/null +++ b/ld/testsuite/ld-x86-64/protected1.s @@ -0,0 +1,13 @@ + .text +.globl foo + .protected foo + .type foo, @function +foo: + ret + .size foo, .-foo +.globl bar + .type bar, @function +bar: + leaq foo(%rip), %rax + ret + .size bar, .-bar diff --git a/ld/testsuite/ld-x86-64/protected2.d b/ld/testsuite/ld-x86-64/protected2.d new file mode 100644 index 0000000..2e91b17 --- /dev/null +++ b/ld/testsuite/ld-x86-64/protected2.d @@ -0,0 +1,16 @@ +#as: --64 +#ld: -shared -melf_x86_64 +#objdump: -drw + +.*: +file format .* + + +Disassembly of section .text: + +0+[a-f0-9]+ <foo>: +[ ]*[a-f0-9]+: c3 retq + +0+[a-f0-9]+ <bar>: +[ ]*[a-f0-9]+: e8 fa ff ff ff callq [a-f0-9]+ <foo> +[ ]*[a-f0-9]+: c3 retq +#pass diff --git a/ld/testsuite/ld-x86-64/protected2.s b/ld/testsuite/ld-x86-64/protected2.s new file mode 100644 index 0000000..61e5aec --- /dev/null +++ b/ld/testsuite/ld-x86-64/protected2.s @@ -0,0 +1,13 @@ + .text +.globl foo + .protected foo + .type foo, @function +foo: + ret + .size foo, .-foo +.globl bar + .type bar, @function +bar: + call foo + ret + .size bar, .-bar diff --git a/ld/testsuite/ld-x86-64/protected3.d b/ld/testsuite/ld-x86-64/protected3.d new file mode 100644 index 0000000..09556ce --- /dev/null +++ b/ld/testsuite/ld-x86-64/protected3.d @@ -0,0 +1,13 @@ +#as: --64 +#ld: -shared -melf_x86_64 +#objdump: -drw + +.*: +file format .* + + +Disassembly of section .text: + +0+[a-f0-9]+ <bar>: +[ ]*[a-f0-9]+: 8b 05 ce 00 20 00 mov 0x[a-f0-9]+\(%rip\),%eax # [a-f0-9]+ <foo> +[ ]*[a-f0-9]+: c3 retq +#pass diff --git a/ld/testsuite/ld-x86-64/protected3.s b/ld/testsuite/ld-x86-64/protected3.s new file mode 100644 index 0000000..e4af6e7 --- /dev/null +++ b/ld/testsuite/ld-x86-64/protected3.s @@ -0,0 +1,15 @@ + .protected foo +.globl foo + .data + .align 4 + .type foo, @object + .size foo, 4 +foo: + .long 1 + .text +.globl bar + .type bar, @function +bar: + movl foo(%rip), %eax + ret + .size bar, .-bar diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp index cd26091..eeeea43 100644 --- a/ld/testsuite/ld-x86-64/x86-64.exp +++ b/ld/testsuite/ld-x86-64/x86-64.exp @@ -86,3 +86,9 @@ run_dump_test "tlsgd2" run_dump_test "tlsgd3" run_dump_test "tlsie2" run_dump_test "tlsie3" +run_dump_test "hidden1" +run_dump_test "hidden2" +run_dump_test "hidden3" +run_dump_test "protected1" +run_dump_test "protected2" +run_dump_test "protected3" |