3 ms·
The source code to the kernel's elf "binfmt"[0] is very readable. The elf binfmt is registered (along with a few others like `binfmt_misc`) and you get dispatch
by emidln 3y ago
The source code to the kernel's elf "binfmt"[0] is very readable. The elf binfmt is registered (along with a few others like `binfmt_misc`) and you get dispatched there via `exec_binprm`[1] which is invoked by the `execve` syscall[2]. When loading a shared library, you also dispatch to a binfmt via the `uselib`[3] syscall.
[0] https://github.com/torvalds/linux/blob/9fdfb15a3dbf818e06be514f4abbfc071004cbe7/fs/binfmt_elf.c#L823 https://github.com/torvalds/linux/blob/9fdfb15a3dbf818e06be5...
[1] https://github.com/torvalds/linux/blob/9fdfb15a3dbf818e06be514f4abbfc071004cbe7/fs/exec.c#L1764 https://github.com/torvalds/linux/blob/9fdfb15a3dbf818e06be5...
[2] https://github.com/torvalds/linux/blob/9fdfb15a3dbf818e06be514f4abbfc071004cbe7/fs/exec.c#L1812 https://github.com/torvalds/linux/blob/9fdfb15a3dbf818e06be5...
[3] https://github.com/torvalds/linux/blob/9fdfb15a3dbf818e06be514f4abbfc071004cbe7/fs/exec.c#L158 https://github.com/torvalds/linux/blob/9fdfb15a3dbf818e06be5...