diff options
author | nate <nate@FreeBSD.org> | 1999-03-24 23:47:29 +0000 |
---|---|---|
committer | nate <nate@FreeBSD.org> | 1999-03-24 23:47:29 +0000 |
commit | aef7a6313eabad0684a90b9a879334debf3121cc (patch) | |
tree | 673fbb532f558b12ff9315d10ca9211fc8b91c47 /libexec/rtld-elf/rtld.c | |
parent | 49744ae917b1d49bd77a6009a2afa719abc35c55 (diff) | |
download | FreeBSD-src-aef7a6313eabad0684a90b9a879334debf3121cc.zip FreeBSD-src-aef7a6313eabad0684a90b9a879334debf3121cc.tar.gz |
- Commit the correct dladdr() implementation.
Reviewed by: jdp@FreeBSD.org <This is the version he reviewed!>
Diffstat (limited to 'libexec/rtld-elf/rtld.c')
-rw-r--r-- | libexec/rtld-elf/rtld.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index 02f9c20..11b2214 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -22,7 +22,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: rtld.c,v 1.13 1998/11/27 21:19:52 dfr Exp $ + * $Id: rtld.c,v 1.14 1999/03/24 23:37:35 nate Exp $ */ /* @@ -1268,13 +1268,13 @@ dladdr(const void *addr, Dl_info *info) void *symbol_addr; unsigned long symoffset; - obj = obj_from_addr(addr); + obj = obj_from_addr(addr); if (obj == NULL) { - _rtld_error("No shared object contains address"); + _rtld_error("No shared object contains address"); return 0; } info->dli_fname = obj->path; - info->dli_fbase = obj->relocbase; + info->dli_fbase = obj->mapbase; info->dli_saddr = (void *)0; info->dli_sname = NULL; @@ -1284,14 +1284,21 @@ dladdr(const void *addr, Dl_info *info) */ for (symoffset = 0; symoffset < obj->nchains; symoffset++) { def = obj->symtab + symoffset; - symbol_addr = obj->relocbase + def->st_value; + + /* + * For skip the symbol if st_shndx is either SHN_UNDEF or + * SHN_COMMON. + */ + if (def->st_shndx == SHN_UNDEF || def->st_shndx == SHN_COMMON) + continue; + /* *If the symbol is greater than the specified address, or if it * is further away from addr than the current nearest symbol, * then reject it. */ - if (symbol_addr > addr || - symbol_addr < info->dli_saddr) + symbol_addr = obj->relocbase + def->st_value; + if (symbol_addr > addr || symbol_addr < info->dli_saddr) continue; /* Update our idea of the nearest symbol. */ |