This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Linking against armlink produced ELF for armv6-m (thumb only) CPU
On 9.8.2010 15:39, Matthew Gretton-Dann wrote:
> Hi,
>
> On Mon, 2010-08-09 at 15:09 +0300, Heikki Keränen wrote:
>> 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.
[snip]
>> 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).
>
> Can you give some sample command lines (I don't think objects are
> necessary at the moment) please?
Here is my very simple example project I used to reproduce this issue:
----- simple_rom_rvct\simple_rom.h ---------
#ifndef SIMPLE_ROM_H
#define SIMPLE_ROM_H
int simple_rom_function(int param);
#endif // SIMPLE_ROM_H
-------------------------------------------
---- simple_rom_rvct\simple_rom.c ----------
#include "simple_rom.h"
int simple_rom_function(int param)
{
return param + 1;
}
-------------------------------------------
----- simple_ram\simple_ram.c -------------
#include "../simple_rom/simple_rom.h"
int mainfunction(void)
{
int result;
result = simple_rom_function(1);
return result;
}
------------------------------------------
----- simple_ram\simple_ram.ld -----------
MEMORY
{
MYROM (rx) : ORIGIN = 0x10000000, LENGTH = 0x00008000
MYRAM (rwxa) : ORIGIN = 0x30000000, LENGTH = 0xf0000000
}
SECTIONS
{
.text : { *(.text) } >MYRAM
.data : { *(.data) } >MYRAM
.bss : { *(.bss) } >MYRAM
}
--------------------------------------------
>
> What I am looking for are examples of how you call armcc, armlink, gcc,
> and ld.
------ RVCT build output (form uVision IDE) -------
Build target 'Target 1'
compiling simple_rom.c...
simple_rom.c: [ArmCC --show_cmdline --debug -c -osimple_rom.o
--depend=simple_rom.d --cpu=Cortex-M0 --apcs=interwork -O0
-IC:\Keil\ARM\INC -IC:\Keil\ARM\INC\ARM --omf_browse=simple_rom.crf
simple_rom.c]
linking...
simple_rom.axf: [ArmLink --show_cmdline --strict
--diag_suppress=6320,6305 --ro_base=0x0 --rw_base=0x0 --cpu=Cortex-M0
--first=__Vectors --output=simple_rom.axf --entry=Reset_Handler
--keep=.ARM.attributes --info=summarysizes simple_rom.o]
Program Size: Code=8 RO-data=0 RW-data=0 ZI-data=0
FromELF: creating hex file...
"simple_rom.axf" - 0 Error(s), 0 Warning(s).
----------------------------------------------------
------- GNU toolchain output (from Eclipse) -------
make all
Building file: simple_ram.c
Invoking: arm-none-eabi-gcc C Compiler
arm-none-eabi-gcc -Os -Wall -c -fmessage-length=0 -MD -MF"simple_ram.d"
-MT"simple_ram.d" -mcpu=cortex-m0 -fpic -mthumb -o"simple_ram.o"
"simple_ram.c"
Finished building: simple_ram.c
Building target: simple_ram.elf
Invoking: arm-none-eabi-gcc C Linker
arm-none-eabi-gcc -T"simple_ram.ld" -nostartfiles
-Wl,--architecture=armv6-m --pic-executable -mcpu=cortex-m0
--strip-debug -o"simple_ram.elf" ./simple_ram.o
-Wl,--just-symbols=../simple_rom_rvct/simple_rom.axf
c:/msys/1.0/home/heikki/arm-none-eabi/bin/../lib/gcc/arm-none-eabi/4.5.0/../../../../arm-none-eabi/bin/ld.exe:
error: ../simple_rom_rvct/simple_rom.axf: Conflicting CPU architectures 11/0
Finished building target: simple_ram.elf
-------------------------------------------------
>
> Can you also give the results of readelf -A when run on the armlink
> produced image and also one of the gcc produced objects you are trying
> to link against?
D:\simple_rom_rvct>arm-none-eabi-readelf -A simple_rom.axf
< NOTE: no output here, since .axf does not contain .ARM.attributes? >
D:\simple_ram>arm-none-eabi-readelf -A simple_ram.o
Attribute Section: aeabi
File Attributes
Tag_CPU_name: "CORTEX-M0"
Tag_CPU_arch: v6-M
Tag_CPU_arch_profile: Microcontroller
Tag_THUMB_ISA_use: Thumb-1
Tag_ABI_PCS_wchar_t: 4
Tag_ABI_FP_denormal: Needed
Tag_ABI_FP_exceptions: Needed
Tag_ABI_FP_number_model: IEEE 754
Tag_ABI_align_needed: 8-byte
Tag_ABI_align_preserved: 8-byte, except leaf SP
Tag_ABI_enum_size: small
Tag_ABI_optimization_goals: Aggressive Size
Tag_DIV_use: Not allowed
>
> What version of RVCT are you using (what is the result of armlink
> --vsn)?
ARM Linker, RVCT4.0 [Build 728] [Standard]
[snip]
> If you can answer the questions above we might be able to give a good
> answer to your question.
>
> Thanks,
>
> Matt
Here should be all the information you asked. I can provide additional
details if required. I have tried a large number of compiler and linker
options so some of those options I used are probably unnecessary or stupid.
Thanks for taking a look into this issue,
Heikki K.