-
Notifications
You must be signed in to change notification settings - Fork 261
Use dl_iterate_phdr on Haiku #699
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
base: master
Are you sure you want to change the base?
Conversation
An implementation or dl_iterate_phdr was added to Haiku a little over a year after Haiku support got added to backtrace-rs.
Haiku's dynamic linker (/system/runtime_loader) doesn't support getting directly invoked rather than going through PT_INTERP.
Repos often delete package versions soon after a new version is available. If the package list still references an old version, apt will error when trying to install the package.
cc @nielx |
We don't have an official Haiku maintainer enrolled it seems, so if either @waddlesplash or @trungnt2910 (or whoever else, basically) think this is good then I'm happy to ship it. |
Should be fine; internally Also note that |
Hmm, I just looked at the code some more, and it appears that when |
Agreed with @waddlesplash here. |
Huh, why didn't the backtrace-rs tests fail on Haiku with this PR if that is the case? |
In the PR you are disabling one of the tests. How did it fail? |
This test reads the dynamic linker from the test executable and then invokes the dynamic linker as executable with the teste executable as argument. I got confirmation from @waddlesplash that this is fundamentally unsupported on Haiku.
Ah, could well be that there are simply no tests for resolving symbols in shared libraries. |
There are but they're only run on some OS, I think? Access to |
I will review the code again to confirm my understanding of our own library and then, assuming I am correct, merge this. |
Well, that should be checked on Haiku to make sure this doesn't regress. Is it really so bad to just use the Haiku-specific API that provides this information directly? |
Well, I always prefer having more shared code to reason about, so that testing other OS also tests Haiku, you see? But if Haiku has a significant functionality gap here based on what APIs are used, such that it cannot reuse certain shared paths, then I'm happy to keep using Haiku-specific APIs. I just would kind of hope that if a function exists in its libc then calling it, uh, works? |
Oh, I see, there's two libc-ish objects, cool. That's fine, but we link in libbsd.so? Hmm. Is that desirable or not? Is libbsd.so necessary for other POSIX support, like pthreads? If so, then yes we absolutely require it forever and ever and we can just say we need both libbsd and libroot. |
It works fine, but the
No, it's not. Only "BSD-style" APIs that are not in POSIX (and which Haiku has found it useful to provide) are in libbsd.so (besides |
Right, okay, I had not finished my coffee before saying things. Currently reading https://www.haiku-os.org/legacy-docs/bebook/TheKernelKit_Images.html Oh wow the |
I see! If libroot.so is considered essential (it sure seems to be) and libbsd.so is considered an optional component of the OS, and Rust has no loss of functionality on the platform using libroot.so, then we would probably prefer to only link against libroot.so in actual fact. Less things to link and load is an obvious good, after all. There's always a balance of "well, if things are greatly simplified by simply using the BSD way on Haiku, then use the BSD way", of course. But it sounds like the gains are pretty marginal, and we generally prefer to lean heavily on POSIX APIs when we are trying to maximize the cross-platformness of our code. |
Yes, indeed. (Also note that Haiku provides the more-standard
Yes it is; the syscall hooks are all in
Well, it's shipped in the same base package as
Right, makes sense; only there's no POSIX API to enumerate all mappings of a process, and I don't think there's a "generally accepted" BSD/GNU one either, i.e. that is the same on at least 2 BSDs if not also Linux libcs. (If I'm mistaken and there is one, then we could probably implement that for convenience.) |
Then it sounds like avoiding libbsd.so is also pretty marginal in gain! It's still always nice that if someone's going to link it in anyway, that it be the thing that actually needs it and not everyone else, so that things don't wind up creating an implicit dependency on something being in the address space that isn't actually required nor guaranteed, but yanno.
Yeah, I think |
If you need/want more information here than |
So, getting back to this, my main question:
It seems to me that It is certainly true that it is the ELF sections that we actually care about, and those correspond better to the mappings. This is partly because DWARF carves the world into sections, and we are trying to peer into various sections to get information about other sections. |
For note, backtrace-rs currently assumes (possibly incorrectly) that once we have obtained the right actual virtual address for the base of a LibrarySegment, that we can assume that |
Also, apologies if I seem increasingly puzzled about things that seem "obvious". Adopting maintainership of backtrace-rs has mostly been an exercise in unlearning assumptions about what is true. That is sometimes including whether the code is correct. |
I haven't dug into backtrace-rs in detail, just enough to see that it's reading the map information from |
Using The use of those MapsEntry structures was primarily introduced to handle the |
An implementation or dl_iterate_phdr was added to Haiku in haiku/haiku@908107a a little over a year after Haiku support got added to backtrace-rs.