This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Linking against armlink produced ELF for armv6-m (thumb only) CPU


Hi,

I have found no good solution to this problem. Can anyone help?

We have a ROM image produced by RVCT toolchain: armlink produces .axf
-file which is in ELF-format. Now we would like to create an executable
to the RAM by using the GNU-toolchain. Those RAM-executables should of
course link against functions in ROM.

If I have understood everything right the correct way to do this is to
link against this armlink produced ELF-file by using option
"--just-symbols=romimagefile.elf".

Everything works when I link against a ROM image ELF-file produced by
the ld -linker, but when I link against armlink -produced ELF-file the
following happens:

Build finishes, but in the ld -linker prints out a following error
message: "Conflicting CPU architectures 11/0". Also the veneers
generated by the ld -linker seem to contain ARM-instructions although we
have a thumb-only CPU architecture (armv6-m).

Binutils ld -linker does not seem to have any command line options to
select or force certain arm-architecture like armlink does. If I
understood right, it is doing the guessing based on the .ARM.attributes
-sections in the input files. I have examined differences in the ld and
armlink produced ELF-files and it seems that armlink does not put
.ARM.attributes -section into the ELF-file like ld does. When the
.ARM.attributes -section is missing the ld -linker assumes the
architecture of that file is "TAG_CPU_ARCH_PRE_V4" (which equals 0 in
arm.h), and generates veneers according to that. And of course our
thumb-only CPU raises an exception when it meets an arm instruction in
the veneer.

Because I have found no way to enable armlink to generate
.ARM.attributes -section to the ELF-file and ld does not work in the
desired way without this information I'am in a dead end.

To work around the problem I have tried to copy an .ARM.attributes
-section from ld generated ELF to armlink generated ELF by using
binutils objcopy with option --add-section, but I have found no way to
set the section type to ARM_ATTRIBUTES, which seems to be required by
the ld -linker.

I have also tried to refer to the ROM symbols by introducing them in a
linker script -file, but the problem is that there is no way to tell ld
that these symbols refer to thumb-code and again the linker is
generating veneers containing arm instructions.

The binutils I'am using is a self compiled CVS snapshot:
"GNU ld (GNU Binutils) 2.20.51.20100802"

The only way I have managed to create a working executable is to modify
the ld -linkers 'using_thumb_only' -function in elf32-arm.c to return
always true, which of course is not an sustainable solution in the long
term.

Is there something I have not found by myself I could try or is this
problem right now a compatibility problem with no solution?

What would be the best solution in the long term?

	Heikki K.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]