/SPARTAN/trunk/src/debug/symtab.c |
---|
0,0 → 1,47 |
/* |
* Copyright (C) 2005 Ondrej Palkovsky |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
#include <symtab.h> |
#include <typedefs.h> |
/** Return entry that seems most likely to correspond to the @addr |
* |
*/ |
char * get_symtab_entry(__native addr) |
{ |
count_t i; |
for (i=1;symbol_table[i].address;++i) { |
if (addr < symbol_table[i].address) |
break; |
} |
if (addr >= symbol_table[i-1].address) |
return symbol_table[i-1].symbol_name; |
return NULL; |
} |
/SPARTAN/trunk/src/debug/genmap.py |
---|
0,0 → 1,60 |
#!/usr/bin/env python |
import sys |
import struct |
import re |
symline = re.compile(r'(0x[a-f0-9]+)\s+([^\s]+)$') |
symtabfmt = "<Q32s" |
MAXSTRING=31 |
def read_symbols(inp): |
while 1: |
line = inp.readline() |
if not line: |
return |
if 'memory map' in line: |
break |
symtable = {} |
while 1: |
line = inp.readline() |
if not line.strip(): |
continue |
if line[0] not in (' ','.'): |
break |
line = line.strip() |
# Search only for symbols |
res = symline.match(line) |
if res: |
symtable[int(res.group(1),16)] = res.group(2) |
return symtable |
def generate(inp, out): |
symtab = read_symbols(inp) |
if not symtab: |
print "Bad kernel.map format, empty." |
sys.exit(1) |
addrs = symtab.keys() |
addrs.sort() |
for addr in addrs: |
# Do not write address 0, it indicates end of data |
if addr == 0: |
continue |
data = struct.pack(symtabfmt,addr,symtab[addr][:MAXSTRING]) |
out.write(data) |
out.write(struct.pack(symtabfmt,0,'')) |
def main(): |
if len(sys.argv) != 3: |
print "Usage: %s <kernel.map> <output.bin>" % sys.argv[0] |
sys.exit(1) |
inp = open(sys.argv[1],'r') |
out = open(sys.argv[2],'w') |
generate(inp,out) |
inp.close() |
out.close() |
if __name__ == '__main__': |
main() |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/SPARTAN/trunk/src/build.amd64 |
---|
8,7 → 8,7 |
( |
set -e |
cd ../arch |
for a in drivers bios fpu_context.c mm/frame.c mm/tlb.c mm/memory_init.c boot/memmap.S; do |
for a in drivers bios fpu_context.c mm/frame.c mm/tlb.c mm/memory_init.c boot/memmap.S smp/apic.c smp/ipi.c smp/mps.c smp/smp.c acpi; do |
if [ \! -e amd64/src/$a ]; then |
echo ln -sf `pwd`/ia32/src/$a amd64/src/$a |
ln -sf `pwd`/ia32/src/$a amd64/src/$a |
/SPARTAN/trunk/src/Makefile |
---|
18,6 → 18,7 |
lib/memstr.c \ |
lib/the.c \ |
debug/print.c \ |
debug/symtab.c \ |
time/clock.c \ |
time/timeout.c \ |
time/delay.c \ |
64,7 → 65,7 |
clean: |
find . ../arch/$(ARCH)/src ../test -name '*.o' -exec rm \{\} \; |
-rm *.bin kernel.map |
-rm *.bin kernel.map kernel.map.pre debug/real_map.bin |
$(MAKE) -C ../arch/$(ARCH)/boot clean |
dist-clean: |
73,7 → 74,11 |
-$(MAKE) clean |
kernel.bin: $(arch_objects) $(objects) $(test_objects) |
$(LD) $(LFLAGS) $(arch_objects) $(objects) $(test_objects) -o $@ -Map kernel.map |
$(OBJCOPY) -I binary -O $(BFD_NAME) -B $(BFD_ARCH) --prefix-sections=symtab Makefile debug/empty_map.o |
$(LD) $(LFLAGS) $(arch_objects) $(objects) $(test_objects) debug/empty_map.o -o $@ -Map kernel.map.pre |
debug/genmap.py kernel.map.pre debug/real_map.bin |
$(OBJCOPY) -I binary -O $(BFD_NAME) -B $(BFD_ARCH) --prefix-sections=symtab debug/real_map.bin debug/real_map.o |
$(LD) $(LFLAGS) $(arch_objects) $(objects) $(test_objects) debug/real_map.o -o $@ -Map kernel.map |
%.s: %.S |
$(CC) $(CPPFLAGS) -E $< >$@ |