Re: [PATCH 0/3] elf: load the main program from AT_EXECFD

Florian Weimer <[email protected]>
Newsgroups gmane.comp.lib.glibc.alpha
Message-ID <[email protected]>
* Christian Brauner:

> A Linux binfmt_misc handler can dispatch a program to a chosen dynamic
> linker.  This is how you run a program under a different or newer ld.so.

Ahem, you'd use an explicit ld.so invocation for that?

> When the handler is registered with the 'O' (open binary) or 'C'
> (credentials) flag, the kernel keeps the executed file open across the
> dispatch.  It hands the descriptor to the interpreter in the AT_EXECFD
> auxiliary vector entry.  This is the SVR4 contract.  AT_EXECFD is "the
> file descriptor of the program to load", the alternative to AT_PHDR.
> FreeBSD's rtld consumes it, and qemu-user has consumed it since 2013.
>
> The GNU dynamic linker never has.  When such a handler dispatches to
> ld.so, the descriptor is ignored.  It leaks into the new program.  ld.so
> opens the executable again, this time by the path spliced into the
> argument vector.

Adding this functionality to ld.so seems reasonable in principle.

What does /proc/self/exe look like for such processes?  Does GDB work?
There are two cases to consider: launching with GDB, and attaching GDB
to a running process with the -p option.

Thanks,
Florian
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.