From 87816a9327dcb13b51ac01b74b09aabea4a719d0 Mon Sep 17 00:00:00 2001 From: Paul Floyd Date: Mon, 14 Apr 2025 22:05:57 +0200 Subject: [PATCH] Illumos readelf: patch for detection of DTrace .data sections Taken from https://github.com/oracle/solaris-userland/blob/master/components/valgrind/patches/03-dtrace-section.patch --- coregrind/m_debuginfo/readelf.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/coregrind/m_debuginfo/readelf.c b/coregrind/m_debuginfo/readelf.c index 0c37ea100..61a39af2a 100644 --- a/coregrind/m_debuginfo/readelf.c +++ b/coregrind/m_debuginfo/readelf.c @@ -2200,17 +2200,24 @@ Bool ML_(read_elf_object) ( struct _DebugInfo* di ) } } } - if (!loaded) { -# if defined(SOLARIS_PT_SUNDWTRACE_THRP) - if ((a_phdr.p_memsz == VKI_PT_SUNWDTRACE_SIZE) - && ((a_phdr.p_flags & (PF_R | PF_W | PF_X)) == PF_R)) { +# if defined(SOLARIS_PT_SUNDWTRACE_THRP) + if ((a_phdr.p_memsz == VKI_PT_SUNWDTRACE_SIZE) + && ((a_phdr.p_flags & (PF_R | PF_W | PF_X)) == PF_R)) { + if (dtrace_data_vaddr != 0) { + ML_(symerr)(di, True, "Multiple dtrace_data headers detected"); + goto out; + } + dtrace_data_vaddr = a_phdr.p_vaddr; + + /* DTrace related section might be outside all mapped regions. */ + if (!loaded) { TRACE_SYMTAB("PT_LOAD[%ld]: ignore dtrace_data program " "header\n", i); - dtrace_data_vaddr = a_phdr.p_vaddr; continue; } -# endif /* SOLARIS_PT_SUNDWTRACE_THRP */ - + } +# endif /* SOLARIS_PT_SUNDWTRACE_THRP */ + if (!loaded) { ML_(symerr)(di, False, "ELF section outside all mapped regions"); /* This problem might be solved by further memory mappings. -- 2.39.5