arm-elf-gcc problem
From: Steffen Lutzmann (steffen.lutzmann_at_web.de)
Date: 06/24/04
- Next message: Paul Burke: "Re: Microcontroller with 4x16 Bit Timers"
- Previous message: Grant Edwards: "Re: Quick Q regarding Ethernet"
- Next in thread: Pablo Bleyer Kocik: "Re: arm-elf-gcc problem"
- Reply: Pablo Bleyer Kocik: "Re: arm-elf-gcc problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 24 Jun 2004 16:28:10 +0200
Hi group,
I'm a newbie regarding the GNU ARM stuff.
After many trials with intensive studying of the manuals for the gnu
linker and assembler I have no more idea to solve the following problem:
I want to compile and link a very simple main.c with startup code and
linker script (see below my sample files, its for ARM7TDMI). The linker,
invoked by arm-elf-gcc, can't find the entry point symbol, which is
referenced in my linker script and defined in the startup code as
.global. The linker complains with:
arm-elf-gcc -nostartfiles -Wl,-Map=mapfile.map
-Wl,--script=my_linker_script -Wl,-cref cstartup.o main.o -o
main.elf
/gnuarm/bin/../lib/gcc-lib/arm-elf/3.3.3/../../../../arm-elf/bin/ld:
warning: cannot find entry symbol __main; defaulting to 04000000
This is confusing because '__main' is defined as '.global' in the
startup file. Did I miss something in the makefile? Hope anybody can
give me hint.
Thanks in advance
Steffen
The startup code fragment:
--------------------------
.include "../at91lib_gnu/periph/arm7tdmi/arm.inc"
.include "phycore.inc"
/******************************
code entry point
******************************/
/* Define "__main" to ensure that C runtime system is not linked */
.global __main
/* Exception vectors (before Remap) */
__main:
B InitReset /* reset */
undefvec:
B undefvec /* Undefined Instruction */
swivec:
B swivec /* Software Interrupt */
pabtvec:
B pabtvec /* Prefetch Abort */
dabtvec:
B dabtvec /* Data Abort */
rsvdvec:
B rsvdvec /* reserved */
irqvec:
B irqvec /* reserved */
fiqvec:
B fiqvec /* reserved */
/* EBI Initialization Data */
InitTableEBI:
.word EBI_CSR_0
.word EBI_CSR_1
.word EBI_CSR_2
.word EBI_CSR_3
.word EBI_CSR_4
.word EBI_CSR_5
.word EBI_CSR_6
.word EBI_CSR_7
.word 0x00000001 /* REMAP command */
.word 0x00000006 /* memory regions, standard read */
PtEBIBase:
.word EBI_BASE /* EBI Base Address */
/*
The reset handler before Remap
From here, the code is executed from SRAM address
Exporting labels used in other files
*/
InitReset:
/*
Load System EBI Base address and CSR0 Init Value
*/
ldr r0, PtEBIBase
ldr r1, InitTableEBI
/*- Speed up code execution by disabling wait state on Chip Select 0*/
str r1, [r0]
bl __low_level_init
...and so on...
pretty simple main.c:
-----------------------
int main(void)
{
int a,b;
volatile int my_var;
a=10;
b=20;
my_var=a+b;
return 0;
}
my linker script:
-----------------------
ENTRY(__main)
MEMORY
{
int_ram : org = 0x00000000, len = 8K /* internal RAM */
ram : org = 0x04000000, len = 1024K /* RAM at CS1 */
}
SECTIONS
{
.startup :
{
cstartup.o;
*(.glue_7t);
*(.glue_7);
*(.rdata);
*(.fini);
} > int_ram
.text :
{
main.o;
*(.text);
} > ram
.data :
{
*(.data);
} > ram
.bss :
{
*(.bss) *(COMMON);
} > ram
}
my makefile:
---------------------------
CC = arm-elf-gcc
AS = arm-elf-as
INC =
INC += -I ../at91lib_gnu
ASM.FILES =
ASM.FILES += cstartup.S
ASM.FLAGS +=
ASM.FLAGS += -mthumb-interwork
ASM.FLAGS += -mcpu=arm7tdmi
ASM.FLAGS += -gstabs
C.FILES = main.c
C.FLAGS +=
C.FLAGS += -c
C.FLAGS += -g
C.FLAGS += -mcpu=arm7tdmi
C.FLAGS += -mthumb-interwork
L.FLAGS =
L.FLAGS += -nostartfiles
L.FLAGS += -Wl,-Map=mapfile.map
L.FLAGS += -Wl,--script=my_linker_script
L.FLAGS += -Wl,-cref
OBJ =
OBJ += $(patsubst %.S,%.o,$(ASM.FILES))
OBJ += $(patsubst %.c,%.o,$(C.FILES))
%.o : %.S makefile
$(AS) $(INC) $(ASM.FLAGS) $< -o $@
%.o : %.c makefile
$(CC) $(INC) $(C.FLAGS) $< -o $@
all: $(OBJ)
exec: $(OBJ)
$(CC) $(L.FLAGS) $(OBJ) -o main.elf
clean:
rm *.o
rm *.elf
rm *.map
-- http://www.da0hq.de
- Next message: Paul Burke: "Re: Microcontroller with 4x16 Bit Timers"
- Previous message: Grant Edwards: "Re: Quick Q regarding Ethernet"
- Next in thread: Pablo Bleyer Kocik: "Re: arm-elf-gcc problem"
- Reply: Pablo Bleyer Kocik: "Re: arm-elf-gcc problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|