| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
For ELF files with more than SHN_LOWRESERVE sections we always need
section zero to store the section number (it doesn't just fit in the
Ehdr e_shnum field). Make sure to create it if it doesn't exist yet
in elf_getscn. Also fix handling on shnum in updatefile for the mmap
case (we already got this correct for the non-mmap case).
This adds a new test run-copymany-sections.sh which is like
run-copyadd-sections.sh but tries to add two times 65535 sections.
It makes sure libelf can copy the whole file and elfcmp checks they
are the same. It doesn't use mmap for addsections since that doesn't
work yet. ELF_C_RDWR_MMAP needs mremap which will fail since it needs
too much space and the original mmap cannot move.
Signed-off-by: Mark Wielaard <mark@klomp.org>
|
| |
| |
| |
| |
| |
| |
| |
| | |
elfcmp would use the Ehdr e_shstrndx field to find the shdr string
index table. Use elf_getshdrstrndx instead to be able to handle ELF
files with more than SHN_LORESERVE sections.
Signed-off-by: Mark Wielaard <mark@klomp.org>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The ebl_section_strip_p function used the Ehdr e_shstrndx field
to get at the name of the (debug) sections. This is not correct
if there are more than SHN_LORESERVE sections. Use elf_getshdrstrndx
to get at the shstrtab section. And drop the Ehdr argument that isn't
necessary anymore.
Signed-off-by: Mark Wielaard <mark@klomp.org>
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The .odp section is found by name. But ppc64_init used the e_shstrndx
Ehdr field for that. This is wrong if the file contains more than
SHN_LORESERVE sections. Use elf_getshdrstrndx instead to find the
shstrtab section.
Signed-off-by: Mark Wielaard <mark@klomp.org>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The check_special_symbol backend functions used the Ehdr e_shstrndx
field to get at the name of sections. This is not correct if there
are more than SHN_LORESERVE sections. Always use elf_getshdrstrndx
to get the shstrtab section. And drop the Ehdr argument that isn't
necessary anymore.
Signed-off-by: Mark Wielaard <mark@klomp.org>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
When ELF_C_RDWR_MMAP is used libelf might have to write overlapping memory
when moving the section data or headers. Make sure to use memmove, not
memcpy. Also the size of the underlying file might have to change. That
means we will have to also extend the mmap region with mremap. Since we
are using direct pointers into the mmapped area we cannot move the mmap,
only extend it. This might still fail if there is not enough free memory
available to extend the mmap region.
Two new test programs have been added. elfcopy which copies a whole elf
file (using either ELF_C_WRITE or ELF_C_WRITE_MMAP). And addsections which
adds new sections to an existing ELF file (using either ELF_C_RDWR or
ELF_C_RDWR_MMAP). The newly added test will fail under valgrind without
the fixes.
Signed-off-by: Mark Wielaard <mark@klomp.org>
|
| |
| |
| |
| |
| |
| |
| |
| | |
GCC could partition main into an cold and hot block causing our symbol
lookup to fail in the backtrace-dwarf testcase. Add a section attribute
on "main" so that it will be kept together.
Signed-off-by: Mark Wielaard <mark@klomp.org>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Normally in non-ET_REL files all allocated sections come before
all non-allocated sections. eu-strip relies on this when stripping
a file and calculating the file offsets. But recently on Fedora
there are non-allocated .gnu.build.attributes NOTE sections in
the middle of the allocated sections, with a sh_offset field that
is larger then the next section. This confuses eu-strip so much that
it might corrupt the stripped file.
Work around this by calculating the sh_offset fields in two phases
when detecting mixed allocated/non-allocated sections. First handle
the allocated ones, then use the offset after the last allocated
section to calculate the offsets of the non-allocated sections left
in the stripped file.
Signed-off-by: Mark Wielaard <mark@klomp.org>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
dwarf_child (__libdw_find_attr), dwarf_getabbrevattr[_data] and
dwarf_getattrs all assume the end of the attribute list is when
both the name (code) and form of the attribute are zero.
dwarf_getabbrev (__libdw_getabbrev) and dwarf_hasattr assume the
end of the attribute list is when either the name (code) or the
form of the attribute is zero.
The DWARF spec says: "The series of attribute specifications ends
with an entry containing 0 for the name and 0 for the form." So
the first check is correct.
Make sure dwarf_getabbrev and dwarf_hasattr use the same check.
This is important since all other functions expect dwarf_getabbrev
(__libdw_getabbrev) to have done a data sanity check of the attribute.
So if the ending condition is different it could cause a crash.
https://sourceware.org/bugzilla/show_bug.cgi?id=23529
Signed-off-by: Mark Wielaard <mark@klomp.org>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
dwarf_getaranges didn't check if there was enough data left to read both
the address and segment size. readelf didn't check there was enough data
left to read the segment size.
https://sourceware.org/bugzilla/show_bug.cgi?id=23541
Signed-off-by: Mark Wielaard <mark@klomp.org>
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The sanity checks for how many words were needed in the section could
overflow causing errors. Fix the checks.
https://sourceware.org/bugzilla/show_bug.cgi?id=23542
Signed-off-by: Mark Wielaard <mark@klomp.org>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Compressing a section that is already compressed is fine, but useless.
But it isn't possible to gnu compress (or decompress) a SHF_COMPRESSED
section since there is no state kept that would tell if the section was
first GNU compressed or first gabi compressed. Calling elf_compress_gnu
on a section and then calling elf_compress on it to decompress it twice
could cause a crash (the other way around is fine). Just disallow it.
https://sourceware.org/bugzilla/show_bug.cgi?id=23528
Signed-off-by: Mark Wielaard <mark@klomp.org>
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Because of copy/paste error part of the documentation for
elf_getshdrstrndx and elf_getshstrndx was actually for
elf_getshdrnum and elf_getshnum. Fix it to refer to the proper
ehdr field and deprecated function name.
Signed-off-by: Mark Wielaard <mark@klomp.org>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
compare_unalloc_sections only checked sh_flags and the section names.
This would cause stripped/debug section mismatches when there were
multiple sections with the same name and flags. Fix this by also checking
the size of the section matches.
Add a testcase that has two ".group" sections created on i386 with the
gcc annobin plugin.
Signed-off-by: Mark Wielaard <mark@klomp.org>
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
SHT_GROUP sections are put in both the stripped and debug file.
Handle correcting the symbol table/name entry of the group only once.
The testfile was generated with the gcc annobin plugin.
Signed-off-by: Mark Wielaard <mark@klomp.org>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
If the input and output file are the same and no section needs to
be updated we really don't need to rewrite the file.
Check whether any matching section is already compressed or decompressed.
Skip the section if it doesn't need to be changed. If no section data
needs updating end with success without rewriting/updating file.
With --force the file will still always be updated/rewritten even if
no section data needs to be (de)compressed.
Acked-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
Signed-off-by: Mark Wielaard <mark@klomp.org>
|
| |
| |
| |
| |
| |
| | |
This fixes all testsuite failures.
Signed-off-by: Andreas Schwab <schwab@linux-m68k.org>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Calling fchmod with a suid bit on a file might silently fail or the suid
bit might be slilently cleared by a call to fchown if already set. Swap
the calls so that the owner is set first and then set the suid bit.
https://bugzilla.redhat.com/show_bug.cgi?id=1607044
Reported-and-tested-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
Signed-off-by: Mark Wielaard <mark@klomp.org>
|
| |
| |
| |
| | |
Signed-off-by: Andreas Schwab <schwab@suse.de>
|
| |
| |
| |
| | |
Signed-off-by: Andreas Schwab <schwab@suse.de>
|
| |
| |
| |
| | |
The PID attaching only works on linux.
|
| |
| |
| |
| | |
Signed-off-by: Andreas Schwab <schwab@suse.de>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
strip explicitly creates the new files. This will not work on windows if
the files already exist.
Also, if strip fails to create the files for any reason, we would check
the previous run's files and succeed. However, the test should fail
then.
Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
|
| |
| |
| |
| |
| |
| |
| |
| | |
Also document CONFIG_DEBUG_INFO=y.
Updated test file provided by Andreas Schwab <schwab@suse.de>.
Signed-off-by: Mark Wielaard <mark@klomp.org>
|
| |
| |
| |
| |
| |
| |
| | |
This fixes the backtrace-dwarf and deleted tests, and lets
backtrace-native run a bit further.
Signed-off-by: Andreas Schwab <schwab@suse.de>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Some toolchains use compressed ELF sections by default.
This would make run-next-cfi-self.sh fail because it would try to
decode the compressed data. Fix by decompressing the section first.
https://sourceware.org/bugzilla/show_bug.cgi?id=23370
Signed-off-by: Mark Wielaard <mark@klomp.org>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
On some ancient GCC versions (4.4.7 at least) -Wshadow warns about local
variables "shadowing" global function definitions.
readelf.c: In function ‘print_debug_addr_section’:
readelf.c:5265: error: declaration of ‘index’ shadows a global declaration
/usr/include/string.h:489: error: shadowed declaration is here
This is silly of course, but easy to work around.
Signed-off-by: Mark Wielaard <mark@klomp.org>
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
error.h isn't standard and so isn't part of the musl C library.
To easy future porting, consolidate the inclusion of error.h into system.h.
https://sourceware.org/bugzilla/show_bug.cgi?id=21008
Signed-off-by: Ross Burton <ross.burton@intel.com>
|
| |
| |
| |
| |
| |
| | |
gawk is required to build known_dwarf.h, so check for it in configure.ac.
Signed-off-by: Ross Burton <ross.burton@intel.com>
|
| |
| |
| |
| |
| |
| |
| |
| | |
Should be run after making a release to upload the new tar.bz2,
signature file and update the latest symlinks. Make sure to run
make distcheck first. Requires a shell account on sourceware.
Signed-off-by: Mark Wielaard <mark@klomp.org>
|
| |
| |
| |
| |
| |
| |
| |
| | |
We obviously need strdup, and it doesn't hurt to also export realloc and
calloc.
Change-Id: Ia4af48faaec2bcf24c3e07002711cd6153f684bf
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
|
| |
| |
| |
| |
| |
| |
| | |
mingw should have complained about this, too ...
Change-Id: I03940ba6e93ef04c51418cc507cccf47453d10fa
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
|
| |
| |
| |
| |
| |
| |
| |
| | |
Nobody can use those, and as windows doesn't have proper symlinks, they
take up lots of space.
Change-Id: If62db984c7ac62e798a88e3a4ecd15962683d001
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
In some situations GetFinalPathNameByHandleA actually wants to write one
character more than the number it gives as return value. We just always
make enough space for this, to be on the safe side.
Following the example given in the documentation, we offer it the whole
buffer (not -1), and figure out if we can fit the zero in afterwards.
It can respond with exactly the number given as input and mean "this is
not enough".
Change-Id: I3a7c2bdbe505ae7382607482e647313684c3ff74
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
|
| |
| |
| |
| |
| |
| |
| | |
We want to link libdl statically, so we need to link psapi ourselves.
Change-Id: I001bda009c58cfb39bba0733436f883bbf501b80
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
|
| |
| |
| |
| |
| |
| |
| | |
Windows loads DLLs from PATH.
Change-Id: I96ef61236a615d06f1d667e1ae25f11a10e545da
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
|
| |
| |
| |
| |
| |
| |
| |
| | |
Windows cannot unlink open files, and there is no predefined temporary
directory. Use the section name as base for the file name.
Change-Id: I7e050e1ca5e5e890256b2573ca0d0c64745932fa
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
|
| |
| |
| |
| |
| | |
Change-Id: Ie9cf00b2e00b84ab736aaefc805a1cacfc9ae408
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
|
| |
| |
| |
| |
| |
| |
| | |
Windows won't unlink open files.
Change-Id: I23f785a8463aa29a972598e1e5a25b4f92448cb8
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
|
| |
| |
| |
| |
| |
| |
| |
| | |
Use generic IS_ABSOLUTE_FILE macro, and implement fd-to-filename for
windows. Reading from /proc/self obviously is not porable.
Change-Id: I805c5295871c13f4fa4b89eb89871fc100559318
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The windows linker looks for .dll files in PATH. LD_LIBRARY_PATH doesn't
work. This reduces the amount of headache to be suffered when running the
test suite.
Change-Id: I94e73af46bf4a7b185158067db86a9c16f3690dd
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
|
| |
| |
| |
| |
| |
| |
| |
| | |
I don't think we can accidentally match these strings in any other place
and the line ending matches are brittle.
Change-Id: I880e23a89c56851b17e50d804ed949761c9c1955
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
|
| |
| |
| |
| |
| | |
Change-Id: Idae0879a3514a9968395de399ee0094fb27e1a08
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
We are relying on the version of grep being used to recognize the platform
specific line endings. In principle it should, but the reality turns out
to be ... complicated. This message is unique enough to not require the
additional qualification of "at end of line".
Change-Id: I8241b023e759c9b57e050b07995cad0683c4bf35
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
|
| |
| |
| |
| |
| |
| |
| | |
On windows, strip cannot overwrite files.
Change-Id: I2cf1384b18daec71f079238cf274bce08bdc209b
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
|
| |
| |
| |
| |
| |
| |
| |
| | |
There are some convenient new methods for selftests that we can hook into
to avoid repeating the same check in every test.
Change-Id: Ie12e1f90f86f3bd3f0590fef4fe0157f4bc0f59c
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
|
| |
| |
| |
| |
| |
| |
| | |
Windows needs that if you're not reading text.
Change-Id: I923782f2c47ef16765f52d6a435f69cb33f50dfd
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
|
| |
| |
| |
| |
| |
| |
| |
| | |
We need realpath() now, as upstream has changed to use that. Updating
single gnulib modules is not really possible, so we update everything.
Change-Id: I32943a1c8af7c1ecce625dca173a942cc58d9c38
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
|
| |
| |
| |
| |
| |
| |
| |
| | |
Windows doesn't unlink or rename if there are still open file handles
around.
Change-Id: Idddda2cf841d42fa3a5a3fee9e3fe79f2a49136b
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
|
| |
| |
| |
| |
| |
| |
| | |
The PID attaching only works on linux.
Change-Id: I00428a711b64cb490429363ef28a867b1347956e
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
|