Why isn't the linker working?

Guest #1442329
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).
Moderator #1442620
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.
Guest #1442663
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.

Reply

A question of your own? This thread is over 17 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

Formatting
  • [c]C-Code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.