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

Rebase of https://github.com/NixOS/patchelf/pull/237 #335

Merged
merged 2 commits into from
Nov 27, 2021
Merged

Conversation

Mic92
Copy link
Member

@Mic92 Mic92 commented Nov 27, 2021

fixes #237

When it happens that the .gnu.version_r stores the strings in .dynstr it can
come to corruption of the library names written into DT_NEEDED:

-the library names in DT_NEEDED are replaced, new entries are written to the end
 of .dynstr
-the version library names are replaced, and written to the end of the string
 section.

If the section for the version strings is also ".dynstr", the previous
modifications were _not_ taken into account and things were written from the old
end of .dynstr again. The order in which these strings were written is not the
same as the previous replacement, so things would end up with the same size, but
different offsets. The .gnu.version_r table is correct, the file contents are
fine, but the offsets in the DT_NEEDED entries are wrong. Since they are printed
as 0-terminated strings the first one replaced will always be shown correct,
which also is the case if the argument is only used once as the string is
replaced with itself afterwards.
This can happen especially if .gnu.version_r stores the strings in .dynstr, so
replacing the library names would add them twice to the same section. Keep a map
of what was already added and where, and simply reuse the old entries if they
are needed again.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants