mirror of
https://github.com/JakeHillion/drgn.git
synced 2024-12-23 01:33:06 +00:00
libdrgn: handle errors from elf_strptr()
For some reason, we consistently ignore errors from elf_strptr(), but we shouldn't. Signed-off-by: Omar Sandoval <osandov@osandov.com>
This commit is contained in:
parent
12723a0c08
commit
da180b7274
@ -840,8 +840,10 @@ static struct drgn_error *apply_elf_relocations(Elf *elf)
|
||||
continue;
|
||||
|
||||
scnname = elf_strptr(elf, shstrndx, shdr->sh_name);
|
||||
if (!scnname)
|
||||
continue;
|
||||
if (!scnname) {
|
||||
err = drgn_error_libelf();
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (strstartswith(scnname, ".rela.debug_")) {
|
||||
Elf_Scn *info_scn, *link_scn;
|
||||
@ -911,7 +913,7 @@ drgn_debug_info_find_sections(struct drgn_debug_info_module *module)
|
||||
continue;
|
||||
const char *scnname = elf_strptr(elf, shstrndx, shdr->sh_name);
|
||||
if (!scnname)
|
||||
continue;
|
||||
return drgn_error_libelf();
|
||||
|
||||
for (size_t i = 0; i < DRGN_NUM_DEBUG_SCNS; i++) {
|
||||
if (!module->scns[i] &&
|
||||
|
@ -908,7 +908,7 @@ static struct drgn_error *identify_kernel_elf(Elf *elf,
|
||||
|
||||
scnname = elf_strptr(elf, shstrndx, shdr->sh_name);
|
||||
if (!scnname)
|
||||
continue;
|
||||
return drgn_error_libelf();
|
||||
if (strcmp(scnname, ".gnu.linkonce.this_module") == 0)
|
||||
*this_module_scn_ret = scn;
|
||||
else if (strcmp(scnname, ".modinfo") == 0)
|
||||
@ -1012,12 +1012,16 @@ cache_kernel_module_sections(struct kernel_module_iterator *kmod_it, Elf *elf,
|
||||
.key = elf_strptr(elf, shstrndx, shdr->sh_name),
|
||||
.value = scn,
|
||||
};
|
||||
if (!entry.key) {
|
||||
err = drgn_error_libelf();
|
||||
goto out_scn_map;
|
||||
}
|
||||
/*
|
||||
* .init sections are freed once the module is initialized, but
|
||||
* they remain in the section list. Ignore them so we don't get
|
||||
* confused if the address gets reused for another module.
|
||||
*/
|
||||
if (!entry.key || strstartswith(entry.key, ".init"))
|
||||
if (strstartswith(entry.key, ".init"))
|
||||
continue;
|
||||
|
||||
if (elf_scn_name_map_insert(&scn_map, &entry, NULL) == -1) {
|
||||
|
Loading…
Reference in New Issue
Block a user