diff options
author | Terry Guo <terry.guo@arm.com> | 2014-09-16 13:08:22 +0100 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2014-09-16 13:08:22 +0100 |
commit | 70e99720f9d558263756a482ae750b263ffd92ba (patch) | |
tree | 893354caf187ada3cfa61d98392b320a99d324ea /bfd/elf32-arm.c | |
parent | 428b16bd5a3947e3a608f0c6751a8be7dbd88959 (diff) | |
download | gdb-70e99720f9d558263756a482ae750b263ffd92ba.zip gdb-70e99720f9d558263756a482ae750b263ffd92ba.tar.gz gdb-70e99720f9d558263756a482ae750b263ffd92ba.tar.bz2 |
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.
Diffstat (limited to 'bfd/elf32-arm.c')
-rw-r--r-- | bfd/elf32-arm.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index 89d51c1..08aa3f9 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -11778,7 +11778,9 @@ elf32_arm_merge_eabi_attributes (bfd *ibfd, bfd *obfd) { int secondary_compat = -1, secondary_compat_out = -1; unsigned int saved_out_attr = out_attr[i].i; - static const char *name_table[] = { + int arch_attr; + static const char *name_table[] = + { /* These aren't real CPU names, but we can't guess that from the architecture version alone. */ "Pre v4", @@ -11800,10 +11802,17 @@ elf32_arm_merge_eabi_attributes (bfd *ibfd, bfd *obfd) /* Merge Tag_CPU_arch and Tag_also_compatible_with. */ secondary_compat = get_secondary_compatible_arch (ibfd); secondary_compat_out = get_secondary_compatible_arch (obfd); - out_attr[i].i = tag_cpu_arch_combine (ibfd, out_attr[i].i, - &secondary_compat_out, - in_attr[i].i, - secondary_compat); + arch_attr = tag_cpu_arch_combine (ibfd, out_attr[i].i, + &secondary_compat_out, + in_attr[i].i, + secondary_compat); + + /* Return with error if failed to merge. */ + if (arch_attr == -1) + return FALSE; + + out_attr[i].i = arch_attr; + set_secondary_compatible_arch (obfd, secondary_compat_out); /* Merge Tag_CPU_name and Tag_CPU_raw_name. */ |