-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support FreeBSD + avoid hard-coding excluded library versions #45
base: release/2.0
Are you sure you want to change the base?
Conversation
Summary/motivation of changes: - FreeBSD has `sys/auxv.h` but it does not have `getauxval`, and its equivalent does not have `AT_PLATFORM`. Luckily, we don't actually need this at all on FreeBSD since, unlike Linux, libraries aren't put into platform-prefixed directories. - `bash` is not installed by default and when it is, it does not live in `/bin`. Thus the integration tests shebang has been changed to use `/usr/bin/env bash`, which should work across platforms. - BSD `diff`, which macOS also uses, does not support the `--color` flag, so that now enabled only on Linux. - Rather than including versioned shared libraries in the exclusion list, we can list unversioned library names and strip any version number from the library currently being inspected. This accounts for cases like FreeBSD's `libc.so.7`, which would have to be added as another special case alongside Linux's `libc.so.6` otherwise.
Thanks Alex! This is great! I noticed a few more things, but that shouldn't block this PR:
|
Ah, good notes!
|
With this change, we use `getauxval` to get the platform on Linux when that function is available, and when it isn't, we use the POSIX `uname` to retrieve that info. The `utsname` struct gets passed around as well so that substitutions other than `$PLATFORM` can be applied downstream with only one additional function parameter.
Okay I figured out the BSD-specific substitutions but I don't love how I did it (passing around a |
Hm, another option is to work with a list of regexes + replacements For me AT_PLATFORM / .machine are equal strings but they're not the same pointer (I hoped the one would call the other :p) |
Oh true. I can implement that here if you think that'd be a better solution. I don't have much of an opinion. |
FYI, Linus Torvalds wrote this 17 years ago:
In Linux it goes roughly like this: #define ELF_PLATFORM <something in some arch/.../include/.../elf.h>
const char *k_platform = ELF_PLATFORM;
copy_to_user(u_platform, k_platform, len)
NEW_AUX_ENT(AT_PLATFORM, (elf_addr_t)(unsigned long)u_platform); |
Meanwhile though ... /* I'm not sure if we can use '-' here */
#define ELF_PLATFORM ("x86_64") 😆 |
Summary/motivation of changes:
sys/auxv.h
but it does not havegetauxval
, and its equivalent does not haveAT_PLATFORM
. Luckily, we don't actually need this at all on FreeBSD since, unlike Linux, libraries aren't put into platform-prefixed directories.bash
is not installed by default and when it is, it does not live in/bin
. Thus the integration tests shebang has been changed to use/usr/bin/env bash
, which should work across platforms.diff
, which macOS also uses, does not support the--color
flag, so that now enabled only on Linux.libc.so.7
, which would have to be added as another special case alongside Linux'slibc.so.6
otherwise.With these changes, libtree builds and passes all tests on FreeBSD 12.2 on x86_64.