How to get the map file by gcc
Moderator: BigEvilCorporation
-
- Very interested
- Posts: 101
- Joined: Thu Sep 04, 2008 2:57 am
- Location: China
How to get the map file by gcc
I want to watch the address information of variable or function.
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
Add this to your LINKFLAGS you pass to gcc:
or if you use ld directly, use:
where output.map is the name of the map file created. You can make it whatever you want, like codemap.txt or wherestuffis.readme.
Code: Select all
-Wl,-Map=output.map
Code: Select all
-Map=output.map
-
- Very interested
- Posts: 101
- Joined: Thu Sep 04, 2008 2:57 am
- Location: China
I don't understand yet.
This is my makefile.gen,
#######
CC= D:/apps/GenDev/bin/gcc
OBJC= D:/apps/GenDev/bin/objcopy
ASMZ80= D:/apps/GenDev/bin/asmz80
BINTOC= D:/apps/GenDev/bin/bintoc
#OPTION= -Dnologo_
SRC_C= $(wildcard *.c)
SRC_S= $(wildcard *.s)
SRC_SZ80= $(wildcard *.s80)
OBJ= $(SRC_SZ80:.s80=.o)
OBJ+= $(SRC_C:.c=.o)
OBJ+= $(SRC_S:.s=.o)
LINKOBJ= sega.o \
$(OBJ)
INCS=
FLAGS= $(OPTION) -m68000 -Wall -O2 -fomit-frame-pointer $(INCS)
FLAGSZ80= -c -i -x1 -x2 -x3 -z -lnul
all: rom.bin
rom.bin: rom.out
# $(OBJC) --pad-to 524288 -O binary rom.out rom.bin
# $(OBJC) --pad-to 1048576 -O binary rom.out rom.bin
$(OBJC) --pad-to 2097152 -O binary rom.out rom.bin
rom.out: $(OBJ)
$(CC) -T D:/apps/GenDev/bin/md.ld -nostdlib $(LINKOBJ) D:/apps/GenDev/bin/libgcc.a -o rom.out
%.o80: %.s80
$(ASMZ80) $(FLAGSZ80) -o$@ $<
%.c: %.o80
$(BINTOC) $<
%.o: %.c
$(CC) $(FLAGS) -c $< -o $@
%.o: %.s
$(CC) $(FLAGS) -c $< -o $@
%.o: %.s
$(AS) -m68000 --register-prefix-optional $< -o $@
Add the "-map" flag to where?
This is my makefile.gen,
#######
CC= D:/apps/GenDev/bin/gcc
OBJC= D:/apps/GenDev/bin/objcopy
ASMZ80= D:/apps/GenDev/bin/asmz80
BINTOC= D:/apps/GenDev/bin/bintoc
#OPTION= -Dnologo_
SRC_C= $(wildcard *.c)
SRC_S= $(wildcard *.s)
SRC_SZ80= $(wildcard *.s80)
OBJ= $(SRC_SZ80:.s80=.o)
OBJ+= $(SRC_C:.c=.o)
OBJ+= $(SRC_S:.s=.o)
LINKOBJ= sega.o \
$(OBJ)
INCS=
FLAGS= $(OPTION) -m68000 -Wall -O2 -fomit-frame-pointer $(INCS)
FLAGSZ80= -c -i -x1 -x2 -x3 -z -lnul
all: rom.bin
rom.bin: rom.out
# $(OBJC) --pad-to 524288 -O binary rom.out rom.bin
# $(OBJC) --pad-to 1048576 -O binary rom.out rom.bin
$(OBJC) --pad-to 2097152 -O binary rom.out rom.bin
rom.out: $(OBJ)
$(CC) -T D:/apps/GenDev/bin/md.ld -nostdlib $(LINKOBJ) D:/apps/GenDev/bin/libgcc.a -o rom.out
%.o80: %.s80
$(ASMZ80) $(FLAGSZ80) -o$@ $<
%.c: %.o80
$(BINTOC) $<
%.o: %.c
$(CC) $(FLAGS) -c $< -o $@
%.o: %.s
$(CC) $(FLAGS) -c $< -o $@
%.o: %.s
$(AS) -m68000 --register-prefix-optional $< -o $@
Add the "-map" flag to where?
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
Change
to
Code: Select all
rom.out: $(OBJ)
$(CC) -T D:/apps/GenDev/bin/md.ld -nostdlib $(LINKOBJ) D:/apps/GenDev/bin/libgcc.a -o rom.out
Code: Select all
rom.out: $(OBJ)
$(CC) -Wl,-Map=output.map -T D:/apps/GenDev/bin/md.ld -nostdlib $(LINKOBJ) D:/apps/GenDev/bin/libgcc.a -o rom.out