HomeFreeBSD

rtld-elf: support either byte-order of hints file

Description

rtld-elf: support either byte-order of hints file

Accept either little-endian or big-endian representation of the ELF
hints magic number in the header of a hints file and convert the
parameters to the native byte-order of the repsective system.

This is a pre-requisite for a planned change to always write the byte
order in little-endian format on all architectures. The only relvant
architecture that uses big-endian data is powerpc64, and it is not
likely that new architectures will choose that representation of data
in memory.

When all supported architectures use little-endian data in the hints
file, the byte swap logic can be enabled for big-endian CPUs at
compile time. Up to that point, there is a very small run-time penalty
that is paid on all systems to check the byte-order of the hints file
and to provide the option to byte-swap the parameters read from the
hints file header.

This commit contains the changes from review D44080 (which had been
split off from this patch for easier review),

Reviewed by: kib
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D44053

(cherry picked from commit 7b77d37a561b47db093a2528b8032dbfe5791698)

rtld-elf: add some debug print statements

The byte-order independent code has been reported to fail on powerpc64.
Add some more debug statements to help identify the parametrs used and
to verify the correct operation of the byte-swap macros used..

(cherry picked from commit 173953182af060dcab43990e179ee91e9f2d1e54)

rtld: fix check for endianess of elf hints file

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.

Reviewed by: se, kib (prior version of the patch)
Fixes: 7b77d37a561b ("rtld-elf: support either byte-order of hints")
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D44472

(cherry picked from commit da2d6e2815d7694e3ccbd561508074c547b02dd6)

rtld: reduce debug messages after fix on big-endian hosts

Remove a debug message that had been added to support the debugging
of a mis-detection of the hint files endianness on powerpc64.

MFC after: 3 days

(cherry picked from commit c44bf7d2e9d2292867f2e23f291266af26762354)

Details

Provenance
seAuthored on Feb 26 2024, 10:18 PM
Reviewer
rG7b77d37a561b: rtld-elf: support either byte-order of hints file
Differential Revision
D44053: Architecture independent ld-elf.so.hints file
Parents
rGb5e7969b239f: Translate linux_newlstat name argument
Branches
Unknown
Tags
Unknown