Page 1 of 1

Formating the linker map...

Posted: Sun Feb 18, 2007 9:50 am
by JJeronimo
Aparently, LD doesn't support outputing the symbol map by ascending address order... I've posed this question some months ago but no one knew...
http://www.osdev.org/phpBB2/viewtopic.p ... linker+map


Well, I've written a very simple Python script that does the job and also removes all the unneeded garbage... at least for me...



If you want it:

Code: Select all

file = open("kernel.map")

filelines = file.readlines()

file.close()



unneeded_excluded = []
for a in filelines:
 if a.lstrip().startswith("0x"):
  unneeded_excluded.append(a.strip())



splited = []
for a in unneeded_excluded:
 splited.append(a.split(None, 1))



addresses = []
for a in splited:
 addresses.append(a[0])

addresses.sort()



linesdict = {}
for a in splited:
 linesdict[a[0]] = a[1]



for a in addresses:
 print "%s\t%s\n" % (a, linesdict[a]),

It assumes the map is called "kernel.map" in the current directory and outputs to stdout... it also assumes that the addresses are in hexadecial, which I don't know if LD allows to change... adapt it to your needs...


It's not very genial, but I thought could be useful... took me only some minutes...

JJ