This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
PATCH: PR ld/11933: Differnt linker behavior with incompatible input files
- From: "H.J. Lu" <hongjiu dot lu at intel dot com>
- To: binutils at sourceware dot org
- Date: Sat, 21 Aug 2010 11:50:16 -0700
- Subject: PATCH: PR ld/11933: Differnt linker behavior with incompatible input files
- Reply-to: "H.J. Lu" <hjl dot tools at gmail dot com>
The linker behavior with incompatible input files is changed from
/export/home/hjl/bugs/binutils/merge-3/bz623687/ld: i386 architecture of input file `libtiff.a(tif_close.o)' is incompatible with i386:x86-64 output
to
libtiff.a: could not read symbols: File in wrong format
The new message isn't as clear as the old one. This patch restores the
old message. OK to install?
Thanks.
H.J.
---
bfd/
2010-08-21 H.J. Lu <hongjiu.lu@intel.com>
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-21 H.J. Lu <hongjiu.lu@intel.com>
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.
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 074229f..2f67c47 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/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp
index ed5d8dc..f5d1b0b 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"
--- /dev/null 2010-08-11 15:57:03.635230126 -0700
+++ binutils/ld/testsuite/ld-x86-64/mixed1a.s 2010-08-21 11:14:27.613974974 -0700
@@ -0,0 +1,6 @@
+ .text
+.globl _start
+ .type _start, @function
+_start:
+ cmpq $0, foo(%rip)
+ .size _start, .-_start
--- /dev/null 2010-08-11 15:57:03.635230126 -0700
+++ binutils/ld/testsuite/ld-x86-64/mixed1b.s 2010-08-21 11:15:00.139920256 -0700
@@ -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
--- /dev/null 2010-08-11 15:57:03.635230126 -0700
+++ binutils/ld/testsuite/ld-x86-64/mixed2a.s 2010-08-21 11:22:40.024634224 -0700
@@ -0,0 +1,7 @@
+ .text
+ .p2align 4,,15
+.globl _start
+ .type _start, @function
+_start:
+ movl foo(%rip), %eax
+ .size _start, .-_start
--- /dev/null 2010-08-11 15:57:03.635230126 -0700
+++ binutils/ld/testsuite/ld-x86-64/mixed2b.s 2010-08-21 11:22:55.783945139 -0700
@@ -0,0 +1,7 @@
+.globl foo
+ .data
+ .align 4
+ .type foo, @object
+ .size foo, 4
+foo:
+ .long 1