git: da2d6e2815d7 - main - rtld: fix check for endianess of elf hints file
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 22 Mar 2024 13:55:25 UTC
The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=da2d6e2815d7694e3ccbd561508074c547b02dd6 commit da2d6e2815d7694e3ccbd561508074c547b02dd6 Author: Michael Tuexen <tuexen@FreeBSD.org> AuthorDate: 2024-03-22 13:50:25 +0000 Commit: Michael Tuexen <tuexen@FreeBSD.org> CommitDate: 2024-03-22 13:50:25 +0000 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 --- libexec/rtld-elf/rtld.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index fbf5b3e20a1f..3071eacbc995 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -2081,7 +2081,7 @@ gethints(bool nostdlib) uint32_t strtab; /* Offset of string table in file */ uint32_t dirlist; /* Offset of directory list in string table */ uint32_t dirlistlen; /* strlen(dirlist) */ - bool is_le; + bool is_le; /* Does the hints file use little endian */ bool skip; /* First call, read the hints file */ @@ -2108,7 +2108,7 @@ cleanup1: hdr.dirlistlen = 0; return (NULL); } - is_le = /*le32toh(1) == 1 || */ hdr.magic == ELFHINTS_MAGIC; + is_le = /*htole32(1) == 1 || */ hdr.magic == htole32(ELFHINTS_MAGIC); dbg("host byte-order: %s-endian", le32toh(1) == 1 ? "little" : "big"); dbg("hints file byte-order: %s-endian", is_le ? "little" : "big"); dbg("verify swap macros: le32toh(0x12345678) == %#010x, "