For ET_REL files, dwfl_offline_section_address matches allocated sections by order because section indexes can differ between a main file and its separate debug file. A malformed pair can still have corresponding allocated sections with different flags.
Reject that mismatch with a callback failure instead of terminating the process with an assertion. Returning -1 lets relocation and DWARF loading propagate a clean failure. Valid matching main/debug pairs are unchanged. https://sourceware.org/bugzilla/show_bug.cgi?id=34436 * libdwfl/offline.c (dwfl_offline_section_address): Return -1 when corresponding allocated sections have different flags. Signed-off-by: zengliwen <[email protected]> --- libdwfl/offline.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libdwfl/offline.c b/libdwfl/offline.c index dc099d2b..5a3ed16a 100644 --- a/libdwfl/offline.c +++ b/libdwfl/offline.c @@ -88,7 +88,8 @@ dwfl_offline_section_address (Dwfl_Module *mod, return -1; if ((main_shdr->sh_flags & SHF_ALLOC) && skip_alloc-- == 0) { - assert (main_shdr->sh_flags == shdr->sh_flags); + if (unlikely (main_shdr->sh_flags != shdr->sh_flags)) + return -1; *addr = main_shdr->sh_addr; return 0; } -- 2.43.0
