Page MenuHomeFreeBSD

Add support for both big and little endian hints files to ldconfig
AbandonedPublic

Authored by se on Mar 25 2022, 8:11 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, May 16, 5:10 AM
Unknown Object (File)
Mon, May 6, 4:55 PM
Unknown Object (File)
Fri, May 3, 10:12 PM
Unknown Object (File)
Sun, Apr 28, 2:54 AM
Unknown Object (File)
Sat, Apr 27, 6:54 AM
Unknown Object (File)
Dec 22 2023, 11:45 PM
Unknown Object (File)
Aug 26 2023, 11:17 AM
Unknown Object (File)
Jun 24 2023, 8:13 AM
Subscribers

Details

Reviewers
kevans
bapt
Summary

The ldconfig command has traditionally only supported the hosts endianness.
This patch allows to specify the endianness of the hints file to be created, for example in order to update the hints for a non-native architecture in a qemu jail.
The options added to control the endianness of a new hints file are -64b and -64l (for big vs. little endian 64 bit architectures) respectively -32b and -32l for 32 bit.
This feature may be useful for the installation of packages in a non-native jail with the pkg command (which will have to pass the correct endianness option).

Test Plan

Verify that there are no regressions executing the previously supported use cases.
Create a hints file using the options "-64b" and "-64l" on a big-endian and a little-endian CPU and check hex dumps for correctness of the created files. (-32b and -32l differ only with regard to the default hints file name, but that should be specified with -f for these tests, anyway.)
Updating a little-endian hints file with -64b and a big-endian hints file with -64l is expected to fail with an error message.
The -r option will ignore the forced endianness and will detect the endianness of the hints file.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

se requested review of this revision.Mar 25 2022, 8:11 PM

Update the patch to use a COND_SWAP macro to conditionally reverse the byte order of the passed 32 bit integer value.
No functional change relative to the previous patch - but IMHO much easier to review and maintain in case of further changes.

Small fix: if there was no hints file in the "merge" case ("-R" or "-m" option used), the requested endianness could be ignored.

Also a clarification with regard to the "-R" option: it is only implied if there are no file or directory arguments.
The "-m" and "-R" options give completely identical results, BTW. This is not made obvious in the man-page.

"-R" could be described as just an alias of "-m" (merging with no additional files/directories results in a rescan).

A version based on these patches (but with slightly different command line options) has been discussed and accepted in review D44093.