[Ups-cvs] ups/ups ao_elflib.c,1.16,1.17 ao_elfread.c,1.5,1.6 ao_execinfo.h,1.1.1.1,1.2 ao_symscan.c,
Brought to you by:
ianedwards
From: Tom H. <th...@us...> - 2005-02-21 16:38:48
|
Update of /cvsroot/ups/ups/ups In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24507 Modified Files: ao_elflib.c ao_elfread.c ao_execinfo.h ao_symscan.c ao_text.c Log Message: More fixes to try and handle prelinked libraries correctly. It turns out that the real problem is that when a prelinked library has separate debug information, that is not prelinked to the same address which is why the debug symbols have a different base. This patch works out the difference between the base address of the real library and of the debug image for it and applies that delta to the normal symbol table base address to get the DWARF symbol table base address. Index: ao_symscan.c =================================================================== RCS file: /cvsroot/ups/ups/ups/ao_symscan.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ao_symscan.c 26 Mar 2004 15:25:08 -0000 1.6 --- ao_symscan.c 21 Feb 2005 16:38:16 -0000 1.7 *************** *** 2014,2017 **** --- 2014,2020 ---- adjust_funcs_addr_base(st->st_funclist, delta); ast->st_base_address = new_addr; + #if WANT_DWARF + ast->st_dw_base_address = ast->st_dw_base_address + delta; + #endif } } Index: ao_execinfo.h =================================================================== RCS file: /cvsroot/ups/ups/ups/ao_execinfo.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** ao_execinfo.h 26 Oct 2002 13:06:31 -0000 1.1.1.1 --- ao_execinfo.h 21 Feb 2005 16:38:16 -0000 1.2 *************** *** 30,34 **** size_t text_size; /* #bytes of text */ off_t text_addr_delta; /* What to add to fu_addr etc to get mem addr */ ! off_t addr_to_fpos_offset; /* Delta from mem addr to file offset */ --- 30,35 ---- size_t text_size; /* #bytes of text */ off_t text_addr_delta; /* What to add to fu_addr etc to get mem addr */ ! off_t debug_addr_delta; /* Delta from debug addresses to real addresses */ ! off_t addr_to_fpos_offset; /* Delta from mem addr to file offset */ Index: ao_elfread.c =================================================================== RCS file: /cvsroot/ups/ups/ups/ao_elfread.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ao_elfread.c 19 Feb 2004 12:48:38 -0000 1.5 --- ao_elfread.c 21 Feb 2005 16:38:16 -0000 1.6 *************** *** 394,398 **** --- 394,402 ---- const Elfops *elops; Elf_Ehdr *hdr; + Elf_Phdr *phtab; Elfinfo *el; + taddr_t text_mem_addr; + size_t text_size; + off_t addr_to_fpos_offset; if ((fd = open(debugpath, O_RDONLY)) < 0) *************** *** 410,413 **** --- 414,432 ---- } + phtab = e_malloc(elf_header_phsize(elops, hdr)); + if (!read_chunk(debugpath, Elfwhat, fd, "debug program header table", + elf_header_phoff(elops, hdr), + phtab, elf_header_phsize(elops, hdr)) || + !get_load_addrs(debugpath, elops, phtab, elf_header_phnum(elops, hdr), + &text_mem_addr, &text_size, + &addr_to_fpos_offset, + &el->min_file_vaddr)) { + free(phtab); + free(hdr); + free_elfinfo(el); + return FALSE; + } + free(phtab); + free(hdr); *************** *** 562,565 **** --- 581,585 ---- ex->text_addr_delta = 0; + ex->debug_addr_delta = el->min_file_vaddr - el->debugel->min_file_vaddr; ex->dynamic = FALSE; ex->entry_addr = elf_header_entry(elops, hdr); Index: ao_elflib.c =================================================================== RCS file: /cvsroot/ups/ups/ups/ao_elflib.c,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** ao_elflib.c 21 Feb 2005 12:20:59 -0000 1.16 --- ao_elflib.c 21 Feb 2005 16:38:15 -0000 1.17 *************** *** 396,407 **** change_base_address(so->symtab, base_address); - - #if WANT_DWARF - if (base_address != 0) { - ao_stdata_t *ast = AO_STDATA(so->symtab); - - ast->st_dw_base_address = base_address; - } - #endif } --- 396,399 ---- Index: ao_text.c =================================================================== RCS file: /cvsroot/ups/ups/ups/ao_text.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** ao_text.c 21 Feb 2005 12:21:05 -0000 1.10 --- ao_text.c 21 Feb 2005 16:38:18 -0000 1.11 *************** *** 256,260 **** ast->st_dw_dbg = 0; ast->st_dw_scanned = FALSE; ! ast->st_dw_base_address = ei->text_mem_addr; if (st_is == ST_DWARF) { ast->st_dw_dbg = dw_dbg; --- 256,260 ---- ast->st_dw_dbg = 0; ast->st_dw_scanned = FALSE; ! ast->st_dw_base_address = base_address + ei->debug_addr_delta; if (st_is == ST_DWARF) { ast->st_dw_dbg = dw_dbg; |