summaryrefslogtreecommitdiff
path: root/ldso/ldso/ldso.c
diff options
context:
space:
mode:
authorWaldemar Brodkorb <wbx@openadk.org>2015-01-25 02:20:43 -0600
committerWaldemar Brodkorb <wbx@openadk.org>2015-01-25 02:20:43 -0600
commit97dc8cb71d96a4bbfda0aa51740433d5da825b6a (patch)
tree664f0cf402d5adec7dc0983fa1755060e5656155 /ldso/ldso/ldso.c
parent9b723c4ea768f71fc0bc69ba467c6240d18adf35 (diff)
add support for $ORIGIN
This is for example required, used and tested with OpenJDK 7. No regressions found, while running the testsuite with embedded-test.
Diffstat (limited to 'ldso/ldso/ldso.c')
-rw-r--r--ldso/ldso/ldso.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/ldso/ldso/ldso.c b/ldso/ldso/ldso.c
index 56196292b..7367f1737 100644
--- a/ldso/ldso/ldso.c
+++ b/ldso/ldso/ldso.c
@@ -403,6 +403,20 @@ static ptrdiff_t _dl_build_local_scope (struct elf_resolve **list,
return p - list;
}
+static void _dl_setup_progname(const char *argv0)
+{
+ char image[PATH_MAX];
+ ssize_t s;
+
+ s = _dl_readlink(AT_FDCWD, "/proc/self/exe", image, sizeof(image));
+ if (s > 0 && image[0] == '/') {
+ image[s] = 0;
+ _dl_progname = _dl_strdup(image);
+ } else if (argv0) {
+ _dl_progname = argv0;
+ }
+}
+
void *_dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
ElfW(auxv_t) auxvt[AT_EGID + 1], char **envp, char **argv
DL_GET_READY_TO_RUN_EXTRA_PARMS)
@@ -454,9 +468,7 @@ void *_dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
* been fixed up by now. Still no function calls outside of this
* library, since the dynamic resolver is not yet ready.
*/
- if (argv[0]) {
- _dl_progname = argv[0];
- }
+ _dl_setup_progname(argv[0]);
#ifdef __DSBT__
_dl_ldso_dsbt = (void *)tpnt->dynamic_info[DT_DSBT_BASE_IDX];