Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dl: Use "adr" assembler command to get proper load address
This change is a partial revert of commit 66a613c5173456fe0edfa1a89147381d2802d4e4 which imposed usage of __ehdr_start linker variable to get the address of loaded program. The elf_machine_load_address() function is declared in the sysdeps/arm/dl-machine.h header. It is called from _dl_start() entry point for the program. It shall return the load address of the dynamic linker program. With this revert the 'adr' assembler instruction is used instead of a place holder: arm-poky-linux-gnueabi-objdump -t ld-linux-armhf.so.3 | grep ehdr 00000000 l .note.gnu.build-id 00000000 __ehdr_start which shall be pre-set by binutils. This is crucial in the QEMU ARM environment for which (when /sbin/init is executed) values set in __ehdr_start symbol are wrong. This causes the program to crash very early - when the /lib/ld-linux-armhf.so.3 is executed as a prerequisite to /sbin/init execution. The kernel's fs/binfmt_elf.c is though responsible for setting up execution environment, not binutils. It looks like the only robust way to obtain the _dl_start offset is to use assembler instruction - not rely on values provided by binutils. HW: Hardware name: ARM-Versatile Express (Run with QEMU) Tested (affected) kernels v5.1.12, v5.10.62 and v5.14.1 When the /sbin/init is setup for run from Linux kernel's very small environment with LD_DEBUG=all the __ehdr_start is not shown at all. Fixes: BZ #28293
- Loading branch information