From ca200db50605e69886a5257e538f0e8d6e4941a1 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Sun, 22 Aug 2010 19:14:23 +0000 Subject: [PATCH] Don't check relocation if input ELF object ID doesn't match output. bfd/ 2010-08-22 H.J. Lu PR ld/11933 * elflink.c (elf_link_add_object_symbols): Don't check relocation if input ELF object ID doesn't match output. ld/testsuite/ 2010-08-22 H.J. Lu PR ld/11933 * ld-x86-64/mixed1a.s: New. * ld-x86-64/mixed1b.s: Likewise. * ld-x86-64/mixed2a.s: Likewise. * ld-x86-64/mixed2b.s: Likewise. * ld-x86-64/x86-64.exp: Text mixed x86_64 and i386 inputs. --- bfd/ChangeLog | 6 ++++++ bfd/elflink.c | 1 + ld/testsuite/ChangeLog | 10 ++++++++++ ld/testsuite/ld-x86-64/mixed1a.s | 6 ++++++ ld/testsuite/ld-x86-64/mixed1b.s | 10 ++++++++++ ld/testsuite/ld-x86-64/mixed2a.s | 7 +++++++ ld/testsuite/ld-x86-64/mixed2b.s | 7 +++++++ ld/testsuite/ld-x86-64/x86-64.exp | 31 +++++++++++++++++++++++++++++++ 8 files changed, 78 insertions(+) create mode 100644 ld/testsuite/ld-x86-64/mixed1a.s create mode 100644 ld/testsuite/ld-x86-64/mixed1b.s create mode 100644 ld/testsuite/ld-x86-64/mixed2a.s create mode 100644 ld/testsuite/ld-x86-64/mixed2b.s diff --git a/bfd/ChangeLog b/bfd/ChangeLog index ee2722940..7ae83002a 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2010-08-22 H.J. Lu + + PR ld/11933 + * elflink.c (elf_link_add_object_symbols): Don't check relocation + if input ELF object ID doesn't match output. + 2010-08-21 Ralf Wildenhues * configure: Regenerate. diff --git a/bfd/elflink.c b/bfd/elflink.c index 074229f7c..2f67c4769 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -4791,6 +4791,7 @@ error_free_dyn: if (! dynamic && is_elf_hash_table (htab) && bed->check_relocs != NULL + && elf_object_id (abfd) == elf_hash_table_id (htab) && (*bed->relocs_compatible) (abfd->xvec, info->output_bfd->xvec)) { asection *o; diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index 5a7bff8fa..df69b3756 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,13 @@ +2010-08-22 H.J. Lu + + PR ld/11933 + * ld-x86-64/mixed1a.s: New. + * ld-x86-64/mixed1b.s: Likewise. + * ld-x86-64/mixed2a.s: Likewise. + * ld-x86-64/mixed2b.s: Likewise. + + * ld-x86-64/x86-64.exp: Text mixed x86_64 and i386 inputs. + 2010-08-20 Maciej W. Rozycki * ld-sh/sh.exp: Add missing newline. diff --git a/ld/testsuite/ld-x86-64/mixed1a.s b/ld/testsuite/ld-x86-64/mixed1a.s new file mode 100644 index 000000000..07e0ae807 --- /dev/null +++ b/ld/testsuite/ld-x86-64/mixed1a.s @@ -0,0 +1,6 @@ + .text +.globl _start + .type _start, @function +_start: + cmpq $0, foo(%rip) + .size _start, .-_start diff --git a/ld/testsuite/ld-x86-64/mixed1b.s b/ld/testsuite/ld-x86-64/mixed1b.s new file mode 100644 index 000000000..66bb38fd2 --- /dev/null +++ b/ld/testsuite/ld-x86-64/mixed1b.s @@ -0,0 +1,10 @@ +.globl foo + .section .rodata.str1.1,"aMS",@progbits,1 +.LC0: + .string "Hello" + .data + .align 4 + .type foo, @object + .size foo, 4 +foo: + .long .LC0 diff --git a/ld/testsuite/ld-x86-64/mixed2a.s b/ld/testsuite/ld-x86-64/mixed2a.s new file mode 100644 index 000000000..a597bb3b2 --- /dev/null +++ b/ld/testsuite/ld-x86-64/mixed2a.s @@ -0,0 +1,7 @@ + .text + .p2align 4,,15 +.globl _start + .type _start, @function +_start: + movl foo(%rip), %eax + .size _start, .-_start diff --git a/ld/testsuite/ld-x86-64/mixed2b.s b/ld/testsuite/ld-x86-64/mixed2b.s new file mode 100644 index 000000000..3cac80132 --- /dev/null +++ b/ld/testsuite/ld-x86-64/mixed2b.s @@ -0,0 +1,7 @@ +.globl foo + .data + .align 4 + .type foo, @object + .size foo, 4 +foo: + .long 1 diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp index ed5d8dce3..f5d1b0bcb 100644 --- a/ld/testsuite/ld-x86-64/x86-64.exp +++ b/ld/testsuite/ld-x86-64/x86-64.exp @@ -75,10 +75,41 @@ set x86_64tests { {"TLS IE->LE transition" "-melf_x86_64" "--64" {tlsie1.s} {{objdump -dwr tlsie1.dd}} "tlsie1"} + {"Helper 64bit object 1" "-r -melf_x86_64" + "--64" {mixed1a.s} {} "libmixe1a.o"} + {"Helper 32bit object 1" "-r -melf_i386" + "--32" {mixed1b.s} {} "libmixe1b.o"} + {"Helper 64bit object 2" "-r -melf_x86_64" + "--64" {mixed2a.s} {} "libmixe2a.o"} + {"Helper 32bit object 2" "-r -melf_i386" + "--32" {mixed2b.s} {} "libmixe2b.o"} } run_ld_link_tests $x86_64tests +global link_output +global ld + +set test_namename "Mixed x86_64 and i386 input test 1" +set test mixed1 +if { ![ld_simple_link $ld tmpdir/$test "-melf_x86_64 tmpdir/${test}a.o tmpdir/${test}b.o"] } { + if [string match "*i386 architecture of input file `tmpdir/${test}b.o' is incompatible with i386:x86-64 output*" $link_output] { + pass "$test_name" + } { + fail "$test_name" + } +} + +set test_namename "Mixed x86_64 and i386 input test 2" +set test mixed2 +if { ![ld_simple_link $ld tmpdir/$test "-melf_x86_64 tmpdir/${test}a.o tmpdir/${test}b.o"] } { + if [string match "*i386 architecture of input file `tmpdir/${test}b.o' is incompatible with i386:x86-64 output*" $link_output] { + pass "$test_name" + } { + fail "$test_name" + } +} + run_dump_test "abs" run_dump_test "abs-l1om" run_dump_test "pcrel8" -- 2.11.4.GIT