summaryrefslogtreecommitdiff
path: root/src/ldso/dynlink.c
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2015-05-25 19:15:17 -0400
committerRich Felker <dalias@aerifal.cx>2015-05-25 19:15:17 -0400
commit768b82c6de24e480267c4c251c440edfc71800e3 (patch)
tree9b59e909041b2ad6ca35dad514ad9fa5c5379894 /src/ldso/dynlink.c
parent967bcbf67c3ffac587de4d79abc1e5e072d83e3e (diff)
downloadmusl-768b82c6de24e480267c4c251c440edfc71800e3.tar.gz
move call to dynamic linker stage-3 into stage-2 function
this move eliminates a duplicate "by-hand" symbol lookup loop from the stage-1 code and replaces it with a call to find_sym, which can be used once we're in stage 2. it reduces the size of the stage 1 code, which is helpful because stage 1 will become the crt start file for static-PIE executables, and it will allow stage 3 to access stage 2's automatic storage, which will be important in an upcoming commit.
Diffstat (limited to 'src/ldso/dynlink.c')
-rw-r--r--src/ldso/dynlink.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/ldso/dynlink.c b/src/ldso/dynlink.c
index 93595a0f..3842aeba 100644
--- a/src/ldso/dynlink.c
+++ b/src/ldso/dynlink.c
@@ -1116,7 +1116,7 @@ static void update_tls_size()
* linker itself, but some of the relocations performed may need to be
* replaced later due to copy relocations in the main program. */
-void __dls2(unsigned char *base)
+void __dls2(unsigned char *base, size_t *sp)
{
Ehdr *ehdr = (void *)base;
ldso.base = base;
@@ -1134,6 +1134,12 @@ void __dls2(unsigned char *base)
ldso.relocated = 0;
ldso.rel_update_got = 1;
+
+ /* Call dynamic linker stage-3, __dls3, looking it up
+ * symbolically as a barrier against moving the address
+ * load across the above relocation processing. */
+ struct symdef dls3_def = find_sym(&ldso, "__dls3", 0);
+ ((stage3_func)(ldso.base+dls3_def.sym->st_value))(sp);
}
/* Stage 3 of the dynamic linker is called with the dynamic linker/libc