-
-
Notifications
You must be signed in to change notification settings - Fork 315
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
Surgical linker can not link absolute relocations #3609
Comments
So we are hitting a few things here and I am trying to untaggle the issue so I can fix it. The main things I am seeing:
So I guess the summary is annoying dependency stuff. @folkertdev any thoughts on this? |
we always compile the builtins with also, zig defines |
Ok. So I think my comment was slightly off. Let me expand. The final Anyway, due to compiling with As for compiler-rt, maybe we just aren't adding it correctly. It doesn't seem that zig is automatically adding the compiler-rt functions. Instead it assumes we are linking the compiler-rt functions. Which I think is why we manually had to add |
Oh, actually the compiler-rt issue looks to just be that we don't tell zig to bundle compiler-rt. I will put up a fix PR for that. EDIT: Can't do this until the surgical linker bug below is fixed. Otherwise it pretty consistently breaks the surgical linker. |
Oh, So adding more detail here just to offload it from my memory: For
Note: this should also enable better constants in roc. Currently we can't have a true const string, but fixing this would fix that. |
we suspect #3827 is related too |
a minimal reproducing example (using just zig) https://gist.github.com/folkertdev/23b121dce858ebebf42b9eec742fdaec |
Give an error message when the surgical linker #3609
I am finally looking into this. We shall see how it goes. Currently just looking at moving the Just have to get past all of the segfaults while loading the modified binary first. I debated just duplicating the section instead of moving it to avoid all of the offset modification pains, but the section can actually get quite large. Don't want to force extra bloat into all binaries. |
Made some progress. Got a few apps to compile with a moved dynamic section. Then tried to make it work in the general case and broke things. Probably gonna be a good amount of bit twiddling and minor adjustments before I get this move working for all apps. That said, definitely possible given I had it working for one app for a bit. Hopefully, I can find the right combination quickly to get this all passing and updating each address in the correct way. Once that is done, I think expanding the table should be rather simple. The main annoyance with this work is that I get a lot of SegEnv where the app doesn't load at all, and that is not easy to debug. |
So I'm not sure what zig does differently than rust and c, but currently I have some zig hosts working with the section moved to the end of the file. I think the ones that don't work are broken due to shifting of alignment of some data. Which breaks when zig tries to load it using vector instructions. So theoretically zig host could work properly with the change, but they need some vector data alignment based fixes. As for rust and c, really not sure. They crash before ever getting to any app code. The dynamic linker fails while trying to load them |
Another update. Zig platforms definitely fully work except for the alignment issue for vector instructions (that said, I am still using zig 9). I was able to get a complex zig platform to work. It runs in debug builds where the alignment just happens to be correct. In release builds, it fails because of alignment issues, but the app runs until hitting a vector instruction. |
Not sure if that is the place for it, but:
Adding
Can you add these cases to the error message b306c9a for the sake of future users? |
Thanks for you suggestion @HajagosNorbert, I made #5492 for it. Sorry for the late reply btw, I just happened to come across this message now. |
Just leaving this info here; the json example now produces this error since the zig-11-llvm-16 merge.
|
Since I haven't touched this in a long time and I am not sure when I will attempt it again, I want to just write out a list of what I think would be the best way to deal with this as a whole (with my current understanding). Hopefully this information is correct, but this is from very old memory and a partial understanding of the proper solution. My last branch I was working on ended up dying because I 1) got into a mess of offsets and 2) made some wrong assumption around moving sections that lead to me moving things wrong and a lot of breakage. If I were to work on this today, my goals would be:
|
Cause:
This does work with
--linker=legacy
. Could this be a surgical linker issue @bhansconnect or is the true cause coming from somewhere else?The text was updated successfully, but these errors were encountered: