aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf32-arm.c
diff options
context:
space:
mode:
authorRichard Earnshaw <Richard.Earnshaw@arm.com>2017-06-08 15:11:44 +0100
committerRichard Earnshaw <Richard.Earnshaw@arm.com>2017-06-08 15:11:44 +0100
commit4ec192e6abe86319b9e9af6f2ae4cf0614b1e2b3 (patch)
tree28d1f146c36a11f8c670036ec1d9b2d6995d2052 /bfd/elf32-arm.c
parentff4ca5ac6a2e85177dc7efe5cbda7b956bb71fd5 (diff)
downloadgdb-4ec192e6abe86319b9e9af6f2ae4cf0614b1e2b3.zip
gdb-4ec192e6abe86319b9e9af6f2ae4cf0614b1e2b3.tar.gz
gdb-4ec192e6abe86319b9e9af6f2ae4cf0614b1e2b3.tar.bz2
[bfd][arm] Don't assert on suspicious build attributes in input file
It's generally a bad idea to use assertions to validate our idea of what an input file looks like. We need to be as liberal as possible in what we accept with respect to standards and conservative with what we produce. Currently, if gcc is used to produce an assembler file which contains only data, but the FPU is set to fpv4-sp-d16 and mfloat-abi=hard, then the following attributes will be set in the output: .cpu arm7tdmi .eabi_attribute 27, 1 @ Tag_ABI_HardFP_use .eabi_attribute 28, 1 @ Tag_ABI_VFP_args .eabi_attribute 20, 1 @ Tag_ABI_FP_denormal .eabi_attribute 21, 1 @ Tag_ABI_FP_exceptions .eabi_attribute 23, 3 @ Tag_ABI_FP_number_model .eabi_attribute 24, 1 @ Tag_ABI_align8_needed .eabi_attribute 25, 1 @ Tag_ABI_align8_preserved .eabi_attribute 26, 2 @ Tag_ABI_enum_size .eabi_attribute 30, 6 @ Tag_ABI_optimization_goals .eabi_attribute 34, 0 @ Tag_CPU_unaligned_access .eabi_attribute 18, 4 @ Tag_ABI_PCS_wchar_t There is then no .fpu directive to cause Tag_FP_arch to be set, because there are no functions containing code in the object file. If this object file is assembled by hand, but without -mfpu on the invocation of the assembler, then the build attributes produced will trigger an assertion during linking. Thinking about the build attributes, the combination of a single-precision only implementation of no floating-point architecture is still no floating-point architecture. Hence the assertion on the input BFD in the linker makes no real sense. We should, however, be more conservative in what we generate, so I've left the assertion on the output bfd in place; I don't think we can trigger it with this change since we never merge the problematic tags from a perversely generated input file. * elf32-arm.c (elf32_arm_merge_eabi_attributes): Remove assertion that the input bfd has Tag_FP_ARCH non-zero if Tag_ABI_HardFP_use is non-zero. Add clarifying comments.
Diffstat (limited to 'bfd/elf32-arm.c')
-rw-r--r--bfd/elf32-arm.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index 9cd34ca..3bfe312 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -13825,6 +13825,9 @@ elf32_arm_merge_eabi_attributes (bfd *ibfd, struct bfd_link_info *info)
follow the requirement of the input. */
if (out_attr[i].i == 0)
{
+ /* This assert is still reasonable, we shouldn't
+ produce the suspicious build attribute
+ combination (See below for in_attr). */
BFD_ASSERT (out_attr[Tag_ABI_HardFP_use].i == 0);
out_attr[i].i = in_attr[i].i;
out_attr[Tag_ABI_HardFP_use].i
@@ -13835,7 +13838,13 @@ elf32_arm_merge_eabi_attributes (bfd *ibfd, struct bfd_link_info *info)
nothing. */
else if (in_attr[i].i == 0)
{
- BFD_ASSERT (in_attr[Tag_ABI_HardFP_use].i == 0);
+ /* We used to assert that Tag_ABI_HardFP_use was
+ zero here, but we should never assert when
+ consuming an object file that has suspicious
+ build attributes. The single precision variant
+ of 'no FP architecture' is still 'no FP
+ architecture', so we just ignore the tag in this
+ case. */
break;
}