mailing list of musl libc
 help / color / mirror / code / Atom feed
* [PATCH 1/3] ldso: when run via CLI, set auxv as if the app was loaded by the kernel
@ 2019-04-27  1:13 Rodger Combs
  2019-04-27  1:13 ` [PATCH 2/3] ldso: move (un)map_library functions to separate file Rodger Combs
  2019-04-27  1:13 ` [PATCH 3/3] crt: add dcrt1, with support for locating the dynamic loader at runtime Rodger Combs
  0 siblings, 2 replies; 13+ messages in thread
From: Rodger Combs @ 2019-04-27  1:13 UTC (permalink / raw)
  To: musl

---
 ldso/dynlink.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/ldso/dynlink.c b/ldso/dynlink.c
index 3d2e0d8..e311069 100644
--- a/ldso/dynlink.c
+++ b/ldso/dynlink.c
@@ -1794,6 +1794,22 @@ _Noreturn void __dls3(size_t *sp)
 			}
 			dprintf(1, "\t%s (%p)\n", ldso.name, ldso.base);
 		}
+
+		// Make it look to the app as if it was loaded by the kernel
+		for (i=0; auxv[i]; i+=2) {
+			if (auxv[i] == AT_BASE)
+				auxv[i + 1] = (size_t)ldso.base;
+			if (auxv[i] == AT_PHDR)
+				auxv[i + 1] = (size_t)app.phdr;
+			if (auxv[i] == AT_ENTRY)
+				auxv[i + 1] = aux[AT_ENTRY];
+			if (auxv[i] == AT_PHNUM)
+				auxv[i + 1] = app.phnum;
+			if (auxv[i] == AT_PHENT)
+				auxv[i + 1] = app.phentsize;
+			if (auxv[i] == AT_EXECFN)
+				auxv[i + 1] = (size_t)app.name;
+		}
 	}
 	if (app.tls.size) {
 		libc.tls_head = tls_tail = &app.tls;
-- 
2.7.4



^ permalink raw reply	[flat|nested] 13+ messages in thread
* [PATCH 1/3] ldso: when run via CLI, set auxv as if the app was loaded by the kernel
@ 2019-09-10  4:56 Rodger Combs
  2019-09-10  4:56 ` [PATCH 3/3] crt: add dcrt1, with support for locating the dynamic loader at runtime Rodger Combs
  0 siblings, 1 reply; 13+ messages in thread
From: Rodger Combs @ 2019-09-10  4:56 UTC (permalink / raw)
  To: musl

---
 ldso/dynlink.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/ldso/dynlink.c b/ldso/dynlink.c
index 5ef2111..22181e3 100644
--- a/ldso/dynlink.c
+++ b/ldso/dynlink.c
@@ -1805,6 +1805,22 @@ void __dls3(size_t *sp)
 			}
 			dprintf(1, "\t%s (%p)\n", ldso.name, ldso.base);
 		}
+
+		// Make it look to the app as if it was loaded by the kernel
+		for (i=0; auxv[i]; i+=2) {
+			if (auxv[i] == AT_BASE)
+				auxv[i + 1] = (size_t)ldso.base;
+			if (auxv[i] == AT_PHDR)
+				auxv[i + 1] = (size_t)app.phdr;
+			if (auxv[i] == AT_ENTRY)
+				auxv[i + 1] = aux[AT_ENTRY];
+			if (auxv[i] == AT_PHNUM)
+				auxv[i + 1] = app.phnum;
+			if (auxv[i] == AT_PHENT)
+				auxv[i + 1] = app.phentsize;
+			if (auxv[i] == AT_EXECFN)
+				auxv[i + 1] = (size_t)app.name;
+		}
 	}
 	if (app.tls.size) {
 		libc.tls_head = tls_tail = &app.tls;
-- 
2.7.4



^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2019-09-10  4:56 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-27  1:13 [PATCH 1/3] ldso: when run via CLI, set auxv as if the app was loaded by the kernel Rodger Combs
2019-04-27  1:13 ` [PATCH 2/3] ldso: move (un)map_library functions to separate file Rodger Combs
2019-04-27  1:13 ` [PATCH 3/3] crt: add dcrt1, with support for locating the dynamic loader at runtime Rodger Combs
2019-04-27  8:55   ` Szabolcs Nagy
2019-04-27 16:19     ` Rich Felker
2019-04-27 17:19   ` Rich Felker
2019-04-27 22:51     ` Rodger Combs
2019-04-27 23:55       ` Szabolcs Nagy
2019-04-28  0:16         ` Rodger Combs
2019-04-28 11:07           ` Szabolcs Nagy
2019-04-28 16:28             ` Rich Felker
2019-04-28 16:12       ` Rich Felker
2019-09-10  4:56 [PATCH 1/3] ldso: when run via CLI, set auxv as if the app was loaded by the kernel Rodger Combs
2019-09-10  4:56 ` [PATCH 3/3] crt: add dcrt1, with support for locating the dynamic loader at runtime Rodger Combs

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).