Don't check if the elf hints file is in host byte order, but check if it is in little endian by looking at the magic number.
This fixes rtld on big endian platforms.
Differential D44472
rtld: fix check for endianess of elf hints file tuexen on Mar 22 2024, 10:03 AM. Authored by Tags None Referenced Files
Details
Don't check if the elf hints file is in host byte order, but check if it is in little endian by looking at the magic number. This fixes rtld on big endian platforms.
Diff Detail
Event TimelineComment Actions Thank you for finding the logic error. The commented out extra condition was meant to be enabled in a future update to make little-endian systems assign a constant to is_le and to let constant expression evaluation effectively remove the conditional byte swap on them. Since the code has now been tested and fixed on big-endian architectures, I'm going to enable that test (or add it back enabled, in case you have already removed it). Comment Actions My understanding is that is_le is true, iff the byte order of the hints file is little endian, not if the host byte order Using your condition would result in is_le being true if the host byte order is little endian or the file byte order
Comment Actions Yes, the plan was to switch FreeBSD to always use a little-endian hints file on all architectures (i.e., all except powerpc64, currently).
If we actually switch to little-endian hints files on all hosts (pending a change in ldconfig - see the comment in line 298 of ldconfig/elfhints.h), then there is no reason to support big-endian hints files on little-endian architectures.
I'd appreciate if you left the commented-out condition as-is, since I plan to enable it to remove the run-time penalty of compiling in this flexibility on little-endian machines. Comment Actions What is the plan?
Sure. But why not just use the host byte order? I'm confused.
What about 32-bit PPC? Why would you use a hints file not in host byte order?
Comment Actions Add a comment describing the semantic of is_le and bring back a check for the host byte order. Comment Actions Please commit with a relative short MFC delay (e.g. 1 week).
|