gensym: avoid link step when generating symbol table

This commit is contained in:
K. Lange 2023-05-09 13:44:52 +09:00
parent 70d594f75e
commit e88dca719f
2 changed files with 4 additions and 3 deletions

View File

@ -108,8 +108,7 @@ kernel/sys/version.o: ${KERNEL_SOURCES}
kernel/symbols.o: ${KERNEL_ASMOBJS} ${KERNEL_OBJS} util/gensym.krk kernel/symbols.o: ${KERNEL_ASMOBJS} ${KERNEL_OBJS} util/gensym.krk
-rm -f kernel/symbols.o -rm -f kernel/symbols.o
${CC} -T kernel/arch/${ARCH}/link.ld ${KERNEL_CFLAGS} -o misaka-kernel.64 ${KERNEL_ASMOBJS} ${KERNEL_OBJS} ${NM} misaka-kernel.64 -g -f p ${KERNEL_ASMOBJS} ${KERNEL_OBJS} | sort | kuroko util/gensym.krk > kernel/symbols.S
${NM} misaka-kernel.64 -g | kuroko util/gensym.krk > kernel/symbols.S
${CC} -c kernel/symbols.S -o $@ ${CC} -c kernel/symbols.S -o $@
kernel/%.o: kernel/%.S kernel/%.o: kernel/%.S

View File

@ -15,7 +15,9 @@ def entry(sym):
print(f'.asciz "{sym}"') print(f'.asciz "{sym}"')
let ignore = ['abs','kernel_symbols_start','kernel_symbols_end'] let ignore = ['abs','kernel_symbols_start','kernel_symbols_end']
let lines = [x.strip().split(' ')[2] for x in fileio.stdin.readlines() if x not in ignore] let source = [x.strip() for x in fileio.stdin.readlines()]
let symbols = [x.split()[0] for x in source if not x.endswith(':')]
let lines = [x for x in symbols if x not in ignore]
print('.section .symbols') print('.section .symbols')
print() print()