Branch: refs/heads/master
  Home:   https://github.com/NixOS/patchelf
  Commit: c4deb5e9e1ce9c98a48e0d5bb37d87739b8cfee4
      
https://github.com/NixOS/patchelf/commit/c4deb5e9e1ce9c98a48e0d5bb37d87739b8cfee4
  Author: Richard Purdie <richard.pur...@linuxfoundation.org>
  Date:   2017-03-07 (Tue, 07 Mar 2017)

  Changed paths:
    M src/patchelf.cc

  Log Message:
  -----------
  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
(https://github.com/NixOS/patchelf/issues/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 <richard.pur...@linuxfoundation.org>


  Commit: 6bfcafbba8d89e44f9ac9582493b4f27d9d8c369
      
https://github.com/NixOS/patchelf/commit/6bfcafbba8d89e44f9ac9582493b4f27d9d8c369
  Author: Eelco Dolstra <edols...@gmail.com>
  Date:   2017-04-21 (Fri, 21 Apr 2017)

  Changed paths:
    M src/patchelf.cc

  Log Message:
  -----------
  Merge branch 'master' of https://github.com/rpurdie/patchelf


Compare: https://github.com/NixOS/patchelf/compare/e44c318b3705...6bfcafbba8d8
_______________________________________________
nix-commits mailing list
nix-comm...@lists.science.uu.nl
https://mailman.science.uu.nl/mailman/listinfo/nix-commits

Reply via email to