Date: Mon, 7 Jul 2025 18:20:18 +0000 From: "zldrobit_gmail.com (Jiacong Fang)" <phabric-noreply@FreeBSD.org> To: Phabricator <phabric-noreply@FreeBSD.org> Cc: freebsd-dtrace@freebsd.org Subject: [Differential] D51188: dtrace: fix symbol address resolving Message-ID: <370d8985ea2675de2b29d006d74192a4@localhost.localdomain> In-Reply-To: <differential-rev-PHID-DREV-b4356atzpi5p55s5zcd7-req@reviews.freebsd.org>
index | next in thread | previous in thread | raw e-mail
[-- Attachment #1 --] zldrobit_gmail.com updated this revision to Diff 158120. zldrobit_gmail.com marked an inline comment as not done. zldrobit_gmail.com added a comment. This revision now requires review to proceed. @markj I found that we should also delete `st_value = 0` in `dt_module_symsort32/64()`, otherwise `dmp->dm_aslen` would always be lesser than `dmp->dm_asrsv` by at least one. As a result, `dt_module_symsort32/64()` ignore the last element in `dmp->dm_asmap` and `dt_module_symaddr32/64()` wouldn't find it. I had to update the patch accordingly. Sorry for interrupting the test suite procedure. REPOSITORY rG FreeBSD src repository CHANGES SINCE LAST UPDATE https://reviews.freebsd.org/D51188?vs=158107&id=158120 CHANGES SINCE LAST ACTION https://reviews.freebsd.org/D51188/new/ REVISION DETAIL https://reviews.freebsd.org/D51188 AFFECTED FILES cddl/contrib/opensolaris/lib/libdtrace/common/dt_module.c EMAIL PREFERENCES https://reviews.freebsd.org/settings/panel/emailpreferences/ To: zldrobit_gmail.com, #dtrace, gnn, markj Cc: markj, avg, 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 [-- Attachment #2 --] 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 @@ -109,8 +109,7 @@ if (sym->st_name == 0 || sym->st_name >= ss_size) continue; /* skip null or invalid names */ - if (sym->st_value != 0 && - (ELF32_ST_BIND(sym->st_info) != STB_LOCAL || sym->st_size)) { + if (ELF32_ST_BIND(sym->st_info) != STB_LOCAL || sym->st_size) { asrsv++; /* reserve space in the address map */ #if defined(__FreeBSD__) @@ -159,8 +158,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; @@ -245,8 +243,7 @@ for (i = 1; i < n; i++, dsp++) { Elf32_Sym *sym = symtab + dsp->ds_symid; - if (sym->st_value != 0 && - (ELF32_ST_BIND(sym->st_info) != STB_LOCAL || sym->st_size)) + if (ELF32_ST_BIND(sym->st_info) != STB_LOCAL || sym->st_size) *sympp++ = sym; } @@ -269,8 +266,7 @@ for (i = 1; i < n; i++, dsp++) { Elf64_Sym *sym = symtab + dsp->ds_symid; - 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) *sympp++ = sym; } @@ -1218,7 +1214,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;help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?370d8985ea2675de2b29d006d74192a4>
