[prev in list] [next in list] [prev in thread] [next in thread]
List: musl
Subject: [musl] [PATCH 2/4] ldso: when run via CLI, set auxv as if the app was loaded by the kernel
From: rcombs <rcombs () rcombs ! me>
Date: 2020-03-29 0:19:26
Message-ID: 1585441168-23444-2-git-send-email-rcombs () rcombs ! me
[Download RAW message or body]
---
ldso/dynlink.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/ldso/dynlink.c b/ldso/dynlink.c
index c378f00..5f637fd 100644
--- a/ldso/dynlink.c
+++ b/ldso/dynlink.c
@@ -1811,6 +1811,22 @@ void __dls3(size_t *sp, size_t *auxv)
}
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
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic