Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F163335327
D26352.id93671.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D26352.id93671.diff
View Options
Index: libexec/rtld-elf/rtld.1
===================================================================
--- libexec/rtld-elf/rtld.1
+++ libexec/rtld-elf/rtld.1
@@ -143,6 +143,11 @@
.Nm
will print a table containing all relocations before symbol
binding and relocation.
+.It Ev LD_DYNAMIC_WEAK
+If set, use the non-standard traditional symbol lookup behavior: when a weak
+definition is found, remember the definition and keep searching in the
+remaining shared objects for a non-weak definition. If found, the non-weak
+definition is returned, otherwise the remembered weak definition is returned.
.It Ev LD_LIBMAP
A library replacement list in the same format as
.Xr libmap.conf 5 .
Index: libexec/rtld-elf/rtld.c
===================================================================
--- libexec/rtld-elf/rtld.c
+++ libexec/rtld-elf/rtld.c
@@ -209,6 +209,7 @@
bool ld_bind_not; /* Disable PLT update */
static char *ld_bind_now; /* Environment variable for immediate binding */
static char *ld_debug; /* Environment variable for debugging */
+static bool ld_dynamic_weak; /* True if non-weak definition overrides weak definition */
static char *ld_library_path; /* Environment variable for search path */
static char *ld_library_dirs; /* Environment variable for library descriptors */
static char *ld_preload; /* Environment variable for libraries to
@@ -591,6 +592,7 @@
ld_debug = getenv(_LD("DEBUG"));
if (ld_bind_now == NULL)
ld_bind_not = getenv(_LD("BIND_NOT")) != NULL;
+ ld_dynamic_weak = getenv(_LD("DYNAMIC_WEAK")) != NULL;
libmap_disable = getenv(_LD("LIBMAP_DISABLE")) != NULL;
libmap_override = getenv(_LD("LIBMAP"));
ld_library_path = getenv(_LD("LIBRARY_PATH"));
@@ -3673,11 +3675,11 @@
continue;
res = symlook_obj(&req, obj);
if (res == 0) {
- if (def == NULL ||
- ELF_ST_BIND(req.sym_out->st_info) != STB_WEAK) {
+ if (def == NULL || (ld_dynamic_weak &&
+ ELF_ST_BIND(req.sym_out->st_info) != STB_WEAK)) {
def = req.sym_out;
defobj = req.defobj_out;
- if (ELF_ST_BIND(def->st_info) != STB_WEAK)
+ if (!ld_dynamic_weak || ELF_ST_BIND(def->st_info) != STB_WEAK)
break;
}
}
@@ -4288,10 +4290,10 @@
symlook_init_from_req(&req1, req);
/* Search all objects loaded at program start up. */
- if (req->defobj_out == NULL ||
- ELF_ST_BIND(req->sym_out->st_info) == STB_WEAK) {
+ if (req->defobj_out == NULL || (ld_dynamic_weak &&
+ ELF_ST_BIND(req->sym_out->st_info) == STB_WEAK)) {
res = symlook_list(&req1, &list_main, donelist);
- if (res == 0 && (req->defobj_out == NULL ||
+ if (res == 0 && (!ld_dynamic_weak || req->defobj_out == NULL ||
ELF_ST_BIND(req1.sym_out->st_info) != STB_WEAK)) {
req->sym_out = req1.sym_out;
req->defobj_out = req1.defobj_out;
@@ -4301,8 +4303,8 @@
/* Search all DAGs whose roots are RTLD_GLOBAL objects. */
STAILQ_FOREACH(elm, &list_global, link) {
- if (req->defobj_out != NULL &&
- ELF_ST_BIND(req->sym_out->st_info) != STB_WEAK)
+ if (req->defobj_out != NULL && (!ld_dynamic_weak ||
+ ELF_ST_BIND(req->sym_out->st_info) != STB_WEAK))
break;
res = symlook_list(&req1, &elm->obj->dagmembers, donelist);
if (res == 0 && (req->defobj_out == NULL ||
@@ -4351,8 +4353,8 @@
/* Search all dlopened DAGs containing the referencing object. */
STAILQ_FOREACH(elm, &refobj->dldags, link) {
- if (req->sym_out != NULL &&
- ELF_ST_BIND(req->sym_out->st_info) != STB_WEAK)
+ if (req->sym_out != NULL && (!ld_dynamic_weak ||
+ ELF_ST_BIND(req->sym_out->st_info) != STB_WEAK))
break;
res = symlook_list(&req1, &elm->obj->dagmembers, &donelist);
if (res == 0 && (req->sym_out == NULL ||
@@ -4397,10 +4399,11 @@
continue;
symlook_init_from_req(&req1, req);
if ((res = symlook_obj(&req1, elm->obj)) == 0) {
- if (def == NULL || ELF_ST_BIND(req1.sym_out->st_info) != STB_WEAK) {
+ if (def == NULL || (ld_dynamic_weak &&
+ ELF_ST_BIND(req1.sym_out->st_info) != STB_WEAK)) {
def = req1.sym_out;
defobj = req1.defobj_out;
- if (ELF_ST_BIND(def->st_info) != STB_WEAK)
+ if (!ld_dynamic_weak || ELF_ST_BIND(def->st_info) != STB_WEAK)
break;
}
}
@@ -4435,10 +4438,11 @@
if (n->obj == NULL ||
(res = symlook_list(&req1, &n->obj->dagmembers, dlp)) != 0)
continue;
- if (def == NULL || ELF_ST_BIND(req1.sym_out->st_info) != STB_WEAK) {
+ if (def == NULL || (ld_dynamic_weak &&
+ ELF_ST_BIND(req1.sym_out->st_info) != STB_WEAK)) {
def = req1.sym_out;
defobj = req1.defobj_out;
- if (ELF_ST_BIND(def->st_info) != STB_WEAK)
+ if (!ld_dynamic_weak || ELF_ST_BIND(def->st_info) != STB_WEAK)
break;
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Jul 23, 5:50 AM (1 h, 27 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
35393708
Default Alt Text
D26352.id93671.diff (4 KB)
Attached To
Mode
D26352: rtld: Switch to the standard symbol lookup behavior if LD_DYNAMIC_WEAK=0
Attached
Detach File
Event Timeline
Log In to Comment