Skip to content

Fixes for static PIE executables - #166

Open
rcombs wants to merge 2 commits into
NixOS:masterfrom
rcombs:dynamic-fixes
Open

rcombs wants to merge 2 commits into
NixOS:masterfrom
rcombs:dynamic-fixes

Conversation

@rcombs

@rcombs rcombs commented Mar 30, 2019

Copy link
Copy Markdown

Most notably, this attempts to avoid growing the dynamic section when adding an rpath, since that results in repositioning the section, which means that existing IP-relative references to the _DYNAMIC symbol will become invalid.

@rcombs rcombs changed the title Fixes for PIE executables Fixes for static PIE executables Mar 30, 2019
@domenkozar

Copy link
Copy Markdown
Member

@rcombs could you rebase?

rcombs and others added 2 commits June 16, 2020 13:51
Growing the section can require changing its position, which results in crashes
if the code relies on a symbol within it (e.g. _DYNAMIC). Instead, we can
usually find an entry that isn't actually required and replace it.
@rcombs

rcombs commented Jun 16, 2020

Copy link
Copy Markdown
Author

Done.

@Mic92

Mic92 commented Jul 31, 2020

Copy link
Copy Markdown
Member

It seems that PRs with tests are preferred :) #225

Comment thread src/patchelf.cc
if (isExecutable && startOffset > startPage) {
if (startOffset > startPage)
debug("shifting new PT_LOAD segment by %d bytes to work around a Linux kernel bug\n", startOffset - startPage);
startPage = startOffset;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This disables this mitigation?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, it unconditionally applies it...

Comment thread src/patchelf.cc
debug("shifting new PT_LOAD segment by %d bytes to work around a Linux kernel bug\n", startOffset - startPage);
startPage = startOffset;
}
startPage = startOffset;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand why isExecutable was removed as a conditional but not why startPage = startOffset was moved out.

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.

3 participants