Last active
December 27, 2015 11:39
-
-
Save dex4er/7319918 to your computer and use it in GitHub Desktop.
argv0 option for glibc dynamic linker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- eglibc-2.17.orig/elf/rtld.c 2012-10-10 17:35:46.000000000 +0200 | |
+++ eglibc-2.17/elf/rtld.c 2013-11-05 17:08:42.066912334 +0100 | |
@@ -932,6 +932,7 @@ | |
if (*user_entry == (ElfW(Addr)) ENTRY_POINT) | |
{ | |
+ char *forced_argv0 = NULL; | |
/* Ho ho. We are not the program interpreter! We are the program | |
itself! This means someone ran ld.so as a command. Well, that | |
might be convenient to do sometimes. We support it by | |
@@ -1003,6 +1004,14 @@ | |
_dl_argc -= 2; | |
INTUSE(_dl_argv) += 2; | |
} | |
+ else if (! strcmp (INTUSE(_dl_argv)[1], "--argv0") && _dl_argc > 2) | |
+ { | |
+ forced_argv0 = INTUSE(_dl_argv)[2]; | |
+ | |
+ _dl_skip_args += 2; | |
+ _dl_argc -= 2; | |
+ INTUSE(_dl_argv) += 2; | |
+ } | |
else | |
break; | |
@@ -1031,7 +1040,9 @@ | |
variable LD_LIBRARY_PATH\n\ | |
--inhibit-rpath LIST ignore RUNPATH and RPATH information in object names\n\ | |
in LIST\n\ | |
- --audit LIST use objects named in LIST as auditors\n"); | |
+ --audit LIST use objects named in LIST as auditors\n\ | |
+ in LIST\n\ | |
+ --argv0 STRING use STRING as argv[0]\n"); | |
++_dl_skip_args; | |
--_dl_argc; | |
@@ -1083,6 +1094,8 @@ | |
HP_TIMING_DIFF (load_time, start, stop); | |
} | |
+ if (forced_argv0 != NULL) _dl_argv[0] = forced_argv0; | |
+ | |
/* Now the map for the main executable is available. */ | |
main_map = GL(dl_ns)[LM_ID_BASE]._ns_loaded; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- /home/lauri/workarea/diablo_x86/OLD-1-lta27/pkgs_slow2/glibc-2.5.0/build-tree/glibc-2.5/elf/rtld.c 2006-09-29 19:56:15.000000000 +0300 | |
+++ rtld.c 2008-09-24 16:08:00.000000000 +0300 | |
@@ -894,6 +894,7 @@ | |
if (*user_entry == (ElfW(Addr)) ENTRY_POINT) | |
{ | |
+ const char *forced_argv0 = NULL; | |
/* Ho ho. We are not the program interpreter! We are the program | |
itself! This means someone ran ld.so as a command. Well, that | |
might be convenient to do sometimes. We support it by | |
@@ -958,6 +959,14 @@ | |
_dl_argc -= 2; | |
INTUSE(_dl_argv) += 2; | |
} | |
+ else if (! strcmp (INTUSE(_dl_argv)[1], "--argv0") && _dl_argc > 2) | |
+ { | |
+ forced_argv0 = INTUSE(_dl_argv)[2]; | |
+ | |
+ _dl_skip_args += 2; | |
+ _dl_argc -= 2; | |
+ INTUSE(_dl_argv) += 2; | |
+ } | |
else | |
break; | |
@@ -984,7 +993,8 @@ | |
--library-path PATH use given PATH instead of content of the environment\n\ | |
variable LD_LIBRARY_PATH\n\ | |
--inhibit-rpath LIST ignore RUNPATH and RPATH information in object names\n\ | |
- in LIST\n"); | |
+ in LIST\n\ | |
+ --argv0 STRING use STRING as argv[0]\n"); | |
++_dl_skip_args; | |
--_dl_argc; | |
@@ -1037,6 +1047,8 @@ | |
HP_TIMING_DIFF (load_time, start, stop); | |
} | |
+ if (forced_argv0 != NULL) _dl_argv[0] = forced_argv0; | |
+ | |
/* Now the map for the main executable is available. */ | |
main_map = GL(dl_ns)[LM_ID_BASE]._ns_loaded; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment