rtld: fix dlopen() for an object that is already mapped but not yet initialized

(cherry picked from commit 1005d3d053)
This commit is contained in:
Konstantin Belousov 2023-07-14 16:38:03 +03:00
parent 542497245d
commit 05e7db731d

View file

@ -3758,7 +3758,6 @@ static Obj_Entry *
dlopen_object(const char *name, int fd, Obj_Entry *refobj, int lo_flags,
int mode, RtldLockState *lockstate)
{
Obj_Entry *old_obj_tail;
Obj_Entry *obj;
Objlist initlist;
RtldLockState mlockstate;
@ -3775,7 +3774,6 @@ dlopen_object(const char *name, int fd, Obj_Entry *refobj, int lo_flags,
}
GDB_STATE(RT_ADD,NULL);
old_obj_tail = globallist_curr(TAILQ_LAST(&obj_list, obj_entry_q));
obj = NULL;
if (name == NULL && fd == -1) {
obj = obj_main;
@ -3788,9 +3786,9 @@ dlopen_object(const char *name, int fd, Obj_Entry *refobj, int lo_flags,
obj->dl_refcount++;
if (mode & RTLD_GLOBAL && objlist_find(&list_global, obj) == NULL)
objlist_push_tail(&list_global, obj);
if (globallist_next(old_obj_tail) != NULL) {
/* We loaded something new. */
assert(globallist_next(old_obj_tail) == obj);
if (!obj->init_done) {
/* We loaded something new and have to init something. */
if ((lo_flags & RTLD_LO_DEEPBIND) != 0)
obj->symbolic = true;
result = 0;