Eelco Dolstra
bf03aff2ea
Handle invalid symbol table entries that refer to non-existent sections
...
For instance, libcairo-swt.so from Eclipse SDK 4.2.2 has entries like:
30: 0000000000000000 0 SECTION LOCAL DEFAULT 30
even though there is no section 30. So ignore these.
2014-01-14 12:05:44 +01:00
David Sveningsson
ebe3087b0d
support -h in addition to --help
2013-12-17 21:03:47 +01:00
Jonas Kuemmerlin
ae5c6775e4
Add ability to add and replace DT_NEEDED entries
2013-04-28 16:42:01 +02:00
Eelco Dolstra
21828ee8cc
Remove debug statement
2013-01-16 23:50:13 +01:00
Eelco Dolstra
118897f030
Add ‘--remove-needed’ option
...
This allows removing the specified DT_NEEDED entries from the dynamic
section.
Closes #4 .
2013-01-16 23:42:21 +01:00
Eelco Dolstra
7c784881c8
Comment out overly verbose debug line
2012-08-21 15:30:22 -04:00
Eelco Dolstra
472deb3708
Rewrite the st_shndx field in symbol tables
...
The st_shndx field in symbol tables specifies the index of the section
that contains the symbol. Since we reorder sections, we need to
update this field as well. Otherwise programs like gdb won't be able
to resolve addresses to symbol names (and will print "?? ()" instead).
2012-08-21 15:21:39 -04:00
Eelco Dolstra
9b794ce691
Remove trailing whitespace
2012-08-21 13:40:43 -04:00
Eelco Dolstra
a9aa808a5c
* Support executables created by the Gold linker (NixOS/140). These
...
are marked as ET_DYN (not ET_EXEC) and have a starting virtual
address of 0 so they cannot grow downwards. In order not to run
into a Linux kernel bug, the virtual address and the offset of the
new PT_LOAD segment have to be equal; otherwise ld-linux segfaults.
To ensure this, it may be necessary to add some padding to the
executable (potentially a lot of padding, if the executable has a
large uninitialised data segment).
* Use size_t rather than off_t in some places.
2011-09-11 20:10:14 +00:00
Eelco Dolstra
87f4d86122
* Fix patching a little-endian binary on a big-endian machine. This
...
fixes the no-rpath test on powerpc-linux.
2010-08-26 12:42:30 +00:00
Eelco Dolstra
f78ceb5677
* Update DT_RELA.
2010-08-26 08:55:28 +00:00
Lluís Batlle i Rossell
396955bb71
I forgot in the last commit (enabling patchelf on the fuloong2f) to change some
...
4096 to the pageSize decided at the top of the module.
2010-07-29 18:47:24 +00:00
Lluís Batlle i Rossell
c050b32d98
Making patchelf work on a MIPS machine with 16KB page size (it's set in its kernel defconfig),
...
the Lemote Fuloong 2F.
2010-07-29 18:44:55 +00:00
Eelco Dolstra
deb109a105
* Segments can have a zero alignment, causing a divide-by-zero error.
...
Ignore those. (Contributed by Zack Weinberg.)
2010-04-06 09:11:42 +00:00
Eelco Dolstra
4bb6695abe
* Remove macros defined in elf.h.
2009-10-14 13:35:52 +00:00
Eelco Dolstra
c46c0ef3e5
* Include a copy of Glibc's elf.h so that we're not dependant on the
...
(lack of) elf.h on various platforms.
2009-10-14 13:34:14 +00:00
Eelco Dolstra
fc79f8a85a
* Use the e_type field instead of trying to guess whether we’re
...
dealing with an executable or dynamic library. Fixes NIXPKGS-98.
2009-06-16 15:34:12 +00:00
Eelco Dolstra
ae660b94d8
* When using --force-rpath and the executable already has a
...
DT_RUNPATH, get rid of it. Sometimes you really want a DT_RPATH
rather than a DT_RUNPATH, since the former is global (affects
the search path of dependencies as well) while the latter is local.
2009-05-07 15:05:34 +00:00
Eelco Dolstra
474641ca07
* Implement --version, --help.
2009-02-24 12:34:25 +00:00
Eelco Dolstra
ac63c25535
* Handle PT_LOAD program headers that become unaligned after adding
...
an extra page to the start of the file. The dynamic loader doesn't
like this (but the kernel doesn't mind).
2009-01-30 15:23:10 +00:00
Eelco Dolstra
d373d86ab3
* Don't clobber previously written sections.
2008-06-03 14:19:12 +00:00
Eelco Dolstra
55a701beb7
* Overwriting replaced sections with 'X's revealed a bug: we weren't
...
updating the DT_GNU_HASH field in the .dynamic section, which is a
problem when we move the .gnu.hash section.
2008-05-29 10:12:47 +00:00
Eelco Dolstra
7da11cac0b
* Ancient FreeBSD compat.
2008-05-29 10:05:27 +00:00
Eelco Dolstra
0c5f99f90a
* Support executables without a .dynamic section (klcc generates
...
'em).
2008-05-28 14:31:08 +00:00
Eelco Dolstra
0bba0e8b14
* More duplicate code removal.
2008-05-28 13:59:34 +00:00
Eelco Dolstra
656349fd15
* Removed some duplicate code (and work around an apparent g++ code
...
generation bug).
2008-05-28 13:19:46 +00:00
Eelco Dolstra
36f96d03db
* When reordering the section headers, the e_shstrndx field in the ELF
...
header should be updated as well.
2008-05-28 11:53:16 +00:00
Eelco Dolstra
1f713dd568
* Add the DT_RUNPATH (or DT_RPATH) entry to the top of the .dynamic
...
section, otherwise "readelf" barfs for unknown reasons.
2008-05-28 11:31:54 +00:00
Eelco Dolstra
15ba1450c3
* A first attempt at --set-rpath support for libraries. This is very
...
useful for the NVIDIA libGL.so, since setting an RPATH on libGL.so
to include its dependencies (like libXext and libGLcore) makes it
unnecessary to set an RPATH on the executables that use it. This is
especially important for executables that use RUNPATH (like Wine)
since there the paths in RUNPATH are ignored when resolving the
dependencies of dependencies (i.e. RUNPATH is scoped).
2008-05-28 09:19:49 +00:00
Eelco Dolstra
704c22c6a8
* Support DT_RUNPATH (in fact, prefer DT_RUNPATH over DT_RPATH unless
...
--force-rpath is set).
2008-05-27 16:23:21 +00:00
Eelco Dolstra
53f7311089
* Sort the program headers. This makes "strip" contain less about
...
the resulting executables (but unfortunately doesn't fix
NIXPKGS-85).
2008-05-27 14:05:53 +00:00
Eelco Dolstra
8f036ab190
* Typos.
2008-05-27 13:24:24 +00:00
Eelco Dolstra
b105af71c2
* patchelf: fix compilation on GCC 4.3.0.
2008-05-21 09:37:24 +00:00
Eelco Dolstra
d5cc557d2d
* Compilation fixes for FreeBSD 4.
2008-05-09 15:44:48 +00:00
Eelco Dolstra
de1f009cde
* Remove debug lines.
2007-12-07 11:32:47 +00:00
Eelco Dolstra
34835b2162
* Various 64-bit fixes. Computation of the first page to use was
...
incorrect if the ELF image maps everything above 2^32 (which seems
to be the case for IA-64, which has the code starting at
0x4000000000000000).
* IA-64 support. Not tested since I don't have an IA-64 machine, but
readelf doesn't complain about the resulting executable.
2007-12-07 11:29:08 +00:00
Eelco Dolstra
efa2a7ee24
* When sorting the sections, make sure that we maintain the sh_link
...
and sh_info fields. Tricky.
2007-02-01 00:25:29 +00:00
Eelco Dolstra
5cc8d9c439
* Keep the section headers sorted by offset. If we don't, we won't
...
correctly find the sections to be moved and some might be
overwritten.
2007-02-01 00:03:46 +00:00
Eelco Dolstra
8ed63404b2
* Support big endian binaries (such as on powerpc-linux).
2007-01-31 18:20:48 +00:00
Eelco Dolstra
94f38d26bc
* .rel.plt is called .rela.plt on x86_64-linux.
2007-01-31 15:08:42 +00:00
Eelco Dolstra
56cae84500
* Instantiate the right template depending on whether the file is 32
...
or 64 bits. (This is done at runtime, so patchelf can patch 32
*and* 64-bit executables on both 32 and 64-bit platforms).
2007-01-31 14:48:19 +00:00
Eelco Dolstra
f6a628b812
* Templatise the ElfFile class to take the Elf32_* types as
...
arguments. The idea is that we can just pass the Elf64_* types to
get a 64-bit version of the class.
2007-01-31 14:24:03 +00:00
Eelco Dolstra
a9fb3f9fbd
* Put the ELF operations in a class.
2007-01-31 13:50:07 +00:00
Eelco Dolstra
1c0e33852e
* Print error messages on stderr.
2007-01-31 12:13:13 +00:00
Eelco Dolstra
fc5cb4be7a
* Hack: if we can't find .rel.dyn, use .rel.got. No idea if this
...
makes sense.
2006-03-03 21:57:07 +00:00
Eelco Dolstra
c246daeeea
* --interpreter' ->
--set-interpreter'.
2005-10-11 13:05:08 +00:00
Eelco Dolstra
37cd5c8d04
* A `--debug' flag.
2005-10-04 13:11:16 +00:00
Eelco Dolstra
a36b2c6144
* Fix computation of the new start page.
2005-10-03 18:25:15 +00:00
Eelco Dolstra
df7806f982
* Use a bigger maximum size.
2005-10-02 20:57:56 +00:00
Eelco Dolstra
dd77b20708
* Handle the case where no RPATH is present, so the .dynamic table has
...
to be increased.
2005-10-01 01:05:50 +00:00