summaryrefslogtreecommitdiff
path: root/ldso/libdl
diff options
context:
space:
mode:
authorJoakim Tjernlund <joakim.tjernlund@transmode.se>2004-11-02 08:14:49 +0000
committerJoakim Tjernlund <joakim.tjernlund@transmode.se>2004-11-02 08:14:49 +0000
commitdc0f822bfed430e5b4f87f27c2e63171fa5fba28 (patch)
tree01eda5fa3c42d0c8b114f76622b4794a7735aa41 /ldso/libdl
parentf8f7b102217864ea382a46bb9ad173b3493e5cae (diff)
- Remove dynamic_size from struct elf_resolve.
- Replace all open coded dynamic handling with a function. Reduces size. - Fold special MIPS dynamic code into the dynamic_info item. - Add RELRO support. - Support linking with "-z now". - prepare for DT_RELACOUNT/DT_RELCOUNT optimization. - Add -z now to ld.so linking, this is what ld.so does anyway so let the linker know that.
Diffstat (limited to 'ldso/libdl')
-rw-r--r--ldso/libdl/libdl.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/ldso/libdl/libdl.c b/ldso/libdl/libdl.c
index 21dbd86ce..1bb68bdc8 100644
--- a/ldso/libdl/libdl.c
+++ b/ldso/libdl/libdl.c
@@ -47,6 +47,8 @@ extern struct elf_resolve * _dl_check_if_named_library_is_loaded(const char *, i
__attribute__ ((__weak__));
extern int _dl_fixup(struct dyn_elf *rpnt, int lazy)
__attribute__ ((__weak__));
+extern void _dl_protect_relro(struct elf_resolve * tpnt)
+ __attribute__ ((__weak__));
extern int _dl_errno __attribute__ ((__weak__));
extern struct dyn_elf *_dl_symbol_tables __attribute__ ((__weak__));
extern struct dyn_elf *_dl_handles __attribute__ ((__weak__));
@@ -128,7 +130,7 @@ void __attribute__ ((destructor)) dl_cleanup(void)
void *dlopen(const char *libname, int flag)
{
struct elf_resolve *tpnt, *tfrom, *tcurr;
- struct dyn_elf *dyn_chain, *rpnt = NULL, *dyn_ptr;
+ struct dyn_elf *dyn_chain, *rpnt = NULL, *dyn_ptr, *relro_ptr;
struct dyn_elf *dpnt;
ElfW(Addr) from;
struct elf_resolve *tpnt1;
@@ -168,6 +170,8 @@ void *dlopen(const char *libname, int flag)
tfrom = tpnt;
}
for(rpnt = _dl_symbol_tables; rpnt->next; rpnt=rpnt->next);
+
+ relro_ptr = rpnt;
/* Try to load the specified library */
#ifdef __SUPPORT_LD_DEBUG__
if(_dl_debug)
@@ -311,6 +315,10 @@ void *dlopen(const char *libname, int flag)
if (_dl_fixup(dyn_chain, now_flag))
goto oops;
+ for (rpnt = relro_ptr->next; rpnt; rpnt = rpnt->next) {
+ if (rpnt->dyn->relro_size)
+ _dl_protect_relro(rpnt->dyn);
+ }
/* TODO: Should we set the protections of all pages back to R/O now ? */