Loïc Minier loic.minier@linaro.org wrote on 08/02/2010 05:30:05 PM:
or more elegantly we could have a generic loader which checks the architecture of the target
ELF
file before calling the arch-specific loader. This loader would be linked to from all the old locations.
Well, but then what architecture would that generic loader be in? In
the
end, it has to be *something* the kernel understands to load natively.
Currently with binfmt_misc when the kernel loads a binary it will check whether it's the native architecture and if it is load the ELF dynamic linker referenced in the binary; if it matches one of the regexps from binfmt_misc, such as the binary pattern for ARM ELF binaries, it will call the binfmt interpreter instead, e.g. qemu-arm, and in this case qemu-arm will load the ELF runtime linker of the target binary to run the binary inside the CPU emulation.
Well, my point is that *qemu-arm* is itself an ELF binary, and the kernel must already know how to handle that. We can have user-space handlers to load secondary architectures that way -- but we cannot have a user-space handler required to load the *primary* architecture; how would that handler itself get loaded?
So I think this should just work; the kernel will call the native ELF loader of the current arch for binaries for the current arch, and will load QEMU which will load and emulate the ELF loader for the emulated arch in the other cases.
Maybe I misunderstood something else about your point then, so let's try and take a step back. Today, the location of the ELF loader is embedded into the executable itself, using a full pathname like /lib/ld.so.1. In a multiarch world, this pathname would violate packaging rules, because there are multiple different per-architecture versions of this file.
Thus I assumed the straightforward multiarch solution would be to move this file to multiarch locations like /lib/$(multiarch)/ld.so.1, which would require this new location to be embedded into all binaries.
I understood you to propose an alternative solution that would keep the old ELF interpreter name (/lib/ld.so.1) embedded in executables, and keep them working by installing some "common" loader at this location.
This caused me to wonder what that "common" loader was supposed to be, given that the kernel (for *any* architecture) would be required to be able to load that loader itself natively ...
Mit freundlichen Gruessen / Best Regards
Ulrich Weigand
-- Dr. Ulrich Weigand | Phone: +49-7031/16-3727 STSM, GNU compiler and toolchain for Linux on System z and Cell/B.E. IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martin Jetter | Geschäftsführung: Dirk Wittkopp Sitz der Gesellschaft: Böblingen | Registergericht: Amtsgericht Stuttgart, HRB 243294