svn commit: trunk/uClibc/ldso: include libdl
vapier at uclibc.org
vapier at uclibc.org
Wed Jul 5 19:05:56 UTC 2006
Author: vapier
Date: 2006-07-05 12:05:55 -0700 (Wed, 05 Jul 2006)
New Revision: 15640
Log:
patch from Bernd Schmidt to abstract away load address checks
Modified:
trunk/uClibc/ldso/include/dl-defs.h
trunk/uClibc/ldso/libdl/libdl.c
Changeset:
Modified: trunk/uClibc/ldso/include/dl-defs.h
===================================================================
--- trunk/uClibc/ldso/include/dl-defs.h 2006-07-05 19:04:29 UTC (rev 15639)
+++ trunk/uClibc/ldso/include/dl-defs.h 2006-07-05 19:05:55 UTC (rev 15640)
@@ -75,4 +75,19 @@
((LOADADDR) = (BASEADDR))
#endif
+/* Test whether a given ADDR is more likely to be within the memory
+ * region mapped to TPNT (a struct elf_resolve *) than to TFROM.
+ * Everywhere that this is used, TFROM is initially NULL, and whenever
+ * a potential match is found, it's updated. One might want to walk
+ * the chain of elf_resolve to locate the best match and return false
+ * whenever TFROM is non-NULL, or use an exact-matching algorithm
+ * using additional information encoded in DL_LOADADDR_TYPE to test
+ * for exact containment.
+ */
+#ifndef DL_ADDR_IN_LOADADDR
+# define DL_ADDR_IN_LOADADDR(ADDR, TPNT, TFROM) \
+ ((void*)(TPNT)->loadaddr < (void*)(ADDR) \
+ && (!(TFROM) || (TFROM)->loadaddr < (TPNT)->loadaddr))
+#endif
+
#endif /* _LD_DEFS_H */
Modified: trunk/uClibc/ldso/libdl/libdl.c
===================================================================
--- trunk/uClibc/ldso/libdl/libdl.c 2006-07-05 19:04:29 UTC (rev 15639)
+++ trunk/uClibc/ldso/libdl/libdl.c 2006-07-05 19:05:55 UTC (rev 15640)
@@ -175,8 +175,7 @@
tfrom = NULL;
for (dpnt = _dl_symbol_tables; dpnt; dpnt = dpnt->next) {
tpnt = dpnt->dyn;
- if (tpnt->loadaddr < from
- && (tfrom == NULL || tfrom->loadaddr < tpnt->loadaddr))
+ if (DL_ADDR_IN_LOADADDR(from, tpnt, tfrom))
tfrom = tpnt;
}
}
@@ -436,8 +435,7 @@
tfrom = NULL;
for (rpnt = _dl_symbol_tables; rpnt; rpnt = rpnt->next) {
tpnt = rpnt->dyn;
- if (tpnt->loadaddr < from
- && (tfrom == NULL || tfrom->loadaddr < tpnt->loadaddr)) {
+ if (DL_ADDR_IN_LOADADDR(from, tpnt, tfrom)) {
tfrom = tpnt;
handle = rpnt->next;
}
@@ -664,10 +662,8 @@
fprintf(stderr, "Module \"%s\" at %p\n",
tpnt->libname, tpnt->loadaddr);
#endif
- if (tpnt->loadaddr < (ElfW(Addr)) __address
- && (pelf == NULL || pelf->loadaddr < tpnt->loadaddr)) {
+ if (DL_ADDR_IN_LOADADDR((ElfW(Addr)) __address, tpnt, pelf))
pelf = tpnt;
- }
}
if (!pelf) {
More information about the uClibc-cvs
mailing list