From 268121417c4844cbb1d533cd5e0a2e273442d718 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 6 Nov 2013 14:47:05 -0800 Subject: Set CPU type in BFD backend for x86_64-nacl* and i?86-nacl* targets bfd/ * archures.c (bfd_mach_i386_nacl): Fix definition so it doesn't collide with bfd_mach_l1om. * bfd-in2.h: Regenerate. * elf32-i386.c (elf32_i386_nacl_elf_object_p): New function. (elf_backend_object_p): Use that in elf32-i386-nacl definition. * elf64-x86-64.c (elf64_x86_64_nacl_elf_object_p): New function. (elf_backend_object_p): Use that in elf64-x86-64-nacl definition. (elf32_x86_64_nacl_elf_object_p): New function. (elf_backend_object_p): Use that in elf32-x86-64-nacl definition. binutils/ * objdump.c (dump_dwarf): Grok bfd_mach_x86_64_nacl and bfd_mach_x64_32_nacl as equivalent to bfd_mach_x86_64. ld/testsuite/ * ld-x86-64/x86-64.exp (mixed1, mixed2): Loosen error string match so it accepts "i386:nacl" in place of "i386". * ld-x86-64/ilp32-2.d: Likewise. * ld-x86-64/ilp32-3.d: Likewise. * ld-x86-64/lp64-2.d: Likewise. * ld-x86-64/lp64-3.d: Likewise. (cherry picked from commit 64b384e1e821cedccefa24f6d5bb82d353546ca1) --- bfd/ChangeLog | 13 +++++++++++++ bfd/archures.c | 8 ++++---- bfd/bfd-in2.h | 8 ++++---- bfd/elf32-i386.c | 11 +++++++++++ bfd/elf64-x86-64.c | 20 +++++++++++++++++++- binutils/ChangeLog | 5 +++++ binutils/objdump.c | 2 ++ ld/testsuite/ChangeLog | 9 +++++++++ ld/testsuite/ld-x86-64/ilp32-2.d | 2 +- ld/testsuite/ld-x86-64/ilp32-3.d | 2 +- ld/testsuite/ld-x86-64/lp64-2.d | 2 +- ld/testsuite/ld-x86-64/lp64-3.d | 2 +- ld/testsuite/ld-x86-64/x86-64.exp | 4 ++-- 13 files changed, 73 insertions(+), 15 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index e9a2f287e9..3da57c0985 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,16 @@ +2013-11-07 Roland McGrath + + * archures.c (bfd_mach_i386_nacl): Fix definition so it doesn't + collide with bfd_mach_l1om. + * bfd-in2.h: Regenerate. + + * elf32-i386.c (elf32_i386_nacl_elf_object_p): New function. + (elf_backend_object_p): Use that in elf32-i386-nacl definition. + * elf64-x86-64.c (elf64_x86_64_nacl_elf_object_p): New function. + (elf_backend_object_p): Use that in elf64-x86-64-nacl definition. + (elf32_x86_64_nacl_elf_object_p): New function. + (elf_backend_object_p): Use that in elf32-x86-64-nacl definition. + 2013-11-01 Roland McGrath * elf-nacl.c (segment_eligible_for_headers): Drop requirement that diff --git a/bfd/archures.c b/bfd/archures.c index 53962bfa38..97c540abee 100644 --- a/bfd/archures.c +++ b/bfd/archures.c @@ -189,19 +189,19 @@ DESCRIPTION .#define bfd_mach_i386_i386 (1 << 2) .#define bfd_mach_x86_64 (1 << 3) .#define bfd_mach_x64_32 (1 << 4) -.#define bfd_mach_i386_nacl (1 << 5) .#define bfd_mach_i386_i386_intel_syntax (bfd_mach_i386_i386 | bfd_mach_i386_intel_syntax) .#define bfd_mach_x86_64_intel_syntax (bfd_mach_x86_64 | bfd_mach_i386_intel_syntax) .#define bfd_mach_x64_32_intel_syntax (bfd_mach_x64_32 | bfd_mach_i386_intel_syntax) -.#define bfd_mach_i386_i386_nacl (bfd_mach_i386_i386 | bfd_mach_i386_nacl) -.#define bfd_mach_x86_64_nacl (bfd_mach_x86_64 | bfd_mach_i386_nacl) -.#define bfd_mach_x64_32_nacl (bfd_mach_x64_32 | bfd_mach_i386_nacl) . bfd_arch_l1om, {* Intel L1OM *} .#define bfd_mach_l1om (1 << 5) .#define bfd_mach_l1om_intel_syntax (bfd_mach_l1om | bfd_mach_i386_intel_syntax) . bfd_arch_k1om, {* Intel K1OM *} .#define bfd_mach_k1om (1 << 6) .#define bfd_mach_k1om_intel_syntax (bfd_mach_k1om | bfd_mach_i386_intel_syntax) +.#define bfd_mach_i386_nacl (1 << 7) +.#define bfd_mach_i386_i386_nacl (bfd_mach_i386_i386 | bfd_mach_i386_nacl) +.#define bfd_mach_x86_64_nacl (bfd_mach_x86_64 | bfd_mach_i386_nacl) +.#define bfd_mach_x64_32_nacl (bfd_mach_x64_32 | bfd_mach_i386_nacl) . bfd_arch_we32k, {* AT&T WE32xxx *} . bfd_arch_tahoe, {* CCI/Harris Tahoe *} . bfd_arch_i860, {* Intel 860 *} diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index 41f7a682c3..ae3fd9b67d 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -1944,19 +1944,19 @@ enum bfd_architecture #define bfd_mach_i386_i386 (1 << 2) #define bfd_mach_x86_64 (1 << 3) #define bfd_mach_x64_32 (1 << 4) -#define bfd_mach_i386_nacl (1 << 5) #define bfd_mach_i386_i386_intel_syntax (bfd_mach_i386_i386 | bfd_mach_i386_intel_syntax) #define bfd_mach_x86_64_intel_syntax (bfd_mach_x86_64 | bfd_mach_i386_intel_syntax) #define bfd_mach_x64_32_intel_syntax (bfd_mach_x64_32 | bfd_mach_i386_intel_syntax) -#define bfd_mach_i386_i386_nacl (bfd_mach_i386_i386 | bfd_mach_i386_nacl) -#define bfd_mach_x86_64_nacl (bfd_mach_x86_64 | bfd_mach_i386_nacl) -#define bfd_mach_x64_32_nacl (bfd_mach_x64_32 | bfd_mach_i386_nacl) bfd_arch_l1om, /* Intel L1OM */ #define bfd_mach_l1om (1 << 5) #define bfd_mach_l1om_intel_syntax (bfd_mach_l1om | bfd_mach_i386_intel_syntax) bfd_arch_k1om, /* Intel K1OM */ #define bfd_mach_k1om (1 << 6) #define bfd_mach_k1om_intel_syntax (bfd_mach_k1om | bfd_mach_i386_intel_syntax) +#define bfd_mach_i386_nacl (1 << 7) +#define bfd_mach_i386_i386_nacl (bfd_mach_i386_i386 | bfd_mach_i386_nacl) +#define bfd_mach_x86_64_nacl (bfd_mach_x86_64 | bfd_mach_i386_nacl) +#define bfd_mach_x64_32_nacl (bfd_mach_x64_32 | bfd_mach_i386_nacl) bfd_arch_we32k, /* AT&T WE32xxx */ bfd_arch_tahoe, /* CCI/Harris Tahoe */ bfd_arch_i860, /* Intel 860 */ diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index 560e05cc4f..cfb417ad37 100644 --- a/bfd/elf32-i386.c +++ b/bfd/elf32-i386.c @@ -5295,9 +5295,19 @@ static const struct elf_i386_backend_data elf_i386_nacl_arch_bed = 0, /* is_vxworks */ }; +static bfd_boolean +elf32_i386_nacl_elf_object_p (bfd *abfd) +{ + /* Set the right machine number for a NaCl i386 ELF32 file. */ + bfd_default_set_arch_mach (abfd, bfd_arch_i386, bfd_mach_i386_i386_nacl); + return TRUE; +} + #undef elf_backend_arch_data #define elf_backend_arch_data &elf_i386_nacl_arch_bed +#undef elf_backend_object_p +#define elf_backend_object_p elf32_i386_nacl_elf_object_p #undef elf_backend_modify_segment_map #define elf_backend_modify_segment_map nacl_modify_segment_map #undef elf_backend_modify_program_headers @@ -5308,6 +5318,7 @@ static const struct elf_i386_backend_data elf_i386_nacl_arch_bed = #include "elf32-target.h" /* Restore defaults. */ +#undef elf_backend_object_p #undef elf_backend_modify_segment_map #undef elf_backend_modify_program_headers #undef elf_backend_final_write_processing diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c index f748641ea8..43861e77ce 100644 --- a/bfd/elf64-x86-64.c +++ b/bfd/elf64-x86-64.c @@ -5347,6 +5347,14 @@ static const struct bfd_elf_special_section /* Native Client support. */ +static bfd_boolean +elf64_x86_64_nacl_elf_object_p (bfd *abfd) +{ + /* Set the right machine number for a NaCl x86-64 ELF64 file. */ + bfd_default_set_arch_mach (abfd, bfd_arch_i386, bfd_mach_x86_64_nacl); + return TRUE; +} + #undef TARGET_LITTLE_SYM #define TARGET_LITTLE_SYM bfd_elf64_x86_64_nacl_vec #undef TARGET_LITTLE_NAME @@ -5479,6 +5487,8 @@ static const struct elf_x86_64_backend_data elf_x86_64_nacl_arch_bed = #undef elf_backend_arch_data #define elf_backend_arch_data &elf_x86_64_nacl_arch_bed +#undef elf_backend_object_p +#define elf_backend_object_p elf64_x86_64_nacl_elf_object_p #undef elf_backend_modify_segment_map #define elf_backend_modify_segment_map nacl_modify_segment_map #undef elf_backend_modify_program_headers @@ -5490,6 +5500,14 @@ static const struct elf_x86_64_backend_data elf_x86_64_nacl_arch_bed = /* Native Client x32 support. */ +static bfd_boolean +elf32_x86_64_nacl_elf_object_p (bfd *abfd) +{ + /* Set the right machine number for a NaCl x86-64 ELF32 file. */ + bfd_default_set_arch_mach (abfd, bfd_arch_i386, bfd_mach_x64_32_nacl); + return TRUE; +} + #undef TARGET_LITTLE_SYM #define TARGET_LITTLE_SYM bfd_elf32_x86_64_nacl_vec #undef TARGET_LITTLE_NAME @@ -5510,7 +5528,7 @@ static const struct elf_x86_64_backend_data elf_x86_64_nacl_arch_bed = #undef elf_backend_object_p #define elf_backend_object_p \ - elf32_x86_64_elf_object_p + elf32_x86_64_nacl_elf_object_p #undef elf_backend_bfd_from_remote_memory #define elf_backend_bfd_from_remote_memory \ diff --git a/binutils/ChangeLog b/binutils/ChangeLog index a8ddd22f79..bc1ace9d50 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,8 @@ +2013-11-07 Roland McGrath + + * objdump.c (dump_dwarf): Grok bfd_mach_x86_64_nacl and + bfd_mach_x64_32_nacl as equivalent to bfd_mach_x86_64. + 2013-10-31 Nick Clifton * nm.c (display_rel_file): Treat bfd_error_no_symbols as diff --git a/binutils/objdump.c b/binutils/objdump.c index 89efc155fb..cfd08e935c 100644 --- a/binutils/objdump.c +++ b/binutils/objdump.c @@ -2395,8 +2395,10 @@ dump_dwarf (bfd *abfd) { case bfd_mach_x86_64: case bfd_mach_x86_64_intel_syntax: + case bfd_mach_x86_64_nacl: case bfd_mach_x64_32: case bfd_mach_x64_32_intel_syntax: + case bfd_mach_x64_32_nacl: init_dwarf_regnames_x86_64 (); break; diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index 0f4a60d1e3..17b671e690 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,12 @@ +2013-11-07 Roland McGrath + + * ld-x86-64/x86-64.exp (mixed1, mixed2): Loosen error string match + so it accepts "i386:nacl" in place of "i386". + * ld-x86-64/ilp32-2.d: Likewise. + * ld-x86-64/ilp32-3.d: Likewise. + * ld-x86-64/lp64-2.d: Likewise. + * ld-x86-64/lp64-3.d: Likewise. + 2013-11-01 Roland McGrath * ld-x86-64/plt-nacl.pd: Update expected disassembly for PLT nop fix. diff --git a/ld/testsuite/ld-x86-64/ilp32-2.d b/ld/testsuite/ld-x86-64/ilp32-2.d index 65b5298457..fde3e8af49 100644 --- a/ld/testsuite/ld-x86-64/ilp32-2.d +++ b/ld/testsuite/ld-x86-64/ilp32-2.d @@ -1,4 +1,4 @@ #source: dummy.s #as: --x32 #ld: -m elf32_x86_64 tmpdir/startx32.o tmpdir/foo32.o -#error: .*i386 architecture of input file `tmpdir/foo32.o' is incompatible with i386:x64-32.* output +#error: .*i386(:.+)? architecture of input file `tmpdir/foo32.o' is incompatible with i386:x64-32.* output diff --git a/ld/testsuite/ld-x86-64/ilp32-3.d b/ld/testsuite/ld-x86-64/ilp32-3.d index b05e531c60..a9080a0561 100644 --- a/ld/testsuite/ld-x86-64/ilp32-3.d +++ b/ld/testsuite/ld-x86-64/ilp32-3.d @@ -1,4 +1,4 @@ #source: dummy.s #as: --x32 #ld: -m elf32_x86_64 tmpdir/startx32.o tmpdir/foo64.o -#error: .*i386:x86-64 architecture of input file `tmpdir/foo64.o' is incompatible with i386:x64-32.* output +#error: .*i386:x86-64(:.+)? architecture of input file `tmpdir/foo64.o' is incompatible with i386:x64-32.* output diff --git a/ld/testsuite/ld-x86-64/lp64-2.d b/ld/testsuite/ld-x86-64/lp64-2.d index 7515881a8b..af7582ad99 100644 --- a/ld/testsuite/ld-x86-64/lp64-2.d +++ b/ld/testsuite/ld-x86-64/lp64-2.d @@ -1,4 +1,4 @@ #source: dummy.s #as: --64 #ld: -m elf_x86_64 tmpdir/start64.o tmpdir/foo32.o -#error: .*i386 architecture of input file `tmpdir/foo32.o' is incompatible with i386:x86-64.* output +#error: .*i386(:.+)? architecture of input file `tmpdir/foo32.o' is incompatible with i386:x86-64.* output diff --git a/ld/testsuite/ld-x86-64/lp64-3.d b/ld/testsuite/ld-x86-64/lp64-3.d index e60efeb935..0e995c87c2 100644 --- a/ld/testsuite/ld-x86-64/lp64-3.d +++ b/ld/testsuite/ld-x86-64/lp64-3.d @@ -1,4 +1,4 @@ #source: dummy.s #as: --64 #ld: -m elf_x86_64 tmpdir/start64.o tmpdir/foox32.o -#error: .*i386:x64-32 architecture of input file `tmpdir/foox32.o' is incompatible with i386:x86-64.* output +#error: .*i386:x64-32(:.+)? architecture of input file `tmpdir/foox32.o' is incompatible with i386:x86-64.* output diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp index 3ddce846be..32927b6129 100644 --- a/ld/testsuite/ld-x86-64/x86-64.exp +++ b/ld/testsuite/ld-x86-64/x86-64.exp @@ -172,7 +172,7 @@ global ld set test_name "Mixed x86_64 and i386 input test 1" set test mixed1 if { ![ld_simple_link $ld tmpdir/$test "-m$emul 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] { + 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" @@ -182,7 +182,7 @@ if { ![ld_simple_link $ld tmpdir/$test "-m$emul tmpdir/${test}a.o tmpdir/${test} set test_name "Mixed x86_64 and i386 input test 2" set test mixed2 if { ![ld_simple_link $ld tmpdir/$test "-m$emul 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] { + 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" -- cgit v1.2.1