[PATCH 1/2] elf: Record original entry point in GLRO(dl_entry)
Florian Weimer
fweimer@redhat.com
Mon Jun 29 21:07:03 GMT 2026
This could be useful information for debugging purposes. On Linux,
the kernel-provided value in the auxilary vector is overwritten
by ld.so.
This is also the address that GDB uses on some architectures to
set the breakpoint on the return from an inferior function call.
---
elf/rtld.c | 1 +
sysdeps/generic/ldsodefs.h | 4 ++++
2 files changed, 5 insertions(+)
diff --git a/elf/rtld.c b/elf/rtld.c
index e5ba71fef1..cc813201dc 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -1366,6 +1366,7 @@ dl_main (const ElfW(Phdr) *phdr,
#endif
const char *ld_so_name = _dl_argv[0];
+ GLRO(dl_entry) = *user_entry;
if (*user_entry == (ElfW(Addr)) ENTRY_POINT)
{
/* Ho ho. We are not the program interpreter! We are the program
diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
index f94247ad9f..9bbc9f2c54 100644
--- a/sysdeps/generic/ldsodefs.h
+++ b/sysdeps/generic/ldsodefs.h
@@ -682,6 +682,10 @@ struct rtld_global_ro
/* Dynamic linker operations used after static dlopen. */
const struct dlfcn_hook *_dl_dlfcn_hook;
+ /* Original kernel-provided entry point. Could be the main program
+ or ld.so itself. */
+ ElfW(Addr) _dl_entry;
+
/* List of auditing interfaces. */
struct audit_ifaces *_dl_audit;
unsigned int _dl_naudit;
--
2.54.0
More information about the Libc-alpha
mailing list