Bug 11897 - Linking of objects with and without attributes sections is incorrect
Summary: Linking of objects with and without attributes sections is incorrect
Status: ASSIGNED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.21
: P2 normal
Target Milestone: ---
Assignee: Matthew Gretton-Dann
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-10 09:24 UTC by Matthew Gretton-Dann
Modified: 2010-08-10 09:25 UTC (History)
1 user (show)

See Also:
Host:
Target: arm-none-eabi
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matthew Gretton-Dann 2010-08-10 09:24:36 UTC
Take the following two test files:

@ test1.s
	.syntax unified
	.thumb
	.global foo
foo:
	bx lr
@ end of test1.s

@ test2.s
	.syntax unified
	.thumb
	.cpu cortex-m0

bar:
	bl foo
@ end of test2.s

Build as follows:
arm-none-eabi-as test1.s -o test1.o
arm-none-eabi-as test2.s -o test2.o
arm-none-eabi-objcopy -R '.ARM.attributes' test1.o test1.stripped.o
arm-non-ld test1.stripped.o test2.o -o test.axf

ld reports:

.../arm-none-eabi-ld: error: test2.o: Conflicting CPU architectures 0/11

The ABI is silent on the behaviour expected in this case but to ensure backwards
compatibility we should allow such objects to link together.

The basic issue seems to be that we are treating an object with no
.ARM.attributes section as one where all the attributes take their default value
(0 or "") and not one which has all the attributes set to undefined (as if a
TAG_nodefaults attribute was present), and hence compatible with all other objects.