From d2c5996f70844ae7816034b56e769ce163251718 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 10 Aug 2005 22:13:57 +0000 Subject: [PATCH] 2005-08-10 Roland McGrath * relocate.c (__libdwfl_relocate): Take argument DEBUGFILE, use it instead of MOD->debug.file. * libdwflP.h: Update decl. * dwfl_module_getdwarf.c (load_dw): Update caller. Fixes bug #165598. --- libdwfl/ChangeLog | 8 ++++++++ libdwfl/dwfl_module_getdwarf.c | 2 +- libdwfl/libdwflP.h | 7 ++++--- libdwfl/relocate.c | 18 +++++++++--------- 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog index 6c22f8a8a..532e1805d 100644 --- a/libdwfl/ChangeLog +++ b/libdwfl/ChangeLog @@ -1,3 +1,11 @@ +2005-08-10 Roland McGrath + + * relocate.c (__libdwfl_relocate): Take argument DEBUGFILE, + use it instead of MOD->debug.file. + * libdwflP.h: Update decl. + * dwfl_module_getdwarf.c (load_dw): Update caller. + Fixes bug #165598. + 2005-08-09 Roland McGrath * libdwflP.h: Include ../libdw/libdwP.h for its INTDECLs. diff --git a/libdwfl/dwfl_module_getdwarf.c b/libdwfl/dwfl_module_getdwarf.c index 1583c7a87..cf982aafe 100644 --- a/libdwfl/dwfl_module_getdwarf.c +++ b/libdwfl/dwfl_module_getdwarf.c @@ -299,7 +299,7 @@ load_dw (Dwfl_Module *mod, Elf *debugfile) find_symtab (mod); Dwfl_Error result = mod->symerr; if (result == DWFL_E_NOERROR) - result = __libdwfl_relocate (mod); + result = __libdwfl_relocate (mod, debugfile); if (result != DWFL_E_NOERROR) return result; } diff --git a/libdwfl/libdwflP.h b/libdwfl/libdwflP.h index 772bf29c5..4f99386f6 100644 --- a/libdwfl/libdwflP.h +++ b/libdwfl/libdwflP.h @@ -177,11 +177,12 @@ extern void __libdwfl_module_free (Dwfl_Module *mod) internal_function; /* Process relocations in debugging sections in an ET_REL file. - MOD->debug.elf must be opened with ELF_C_READ_MMAP_PRIVATE or ELF_C_READ, + DEBUGFILE must be opened with ELF_C_READ_MMAP_PRIVATE or ELF_C_READ, to make it possible to relocate the data in place (or ELF_C_RDWR or ELF_C_RDWR_MMAP if you intend to modify the Elf file on disk). After - this, dwarf_begin_elf on MOD->debug.elf will read the relocated data. */ -extern Dwfl_Error __libdwfl_relocate (Dwfl_Module *) internal_function; + this, dwarf_begin_elf on DEBUGFILE will read the relocated data. */ +extern Dwfl_Error __libdwfl_relocate (Dwfl_Module *mod, Elf *debugfile) + internal_function; /* Adjust *VALUE from section-relative to absolute. MOD->dwfl->callbacks->section_address is called to determine the actual diff --git a/libdwfl/relocate.c b/libdwfl/relocate.c index 41de6d180..48cb1ad26 100644 --- a/libdwfl/relocate.c +++ b/libdwfl/relocate.c @@ -61,28 +61,28 @@ __libdwfl_relocate_value (Dwfl_Module *mod, size_t symshstrndx, Dwfl_Error internal_function_def -__libdwfl_relocate (Dwfl_Module *mod) +__libdwfl_relocate (Dwfl_Module *mod, Elf *debugfile) { assert (mod->isrel); GElf_Ehdr ehdr_mem; - const GElf_Ehdr *ehdr = gelf_getehdr (mod->debug.elf, &ehdr_mem); + const GElf_Ehdr *ehdr = gelf_getehdr (debugfile, &ehdr_mem); if (ehdr == NULL) return DWFL_E_LIBELF; size_t symshstrndx, d_shstrndx; if (elf_getshstrndx (mod->symfile->elf, &symshstrndx) < 0) return DWFL_E_LIBELF; - if (mod->symfile == &mod->debug) + if (mod->symfile->elf == debugfile) d_shstrndx = symshstrndx; - else if (elf_getshstrndx (mod->debug.elf, &d_shstrndx) < 0) + else if (elf_getshstrndx (debugfile, &d_shstrndx) < 0) return DWFL_E_LIBELF; /* Look at each section in the debuginfo file, and process the relocation sections for debugging sections. */ Dwfl_Error result = DWFL_E_NO_DWARF; Elf_Scn *scn = NULL; - while ((scn = elf_nextscn (mod->debug.elf, scn)) != NULL) + while ((scn = elf_nextscn (debugfile, scn)) != NULL) { GElf_Shdr shdr_mem; GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem); @@ -92,13 +92,13 @@ __libdwfl_relocate (Dwfl_Module *mod) /* It's a relocation section. First, fetch the name of the section these relocations apply to. */ - Elf_Scn *tscn = elf_getscn (mod->debug.elf, shdr->sh_info); + Elf_Scn *tscn = elf_getscn (debugfile, shdr->sh_info); if (tscn == NULL) return DWFL_E_LIBELF; GElf_Shdr tshdr_mem; GElf_Shdr *tshdr = gelf_getshdr (tscn, &tshdr_mem); - const char *tname = elf_strptr (mod->debug.elf, d_shstrndx, + const char *tname = elf_strptr (debugfile, d_shstrndx, tshdr->sh_name); if (tname == NULL) return DWFL_E_LIBELF; @@ -225,7 +225,7 @@ __libdwfl_relocate (Dwfl_Module *mod) else { /* Extract the original value and apply the reloc. */ - Elf_Data *d = gelf_xlatetom (mod->main.elf, &tmpdata, &rdata, + Elf_Data *d = gelf_xlatetom (debugfile, &tmpdata, &rdata, ehdr->e_ident[EI_DATA]); if (d == NULL) return DWFL_E_LIBELF; @@ -246,7 +246,7 @@ __libdwfl_relocate (Dwfl_Module *mod) /* Now convert the relocated datum back to the target format. This will write into rdata.d_buf, which points into the raw section data being relocated. */ - Elf_Data *s = gelf_xlatetof (mod->main.elf, &rdata, &tmpdata, + Elf_Data *s = gelf_xlatetof (debugfile, &rdata, &tmpdata, ehdr->e_ident[EI_DATA]); if (s == NULL) return DWFL_E_LIBELF; -- 2.47.2