From adc7571d319f150964da9eb81db6f0a1f9dfcf82 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Thu, 9 Jun 2011 05:51:11 +0000 Subject: Allow building x32 DSO from x86-64 object file. bfd/ 2011-06-08 H.J. Lu * elf64-x86-64.c (elf_x86_64_check_relocs): Allow R_X86_64_64 relocations in SEC_DEBUGGING sections when building shared libraries. ld/testsuite/ 2011-06-08 H.J. Lu * ld-x86-64/simple.c: New. * ld-x86-64/x86-64-x32.rd: Likewise. * ld-x86-64/x86-64.exp: Check building x32 DSO from x86-64 object file. --- ld/testsuite/ChangeLog | 8 ++++++++ ld/testsuite/ld-x86-64/simple.c | 5 +++++ ld/testsuite/ld-x86-64/x86-64-x32.rd | 5 +++++ ld/testsuite/ld-x86-64/x86-64.exp | 23 +++++++++++++++++++++++ 4 files changed, 41 insertions(+) create mode 100644 ld/testsuite/ld-x86-64/simple.c create mode 100644 ld/testsuite/ld-x86-64/x86-64-x32.rd (limited to 'ld') diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index dcefc10..93096b0 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,5 +1,13 @@ 2011-06-08 H.J. Lu + * ld-x86-64/simple.c: New. + * ld-x86-64/x86-64-x32.rd: Likewise. + + * ld-x86-64/x86-64.exp: Check building x32 DSO from x86-64 + object file. + +2011-06-08 H.J. Lu + PR ld/12851 * ld-elf/pr12851.d: New. * ld-elf/pr12851.s: Likewise. diff --git a/ld/testsuite/ld-x86-64/simple.c b/ld/testsuite/ld-x86-64/simple.c new file mode 100644 index 0000000..4ce3e8f --- /dev/null +++ b/ld/testsuite/ld-x86-64/simple.c @@ -0,0 +1,5 @@ +int +foo (int x) +{ + return x * 4; +} diff --git a/ld/testsuite/ld-x86-64/x86-64-x32.rd b/ld/testsuite/ld-x86-64/x86-64-x32.rd new file mode 100644 index 0000000..7118cb9 --- /dev/null +++ b/ld/testsuite/ld-x86-64/x86-64-x32.rd @@ -0,0 +1,5 @@ +Symbol table '\.dynsym' contains [0-9]+ entries: + +Num: +Value +Size Type +Bind +Vis +Ndx Name +#... + +[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +FUNC +GLOBAL +DEFAULT +[0-9]+ +foo +#... diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp index c77640b..8d4ed2c 100644 --- a/ld/testsuite/ld-x86-64/x86-64.exp +++ b/ld/testsuite/ld-x86-64/x86-64.exp @@ -203,3 +203,26 @@ run_dump_test "ia32-3" run_dump_test "lp64-1" run_dump_test "lp64-2" run_dump_test "lp64-3" + +# Need the C compiler +if { [which $CC] != 0 } { + run_cc_link_tests { + {"Helper X32 DSO from x86-64 object" "" "-m64 -fPIC -g" + {simple.c} {} "libsimple.a"} + } + + set convertx32 "$objcopy -O elf32-x86-64 tmpdir/simple.o tmpdir/simple-x32.o" + send_log "$convertx32\n" + set got [remote_exec host "$convertx32"] + if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then { + send_log "$got\n" + fail "Convert x86-64 object to x32" + return + } + + run_ld_link_tests { + {"X32 DSO from x86-64 object" + "-shared -melf32_x86_64 tmpdir/simple-x32.o" "--x32" + {dummy.s} {{readelf {-s --wide} x86-64-x32.rd}} "x86-64-x32"} + } +} -- cgit v1.1