From 70e99720f9d558263756a482ae750b263ffd92ba Mon Sep 17 00:00:00 2001 From: Terry Guo Date: Tue, 16 Sep 2014 13:08:22 +0100 Subject: Make the linker return an error status if it fails to merge ARM binaries with different architecture tags. Add a test case to make sure that this works, and update readelf so that it will not seg-fault when trying to display the attributes of binaries with invalid architecture tags. * elf32-arm.c (elf32_arm_merge_eabi_attributes): Return false if failed to merge. * ld-arm/attr-merge-arch-2.d: New test case. * ld-arm/attr-merge-arch-2a.s: New test case source file. * ld-arm/attr-merge-arch-2b.s: Likewise. * ld-arm/arm-elf.exp: Run new test case. * readelf.c (display_arm_attribute): Use unsigned int type for tag, val and type variables. --- ld/testsuite/ChangeLog | 7 +++++++ ld/testsuite/ld-arm/arm-elf.exp | 1 + ld/testsuite/ld-arm/attr-merge-arch-2.d | 5 +++++ ld/testsuite/ld-arm/attr-merge-arch-2a.s | 18 ++++++++++++++++++ ld/testsuite/ld-arm/attr-merge-arch-2b.s | 8 ++++++++ 5 files changed, 39 insertions(+) create mode 100644 ld/testsuite/ld-arm/attr-merge-arch-2.d create mode 100644 ld/testsuite/ld-arm/attr-merge-arch-2a.s create mode 100644 ld/testsuite/ld-arm/attr-merge-arch-2b.s (limited to 'ld/testsuite') diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index f5aef2a..556ee1a 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2014-09-16 Terry Guo + + * ld-arm/attr-merge-arch-2.d: New test case. + * ld-arm/attr-merge-arch-2a.s: New test case source file. + * ld-arm/attr-merge-arch-2b.s: Likewise. + * ld-arm/arm-elf.exp: Run new test case. + 2014-09-12 Andrew Bennett * ld-mips-elf/mips-elf.exp: Add support for mips*-img-elf* target diff --git a/ld/testsuite/ld-arm/arm-elf.exp b/ld/testsuite/ld-arm/arm-elf.exp index f971afc..3c8cc68 100644 --- a/ld/testsuite/ld-arm/arm-elf.exp +++ b/ld/testsuite/ld-arm/arm-elf.exp @@ -878,6 +878,7 @@ run_dump_test "attr-merge-vfp-6r" run_dump_test "attr-merge-vfp-7" run_dump_test "attr-merge-vfp-7r" run_dump_test "attr-merge-incompatible" +run_dump_test "attr-merge-arch-2" run_dump_test "unresolved-1" if { ![istarget "arm*-*-nacl*"] } { run_dump_test "unresolved-1-dyn" diff --git a/ld/testsuite/ld-arm/attr-merge-arch-2.d b/ld/testsuite/ld-arm/attr-merge-arch-2.d new file mode 100644 index 0000000..0e98edb --- /dev/null +++ b/ld/testsuite/ld-arm/attr-merge-arch-2.d @@ -0,0 +1,5 @@ +#source: attr-merge-arch-2a.s +#source: attr-merge-arch-2b.s +#as: +#ld: -e main +#error: Conflicting CPU architectures 13/0 diff --git a/ld/testsuite/ld-arm/attr-merge-arch-2a.s b/ld/testsuite/ld-arm/attr-merge-arch-2a.s new file mode 100644 index 0000000..6235a3e --- /dev/null +++ b/ld/testsuite/ld-arm/attr-merge-arch-2a.s @@ -0,0 +1,18 @@ + .syntax unified + .cpu cortex-m4 + .fpu softvfp + .thumb + .file "m.c" + .text + .align 2 + .global main + .thumb + .thumb_func + .type main, %function +main: + push {r7, lr} + add r7, sp, #0 + bl foo + mov r3, r0 + mov r0, r3 + pop {r7, pc} diff --git a/ld/testsuite/ld-arm/attr-merge-arch-2b.s b/ld/testsuite/ld-arm/attr-merge-arch-2b.s new file mode 100644 index 0000000..5771835 --- /dev/null +++ b/ld/testsuite/ld-arm/attr-merge-arch-2b.s @@ -0,0 +1,8 @@ + .eabi_attribute 6, 0 @Tag_CPU_arch, 0 means pre-v4. + .file "f.c" + .text + .align 2 + .global foo + .type foo, %function +foo: + bx lr -- cgit v1.1