Skip to content
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

patchelf.cc: handle DT_MIPS_XHASH and .MIPS.xhash #380

Merged
merged 3 commits into from Jun 29, 2022
Merged

patchelf.cc: handle DT_MIPS_XHASH and .MIPS.xhash #380

merged 3 commits into from Jun 29, 2022

Conversation

ghost
Copy link

@ghost ghost commented Jun 19, 2022

glibc changed their ABI in commit 23c1c256ae7b0f010d0fcaff60682b620887b164 on 2019-Aug-29, by changing the structure of the .gnu.hash data on MIPS and moving it to a different section. We need to adapt to this change by glibc.

Closes #368

@ghost
Copy link
Author

ghost commented Jun 19, 2022

This fixes #368 on my testing setup.

Will reverify once I confirm that it fixes the QEMU-VM test case in that PR, but I'm pretty darn sure it will work.

Adam Joseph added 2 commits June 18, 2022 21:51
This commit adds two symbols (SHT_MIPS_XHASH and DT_MIPS_XHASH) found
in glibc, and updates the value of DT_MIPS_NUM.  These changes were
made to glibc in 23c1c256ae7b0f010d0fcaff60682b620887b164 on
29-Aug-2019.
glibc changed their ABI in commit
23c1c256ae7b0f010d0fcaff60682b620887b164 on 2019-Aug-29, by changing
the structure of the .gnu.hash data on MIPS and moving it to a
different section.  We need to adapt to this change by glibc.

Closes #368
src/patchelf.cc Outdated Show resolved Hide resolved
@ghost
Copy link
Author

ghost commented Jun 19, 2022

This bug has been sufficiently frustrating to track down that I want to make sure I've completely documented how to both (a) reproduce it and (b) verify that it is fixed. I'm currently running the commands below (which require quite a lot of rebuilding); as soon as they finish sometime tonight I will undraftify this PR. Thank you for your patience.

Instructions for verifying this bug, and the fact that it is indeed fixed (based on #368):

# Assumes you have set $NIX_PATH explicitly.  If not, do so.
cd $NIX_PATH/nixpkgs
git fetch https://github.com/a-m-joseph/nixpkgs patchelf-issue-368 # e642d58dd59d40d8b2062b5ac33d053aab37cfc6
git switch -c patchelf-issue-368 FETCH_HEAD

cd /tmp  # or elsewhere
git clone -b patchelf-issue https://github.com/a-m-joseph/mips64-nixpkgs-qemu # 69126a995bc8b6a2f33b80fd5cb456acdf8a6a07
cd mips64-nixpkgs-qemu
nix-shell shell.nix --argstr NIXPATH $NIX_PATH

Once the VM boots, type ./demo.sh and you should get a crash with Inconsistency detected by ld.so ... (bitmask_nwords & (bitmask_nwords - 1)) == 0 failed.

Then, shut down the VM, cherry-pick NixOS/nixpkgs@12618e7 into your $NIX_PATH/nixpkgs and run the nix-shell command above again; the bootstrap-tools should unpack correctly with no crash.

@ghost ghost marked this pull request as ready for review June 20, 2022 08:04
@ghost
Copy link
Author

ghost commented Jun 20, 2022

Yep, it works, and the steps above reproduce the problem and verify the fix.

@klemensn
Copy link
Contributor

Yep, it works, and the steps above reproduce the problem and verify the fix.

I have not reproduced your issue due to limited resources but the fix makes sense.

@ghost ghost requested a review from Mic92 June 21, 2022 21:17
@ghost
Copy link
Author

ghost commented Jun 28, 2022

Ping...

@Mic92 Mic92 merged commit 734daa3 into NixOS:master Jun 29, 2022
@ghost ghost deleted the pr/close/368 branch June 29, 2022 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants