From 6d6f3a5c26adcf6b105edfb4b53e97ceee81944c Mon Sep 17 00:00:00 2001 From: Joakim Tjernlund Date: Tue, 17 Aug 2004 13:37:54 +0000 Subject: Let ldso decide if it should relocate itselft a second time. This is needed if ldso should use libcs malloc whenever possible. Fix RTLD_LAZY propagation to RTLD_NOW relocation when requested by libdl. --- ldso/libdl/Makefile | 2 +- ldso/libdl/libdl.c | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'ldso/libdl') diff --git a/ldso/libdl/Makefile b/ldso/libdl/Makefile index f10510f51..471b8b554 100644 --- a/ldso/libdl/Makefile +++ b/ldso/libdl/Makefile @@ -71,7 +71,7 @@ libdl_pic.o: libdl.c $(OBJ): Makefile -shared: +shared: $(TOPDIR)lib/$(LIBDL_SHARED_FULLNAME) $(LD) $(LDFLAGS) -soname=$(LIBDL_SHARED).$(MAJOR_VERSION) \ -o $(LIBDL_SHARED_FULLNAME) -fini dl_cleanup --whole-archive $(LIBDL_PIC) \ --no-whole-archive $(TOPDIR)/libc/misc/internals/interp.o \ diff --git a/ldso/libdl/libdl.c b/ldso/libdl/libdl.c index fd72509d0..d1274e3ff 100644 --- a/ldso/libdl/libdl.c +++ b/ldso/libdl/libdl.c @@ -134,6 +134,7 @@ void *dlopen(const char *libname, int flag) ElfW(Addr) from; struct elf_resolve *tpnt1; void (*dl_brk) (void); + int now_flag; /* A bit of sanity checking... */ if (!(flag & (RTLD_LAZY|RTLD_NOW))) { @@ -188,7 +189,7 @@ void *dlopen(const char *libname, int flag) dyn_chain = (struct dyn_elf *) malloc(sizeof(struct dyn_elf)); _dl_memset(dyn_chain, 0, sizeof(struct dyn_elf)); dyn_chain->dyn = tpnt; - dyn_chain->flags = flag; + tpnt->rtld_flags |= RTLD_GLOBAL; dyn_chain->next_handle = _dl_handles; _dl_handles = dyn_ptr = dyn_chain; @@ -219,6 +220,7 @@ void *dlopen(const char *libname, int flag) _dl_memset (dyn_ptr->next, 0, sizeof (struct dyn_elf)); dyn_ptr = dyn_ptr->next; dyn_ptr->dyn = tpnt1; + tpnt->rtld_flags |= RTLD_GLOBAL; if (!tpnt1) { tpnt1 = _dl_load_shared_library(0, &rpnt, tcurr, lpntstr, 0); if (!tpnt1) @@ -254,7 +256,10 @@ void *dlopen(const char *libname, int flag) * Now we go through and look for REL and RELA records that indicate fixups * to the GOT tables. We need to do this in reverse order so that COPY * directives work correctly */ - if (_dl_fixup(dyn_chain, dyn_chain->flags)) + now_flag = (flag & RTLD_NOW) ? RTLD_NOW : 0; + if (getenv("LD_BIND_NOW")) + now_flag = RTLD_NOW; + if (_dl_fixup(dyn_chain, now_flag)) goto oops; /* TODO: Should we set the protections of all pages back to R/O now ? */ -- cgit v1.2.3