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

Local patches for patchelf 0.9 #2

Merged
merged 5 commits into from
Apr 10, 2019

Commits on Mar 28, 2019

  1. no-rpath-prebuild: force pagesize to 4096 on prebuilt binaries

    They all have that page size, and the host-detected one might be
    different.
    fsateler authored and Claudio Matsuoka committed Mar 28, 2019
    Configuration menu
    Copy the full SHA
    702cb04 View commit details
    Browse the repository at this point in the history
  2. Fix issue NixOS#66 by ignoring the first section header when sorting,…

    … and not overwriting NOBITS entries.
    ezquat authored and Claudio Matsuoka committed Mar 28, 2019
    Configuration menu
    Copy the full SHA
    0f87d7f View commit details
    Browse the repository at this point in the history
  3. Avoid inflating file sizes needlessly and allow binaries to be stripped

    The current approach to changing sections in ET_DYN executables is to move
    the INTERP section to the end of the file. +This means changing PT_PHDR to
    add an extra PT_LOAD section so that the new section is mmaped into memory
    by the elf loader in the kernel. In order to extend PHDR, this means moving
    it to the end of the file.
    
    Its documented in BUGS there is a kernel 'bug' which means that if you have holes
    in memory between the base load address and the PT_LOAD segment that contains PHDR,
    it will pass an incorrect PHDR address to ld.so and fail to load the binary, segfaulting.
    
    To avoid this, the code currently inserts space into the binary to ensure that when
    loaded into memory there are no holes between the PT_LOAD sections. This inflates the
    binaries by many MBs in some cases. Whilst we could make them sparse, there is a second
    issue which is that strip can fail to process these binaries:
    
    $ strip fixincl
    Not enough room for program headers, try linking with -N
    [.note.ABI-tag]: Bad value
    
    This turns out to be due to libbfd not liking the relocated PHDR section either
    (NixOS#10).
    
    Instead this patch implements a different approach, leaving PHDR where it is but extending
    it in place to allow addition of a new PT_LOAD section. This overwrites sections in the
    binary but those get moved to the end of the file in the new PT_LOAD section.
    
    This is based on patches linked from the above github issue, however whilst the idea
    was good, the implementation wasn't correct and they've been rewritten here.
    
    Signed-off-by: Richard Purdie <[email protected]>
    (cherry picked from commit c4deb5e)
    Signed-off-by: Claudio Matsuoka <[email protected]>
    rpurdie authored and cmatsuoka committed Mar 28, 2019
    Configuration menu
    Copy the full SHA
    b07897f View commit details
    Browse the repository at this point in the history
  4. build: set c++ compiler standard to c++11

    Signed-off-by: Claudio Matsuoka <[email protected]>
    cmatsuoka committed Mar 28, 2019
    Configuration menu
    Copy the full SHA
    4a4e8d0 View commit details
    Browse the repository at this point in the history

Commits on Apr 10, 2019

  1. fix adjusting startPage

    startPage is adjusted unconditionally for all executables.
    This results in incorrect addresses assigned to INTERP and LOAD
    program headers, which breaks patched executable.
    
    Adjusting startPage variable only when startOffset > startPage
    should fix this.
    
    This change is related to the issue NixOS#10
    
    Signed-off-by: Ed Bartosh <[email protected]>
    Ed Bartosh authored and cmatsuoka committed Apr 10, 2019
    Configuration menu
    Copy the full SHA
    27c0ba1 View commit details
    Browse the repository at this point in the history