public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Linking against armlink produced ELF for armv6-m (thumb only) CPU
@ 2010-08-09 12:39 Heikki Keränen
  2010-08-09 15:42 ` Matthew Gretton-Dann
  0 siblings, 1 reply; 7+ messages in thread
From: Heikki Keränen @ 2010-08-09 12:39 UTC (permalink / raw)
  To: binutils


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.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-07-12  9:43 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-09 12:39 Linking against armlink produced ELF for armv6-m (thumb only) CPU Heikki Keränen
2010-08-09 15:42 ` Matthew Gretton-Dann
2010-08-09 18:09   ` Heikki Keränen
2010-08-10 21:17     ` Matthew Gretton-Dann
2011-07-05 18:21       ` GusSabina
2011-07-06 14:58         ` Matthew Gretton-Dann
     [not found]           ` <1310448299.35910.YahooMailRC@web34301.mail.mud.yahoo.com>
2011-07-12 22:33             ` Matthew Gretton-Dann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).