How to get the map file by gcc

Ask anything your want about Megadrive/Genesis programming.

Moderator: BigEvilCorporation

Post Reply
zhengyaxin_8bit
Very interested
Posts: 101
Joined: Thu Sep 04, 2008 2:57 am
Location: China

How to get the map file by gcc

Post by zhengyaxin_8bit » Thu Jan 05, 2012 1:45 pm

I want to watch the address information of variable or function.

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Thu Jan 05, 2012 4:30 pm

Add this to your LINKFLAGS you pass to gcc:

Code: Select all

-Wl,-Map=output.map
or if you use ld directly, use:

Code: Select all

-Map=output.map
where output.map is the name of the map file created. You can make it whatever you want, like codemap.txt or wherestuffis.readme.

zhengyaxin_8bit
Very interested
Posts: 101
Joined: Thu Sep 04, 2008 2:57 am
Location: China

Post by zhengyaxin_8bit » Mon Jan 09, 2012 2:11 am

I don't understand yet. :oops:
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?

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Mon Jan 09, 2012 3:30 am

Change

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
to

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

Post Reply