[Differential] D51188: dtrace: fix symbol address resolving
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 07 Jul 2025 07:34:43 UTC
zldrobit_gmail.com created this revision.
zldrobit_gmail.com added a reviewer: DTrace.
zldrobit_gmail.com added a project: DTrace.
Herald added a subscriber: imp.
Herald added a reviewer: gnn.
zldrobit_gmail.com requested review of this revision.
REVISION SUMMARY
Dtrace assumes only **ELF** sections of type `SHT_PROGBITS` or `SHT_NOBITS` occupy memory space. However, sections with `SHF_ALLOC` flag also consume memory space. Moreover, the symbol address initialization skips symbols at the very beginning of a section.
Fix: Check section flag for calculating section offset, and disable the skipping at the beginning of a section.
PR: 288000
REPOSITORY
rG FreeBSD src repository
REVISION DETAIL
https://reviews.freebsd.org/D51188
AFFECTED FILES
cddl/contrib/opensolaris/lib/libdtrace/common/dt_module.c
CHANGE DETAILS
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_module.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_module.c
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_module.c
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_module.c
@@ -159,8 +159,7 @@
if (sym->st_name == 0 || sym->st_name >= ss_size)
continue; /* skip null or invalid names */
- if (sym->st_value != 0 &&
- (ELF64_ST_BIND(sym->st_info) != STB_LOCAL || sym->st_size)) {
+ if (ELF64_ST_BIND(sym->st_info) != STB_LOCAL || sym->st_size) {
asrsv++; /* reserve space in the address map */
#if defined(__FreeBSD__)
sym->st_value += (Elf_Addr) dmp->dm_reloc_offset;
@@ -1218,7 +1217,7 @@
continue; /* skip any malformed sections */
if (sh.sh_size == 0)
continue;
- if (sh.sh_type == SHT_PROGBITS || sh.sh_type == SHT_NOBITS) {
+ if (sh.sh_flags & SHF_ALLOC) {
alignmask = sh.sh_addralign - 1;
mapbase += alignmask;
mapbase &= ~alignmask;
EMAIL PREFERENCES
https://reviews.freebsd.org/settings/panel/emailpreferences/
To: zldrobit_gmail.com, #dtrace, gnn
Cc: freebsd-dtrace-list, imp, me_reviews.freebsd_lelf.lu, kpraveen.lkml_gmail.com, bkidney_briankidney.ca, dnelson_1901_yahoo.com, yan.jurak_gmail.com, bcr, lwhsu, jonathan, pstef, guest-patmaddox