Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 7 Jul 2025 07:34:43 +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:  <13cc141ff1b45a2c95c6aa722cdf22d4@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 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

[-- 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
@@ -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;

home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?13cc141ff1b45a2c95c6aa722cdf22d4>