diff options
author | Mark Johnston <markj@FreeBSD.org> | 2021-01-10 22:46:32 +0000 |
---|---|---|
committer | Mark Johnston <markj@FreeBSD.org> | 2021-01-10 22:58:38 +0000 |
commit | d00431a7bd0c4b4607943baed588e58ad5ae6150 (patch) | |
tree | 79695fa96c85c3be4f2a4582e5162c9af89581d5 /cddl | |
parent | 55f0ad5fdee1a779d6889481ba591a819081b9ca (diff) | |
download | src-d00431a7bd0c4b4607943baed588e58ad5ae6150.tar.gz src-d00431a7bd0c4b4607943baed588e58ad5ae6150.zip |
libdtrace: Format USDT symbols correctly based on symbol binding
Before we did not handle weak symbols correctly, sometimes resulting in
link errors from dtrace -G when processing object files where functions
with weak aliases contain USDT probes.
Reported by: rlibby
Tested by: rlibby
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Diffstat (limited to 'cddl')
-rw-r--r-- | cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c index 8f32890057f0..0b3dac0224f9 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c @@ -1344,18 +1344,24 @@ process_obj(dtrace_hdl_t *dtp, const char *obj, int *eprobesp) /* * Aliases of weak symbols don't get a uniquifier. */ - if (GELF_ST_BIND(fsym.st_info) == STB_WEAK) + if (GELF_ST_BIND(fsym.st_info) == STB_WEAK) { len = snprintf(NULL, 0, dt_weaksymfmt, dt_symprefix, s) + 1; - else + } else { len = snprintf(NULL, 0, dt_symfmt, dt_symprefix, objkey, s) + 1; + } if ((p = dt_alloc(dtp, len)) == NULL) { dt_strtab_destroy(strtab); goto err; } - (void) snprintf(p, len, dt_symfmt, dt_symprefix, - objkey, s); + if (GELF_ST_BIND(fsym.st_info) == STB_WEAK) { + (void) snprintf(p, len, dt_weaksymfmt, + dt_symprefix, s); + } else { + (void) snprintf(p, len, dt_symfmt, dt_symprefix, + objkey, s); + } if (dt_strtab_index(strtab, p) == -1) { /* |