看板 CompilerDev 關於我們 聯絡資訊
早期的 forth image 都沒有 symbol table,不易用 gdb 除錯, 所以可以用 elfsh 工具增加這項內容。 gforth Smake.f 會造出執行檔 sforth,把函式名字和位置列印出來, 之後就可以輸出有 symbol table 的 sforth.new 執行檔。 // http://elfsh.asgardlabs.org/ // http://www.eresi-project.org/ // https://github.com/thorkill/eresi // ** symtab_extend.c for elfsh testsuite #include "libelfsh.h" #define INPUT_FILE "./sforth" #define OUTPUT_FILE "./sforth.new" elfshobj_t *file; int linkcode (char *name, int addr) { int ret; elfsh_Sym sym; // name = "SEARCH-WORDLIST"; // sym = elfsh_create_symbol(addr, 21, STT_FUNC, 0, 0, 1); printf ("name is %s, addr 0x%x \n", name, addr); sym = elfsh_create_symbol(addr, 42, 0, 0, 0, 1); ret = elfsh_insert_symbol(file->secthash[ELFSH_SECTION_SYMTAB], &sym, name); } int main(int argc, char **argv) { int ret; elfsh_Sym sym; // ... sym = elfsh_create_symbol(0x11152, 21, STT_FUNC, 0, 0, 1); ret = elfsh_insert_symbol(file->secthash[ELFSH_SECTION_SYMTAB], &sym, name); while (gets(buf)) { if (2 == sscanf(buf, "linkcode %s 0x%x", buf2, &addr)) { linkcode(buf2, addr); } } ret = elfsh_save_obj(file, buf2); printf("Relinking *%s* \n", ret ? "Error" : "OK"); } sforth4addr.txt /* gforth Smake.f ;*/ linkcode MY_COLD 0x10000 linkcode E820 0x10024 linkcode AH88 0x10043 linkcode SYSCALL0 0x1004B linkcode SYSCALL1 0x1004E linkcode SYSCALL2 0x10056 linkcode SYSCALL3 0x10061 linkcode SYSCALL4 0x1006F linkcode SYSCALL5 0x10082 ... -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.43.77.156 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/CompilerDev/M.1591604848.A.CDC.html