From: Paul Floyd Date: Sun, 8 Oct 2023 07:43:15 +0000 (+0200) Subject: Revert "Bug 390871 - ELF debug info reader confused with multiple .rodata* sections" X-Git-Tag: VALGRIND_3_22_0~32 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=bd21fefde12825948ee0aca9c0a88f0f8c38cfea;p=valgrind.git Revert "Bug 390871 - ELF debug info reader confused with multiple .rodata* sections" This reverts commit 5472a7a54000692f9f58e9b551d36b8c68c44873. --- diff --git a/NEWS b/NEWS index ad30282704..9a05f5486d 100644 --- a/NEWS +++ b/NEWS @@ -55,7 +55,6 @@ bugzilla (https://bugs.kde.org/enter_bug.cgi?product=valgrind) rather than mailing the developers (or mailing lists) directly -- bugs that are not entered into bugzilla tend to get forgotten about or ignored. -390871 ELF debug info reader confused with multiple .rodata* sections 426751 Valgrind reports "still reachable" memory using musl (alpine running inside docker) 432801 Valgrind 3.16.1 reports a jump based on uninitialized memory somehow related to clang and signals 433857 Add validation to C++17 aligned new/delete alignment size diff --git a/coregrind/m_debuginfo/readelf.c b/coregrind/m_debuginfo/readelf.c index fb64ed9769..9bb60f42ad 100644 --- a/coregrind/m_debuginfo/readelf.c +++ b/coregrind/m_debuginfo/readelf.c @@ -2334,7 +2334,7 @@ Bool ML_(read_elf_object) ( struct _DebugInfo* di ) leave the relevant pointer at NULL. */ RangeAndBias* inrx = NULL; RangeAndBias* inrw1 = NULL; - /* Depending on the link editor there may be two RW PT_LOAD headers + /* Depending on the link editro there may be two RW PT_LOAD headers * If so this will point to the seond one */ RangeAndBias* inrw2 = NULL; /* used to switch between inrw1 and inrw2 */ @@ -2478,42 +2478,35 @@ Bool ML_(read_elf_object) ( struct _DebugInfo* di ) } /* Accept .rodata where mapped as rx or rw (data), even if zero-sized */ - /* Also accept .rodata., and aggregate adjacent after alignment. */ - if (0 == VG_(strncmp)(name, ".rodata", 7)) { - if ((inrx||inrw1) && !di->rodata_present) { /* first .rodata* */ + if (0 == VG_(strcmp)(name, ".rodata")) { + if (!di->rodata_present) { di->rodata_svma = svma; di->rodata_avma = svma; di->rodata_size = size; di->rodata_debug_svma = svma; - } else if ((inrx||inrw1) && di->rodata_present) { /* not first .rodata* */ - Addr tmp = VG_ROUNDUP(di->rodata_size + di->rodata_svma, alyn); - if (svma == tmp) { /* adjacent to previous .rodata* */ - di->rodata_size = size + tmp - di->rodata_svma; + if (inrx) { + di->rodata_avma += inrx->bias; + di->rodata_bias = inrx->bias; + di->rodata_debug_bias = inrx->bias; + } else if (inrw1) { + di->rodata_avma += inrw1->bias; + di->rodata_bias = inrw1->bias; + di->rodata_debug_bias = inrw1->bias; } else { - BAD(".rodata"); /* is OK, but we cannot handle multiple .rodata* */ + BAD(".rodata"); } + di->rodata_present = True; + TRACE_SYMTAB("acquiring .rodata svma = %#lx .. %#lx\n", + di->rodata_svma, + di->rodata_svma + di->rodata_size - 1); + TRACE_SYMTAB("acquiring .rodata avma = %#lx .. %#lx\n", + di->rodata_avma, + di->rodata_avma + di->rodata_size - 1); + TRACE_SYMTAB("acquiring .rodata bias = %#lx\n", + (UWord)di->rodata_bias); + } else { + BAD(".rodata"); } - if (inrx) { - di->rodata_avma += inrx->bias; - di->rodata_bias = inrx->bias; - di->rodata_debug_bias = inrx->bias; - } else if (inrw1) { - di->rodata_avma += inrw1->bias; - di->rodata_bias = inrw1->bias; - di->rodata_debug_bias = inrw1->bias; - } - else { - BAD(".rodata"); /* should not happen? */ - } - di->rodata_present = True; - TRACE_SYMTAB("acquiring .rodata svma = %#lx .. %#lx\n", - di->rodata_svma, - di->rodata_svma + di->rodata_size - 1); - TRACE_SYMTAB("acquiring .rodata avma = %#lx .. %#lx\n", - di->rodata_avma, - di->rodata_avma + di->rodata_size - 1); - TRACE_SYMTAB("acquiring .rodata bias = %#lx\n", - (UWord)di->rodata_bias); } if (0 == VG_(strcmp)(name, ".dynbss")) {