Subject: patches to add suport for dladdr
To: None <tech-toolchain@netbsd.org>
From: Scott Bartram <scottb@orionsoft.com>
List: tech-toolchain
Date: 01/30/2000 13:11:00
Anyone have a problem with this simple patch to add support for dladdr
to ELF binaries?
*** lib/csu/common_elf/common.c.orig Fri Jan 28 14:29:21 2000
--- lib/csu/common_elf/common.c Fri Jan 28 14:37:06 2000
***************
*** 61,66 ****
--- 61,67 ----
__weak_alias(dlclose,_dlclose);
__weak_alias(dlsym,_dlsym);
__weak_alias(dlerror,_dlerror);
+ __weak_alias(dladdr,_dladdr);
#endif
void
***************
*** 130,134 ****
--- 131,144 ----
if (__mainprog_obj == NULL)
return ("Dynamic linker interface not available");
return (__mainprog_obj->dlerror)();
+ }
+
+ int
+ dladdr(void *addr, Dl_info *dli)
+ {
+
+ if (__mainprog_obj == NULL)
+ return -1;
+ return (__mainprog_obj->dladdr)(addr, dli);
}
#endif /* DYNAMIC */
*** lib/csu/common_elf/common.h.orig Fri Jan 28 14:29:09 2000
--- lib/csu/common_elf/common.h Fri Jan 28 14:32:11 2000
***************
*** 42,47 ****
--- 42,48 ----
#define dlclose _dlclose
#define dlsym _dlsym
#define dlerror _dlerror
+ #define dladdr _dladdr
#endif
#include <dlfcn.h>
#include "rtld.h"
*** libexec/ld.elf_so/reloc.c.orig Fri Jan 28 14:02:29 2000
--- libexec/ld.elf_so/reloc.c Fri Jan 28 14:04:09 2000
***************
*** 625,630 ****
--- 625,631 ----
obj->dlsym = _rtld_dlsym;
obj->dlerror = _rtld_dlerror;
obj->dlclose = _rtld_dlclose;
+ obj->dladdr = _rtld_dladdr;
/* Set the special PLTGOT entries. */
if (obj->pltgot != NULL) {
*** libexec/ld.elf_so/rtld.h.orig Fri Jan 28 14:02:14 2000
--- libexec/ld.elf_so/rtld.h Fri Jan 28 23:37:34 2000
***************
*** 193,198 ****
--- 193,199 ----
void *(*dlsym) __P((void *, const char *));
char *(*dlerror) __P((void));
int (*dlclose) __P((void *));
+ int (*dladdr) __P((void *, Dl_info *));
int mainprog:1; /* True if this is the main program */
int rtld:1; /* True if this is the dynamic linker */