|
|
1.1 root 1: # LOADMAP(1)
2: #
3: # Produce load map of object file
4: #
5: # Stephen B. Wampler
6: #
7: # Last modified 7/10/83
8: #
9:
10: record entry(name,address)
11:
12: procedure main(args)
13: local maptype, arg, file, nm, ldmap, tname, line, text, data, bss
14: local SPACE, COLON, DIGITS, HEXDIGITS, usize, address, name
15: initial {
16: if *args = 0 then stop("usage: loadmap -tdbuac file")
17: SPACE := '\t '
18: COLON := ':'
19: DIGITS := '0123456789'
20: HEXDIGITS := DIGITS ++ 'abcdef'
21: ldmap := table(6)
22: ldmap["u"] := []
23: ldmap["d"] := []
24: ldmap["a"] := []
25: ldmap["b"] := []
26: ldmap["t"] := []
27: ldmap["c"] := []
28: tname := table(6)
29: tname["u"] := "Undefined symbols"
30: tname["a"] := "Absolute locations"
31: tname["t"] := "Text segment symbols"
32: tname["d"] := "Data segment symbols"
33: tname["b"] := "BSS segment symbols"
34: tname["c"] := "Common symbols"
35: }
36: maptype := ""
37: every arg := !args do
38: if arg[1] ~== "-" then file := arg
39: else if arg[1] == "-" then maptype ||:= (!"tdbuac" == arg[2:0]) |
40: stop("usage: loadmap -tdbuac file")
41: maptype := if *maptype = 0 then "t" else string(cset(maptype))
42: write("\n",file,"\n")
43: usize := open("size " || file,"rp") | stop("loadmap: cannot execute size")
44: !usize ? {
45: writes("Text space: ",right(text := tab(many(DIGITS)),6)," ")
46: move(1)
47: writes("Initialized Data: ",right(data := tab(many(DIGITS)),6)," ")
48: move(1)
49: write("Uninitialized Data: ",right(bss := tab(many(DIGITS)),6))
50: }
51: close(usize)
52: nm := open("nm -gno " || file,"rp") | stop("loadmap: cannot execute nm")
53: every line := !nm do
54: line ? {
55: tab(upto(COLON)) & move(1)
56: address := integer("16r" || tab(many(HEXDIGITS))) | "????"
57: tab(many(SPACE))
58: type := map(move(1))
59: tab(many(SPACE))
60: name := tab(0)
61: if find(type,maptype) then put(ldmap[type],entry(name,address))
62: }
63: every type := !maptype do {
64: if *ldmap[type] > 0 then {
65: write("\n\n\n")
66: write(tname[type],":")
67: write()
68: show(ldmap[type],(type == "t" & text) |
69: (type == "d" & data) | (type == "b" & bss) | &null,
70: ldmap[type][1].address)
71: }
72: }
73: end
74:
75: procedure show(l,ssize,base)
76: local i1, i2, nrows
77: static ncols
78: initial ncols := 3
79: write(repl(repl(" ",3) || left("name",9) || right("addr",7) ||
80: right("size",6),ncols))
81: write()
82: nrows := (*l + (ncols - 1)) / ncols
83: every i1 := 1 to nrows do {
84: every i2 := i1 to *l by nrows do
85: writes(repl(" ",3),left(l[i2].name,9),right(l[i2].address,7),
86: right(area(l[i2 + 1].address,l[i2].address) |
87: if /ssize then "rem" else base + ssize - l[i2].address,6))
88: write()
89: }
90: return
91: end
92:
93: procedure area(high,low)
94: if integer(low) & integer(high) then return high - low
95: else return "????"
96: end
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.