EmbDev.net

Forum: ARM programming with GCC/GNU tools Why isn't the linker working?


von noether (Guest)


Rate this post
useful
not useful
Hello, i moved to arm-none-linux-gnueabi toolchain (Sourcery), and i'm 
trying
to modify an old makefile (gnuarm-4.0.2) without any success at linking.

Previously i used the ld, but now i want to delegate this work to the 
compiler.

Here it is my Makefile:
1
NAME = truck
2
3
# variables 
4
CC      = arm-none-linux-gnueabi-gcc
5
LD      = arm-none-linux-gnueabi-ld -v
6
AR      = arm-none-linux-gnueabi-ar
7
AS      = arm-none-linux-gnueabi-as
8
CP      = arm-none-linux-gnueabi-objcopy
9
OD    = arm-none-linux-gnueabi-objdump
10
11
# LIBM = /home/noether/workspace/ARM7//gnuarm-4.0.2/arm-elf/lib/libm.a
12
# LIBGCC = /home/noether/workspace/ARM7/gnuarm-4.0.2/lib/gcc/arm-elf/4.0.2/libgcc.a
13
14
CFLAGS  = -I./ -mcpu=arm7tdmi -c -fno-common -Os -g
15
AFLAGS  = -ahls -mapcs-32 -o crt.o
16
LFLAGS  = -Map main.map -Ttruck.cmd
17
CPFLAGS = --output-target=binary
18
ODFLAGS  = -x --syms
19
20
OBJECTS = crt.o  main.o timer.o misc.o tsip.o adc.o spi.o gps.o geomag.o isrsupport.o lowlevelinit.o 
21
22
all:  main.out
23
  @ echo "...copying"
24
  $(CP) $(CPFLAGS) main.out main.bin
25
  $(OD) $(ODFLAGS) main.out > main.dmp
26
27
clean:
28
  -$(RM) $(OBJECTS) crt.lst main.out main.bin main.map main.dmp
29
30
31
32
main.out: $(OBJECTS) truck.cmd 
33
  @ echo "..linking"
34
LINK--------->  $(CC) $(CFLAGS) $(OBJECTS) -o main.out $(LFLAGS) -lm -lgcc 
35
  
36
37
38
crt.o: crt.s
39
  @ echo ".assembling"
40
  $(AS) $(AFLAGS) crt.s > crt.lst
41
42
main.o: main.c
43
  @ echo ".compiling"
44
  $(CC) $(CFLAGS) main.c
45
  
46
timer.o: timer.c
47
  @echo ".compiling"
48
  $(CC) $(CFLAGS) timer.c
49
  
50
misc.o: misc.c
51
  @echo ".compiling"
52
  $(CC) $(CFLAGS) misc.c
53
  
54
tsip.o: tsip.c
55
  @echo ".compiling"
56
  $(CC) $(CFLAGS) tsip.c
57
58
adc.o: adc.c
59
  @echo ".compiling"
60
  $(CC) $(CFLAGS) adc.c
61
62
spi.o: spi.c
63
  @echo ".compiling"
64
  $(CC) $(CFLAGS) spi.c
65
66
gps.o: gps.c
67
  @echo ".compiling"
68
  $(CC) $(CFLAGS) gps.c
69
70
geomag.o: geomag.c
71
  @echo ".compiling"
72
  $(CC) $(CFLAGS) geomag.c
73
74
isrsupport.o: isrsupport.c
75
  @echo ".compiling"
76
  $(CC) $(CFLAGS) isrsupport.c
77
  
78
lowlevelinit.o: lowlevelinit.c
79
  @ echo ".compiling"
80
  $(CC) $(CFLAGS) lowlevelinit.c


And here it's the output:

noether@SpaceFish:~/workspace/ARM7/Truck$ make
..linking
arm-none-linux-gnueabi-gcc -I./ -mcpu=arm7tdmi -c -fno-common -Os -g 
crt.o  main.o timer.o misc.o tsip.o adc.o spi.o gps.o geomag.o 
isrsupport.o lowlevelinit.o  -o main.out -Map main.map -Ttruck.cmd -lm 
-lgcc
arm-none-linux-gnueabi-gcc: main.map: No such file or directory
arm-none-linux-gnueabi-gcc: unrecognized option '-Map'
make: *** [main.out] Error 1

I tried with -Map= instead -Map, and it is the same.
Any ideas? (i¡m really noob, i know it xD).

von Jörg W. (dl8dtl) (Moderator)


Rate this post
useful
not useful
noether wrote:

> Previously i used the ld, but now i want to delegate this work to the
> compiler.

In that case, you have to prefix linker-specific options with -Wl,
so your option must be

-Wl,-Map=main.map

The -Wl tells the compiler to not consider this option as a compiler
option but pass it on to the linker.

von noether (Guest)


Rate this post
useful
not useful
Thank you very much, i forgot it!

Anyway, finally i just compiled my own tool-chain this afternoon from 
sources xD, and everything is working again.

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.