summaryrefslogtreecommitdiff
path: root/src/patchelf.h
Commit message (Collapse)AuthorAgeFilesLines
* Avoid <class ER> syntax in lambdas. Thats C++20Breno Rodrigues Guimaraes2023-02-221-7/+20
|
* Merge branch 'master' into breno.rename_symsJörg Thalheim2023-02-221-27/+36
|\
| * Declare more read-only functions constChristian Göttsche2023-02-211-4/+4
| |
| * Avoid implicit value truncations in wri()Christian Göttsche2023-02-211-4/+8
| | | | | | | | | | Abort on truncation of values being written to the ELF data, to prevent silent behavior mismatch.
| * Use C++ casts instead of raw C ones in hdr()Christian Göttsche2023-02-211-2/+2
| |
| * Drop unnecessary friend declarationsChristian Göttsche2023-02-211-4/+0
| |
| * Add misc functions annotationsChristian Göttsche2023-02-211-16/+16
| | | | | | | | Make the behavior of functions more explicit.
| * Add required includes in header fileChristian Göttsche2023-02-211-0/+9
| | | | | | | | | | Enable to parse the header file on its own, e.g. for language servers (clangd).
* | No need for both assert and exceptionBreno Rodrigues Guimaraes2023-02-211-5/+3
| |
* | Code polishing to use more spansBreno Rodrigues Guimaraes2023-02-211-2/+2
| |
* | Add out-of-range check for spanBreno Rodrigues Guimaraes2023-02-211-5/+12
| |
* | Add support for symbol name remappingBreno Rodrigues Guimaraes2023-02-201-2/+70
|/
* Add options to print, clear and set executable stack stateChristian Göttsche2023-01-281-1/+5
| | | | | | Add options the modify the state of the executable flag of the GNU_STACK program header. That header indicates whether the object is requiring an executable stack.
* Fix bug in file shifting that could cause conflicting PT_LOAD segmentsJason2022-12-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a section in the file needs to be enlarged (e.g. to accommodate setting a larger RPATH), shiftFile() is used to shift all content following the growing section to a later position in the file. Commit 109b771f53ee3d37ede8c0f165665605183c0975 introduced logic to ensure that, after the segment split, no sections span multiple segments. This is done by sliding the portion of the segment after the split point later in the file, then adding a new PT_LOAD segment that contains the preceding data plus the extra room that is being added. The existing implementation does this by simply adding `extraPages*getPageSize()` bytes to the number of bytes ahead of the split point in the segment. However, this approach can result in two PT_LOAD segments that overlap when page boundaries are taken into account. As an example, this PT_LOAD section (taken from a Python 3.10 binary): LOAD 0x0000000000000000 0x0000000000400000 0x0000000000400000 0x0000000000000948 0x0000000000000948 R E 0x200000 is split into the following two sections: LOAD 0x0000000000000000 0x00000000003ff000 0x00000000003ff000 0x0000000000001594 0x0000000000001594 R E 0x1000 LOAD 0x0000000000001594 0x0000000000400594 0x0000000000400594 0x00000000000003b4 0x00000000000003b4 R E 0x1000 Note that the two PT_LOAD sections both contain the memory page at address 0x400000. The Linux kernel's ELF loader (at least as of v4.18) does not accept this as a valid ELF executable, triggering a segfault with si_code=SI_KERNEL immediately when the binary is executed. The fix here is to set the length of the segment that comes before the split point more carefully; instead of adding `extraPages*getPageSize()` bytes to the portion of the segment that came before the split, the actual number of padding bytes that were needed (before rounding up to the next multiple of the page size) are used. This avoids the overlap in the PT_LOAD segments and makes the output files executable again.
* Rework file shifting to avoid sections crossing multiple segmentsBo Anderson2022-10-131-1/+1
| | | | Fixes #403.
* Add --print-os-abi and --set-os-abi optionsDmitry Moskalchuk2022-06-301-0/+4
| | | | | | | This commit adds an ability to print and change the EI_OSABI field of the ELF header. Signed-off-by: Dmitry Moskalchuk <dm@crystax.net>
* Update argument name to be more descriptivedeadwood2022-02-211-1/+1
|
* Add --add-debug optiondeadwood2022-02-201-0/+2
| | | | | | | | | | A shared library (-shared) by default does not receive DT_DEBUG tag. This means that when a shared library has an entry point (so that it can be run as an executable), the debugger does not connect to it correctly and symbols are not resolved. --add-debug option adds DT_DEBUG tag if it not yet present to an ELF object.
* Renamed findSection2 to tryFindSectionHeaderFarid Zakaria2021-12-211-23/+2
|
* Added patchelf.hFarid Zakaria2021-12-201-0/+180
Added a header file to make things easier to navigate. Renamed findSection3 -> getSectionIndex since thats more sensible to read. Renamed findSection -> findSectionHeader to better distinguish sections from headers.