Re: [PATCH] readelf: Handle signedness of DW_FORM_implicit_const and DW_AT_const_value.

2018-06-15 Thread Mark Wielaard
On Wed, Jun 13, 2018 at 02:51:43PM +0200, Mark Wielaard wrote: > We only handles DW_FORM_sdata as a signed form, but DW_FORM_implicit_const > is also signed by default. For DW_AT_const_value we can do a little better. > GCC encodes some const_values with signed forms, even though the

Re: [PATCH] readelf: While printing .debug_loc make sure that next_off doesn't overflow.

2018-06-15 Thread Mark Wielaard
On Wed, Jun 13, 2018 at 03:24:45PM +0200, Mark Wielaard wrote: > Found by the afl fuzzer. The next offset (after a locview) comes from a > DIE loclist attribute. This could be a bogus value so large it overflows > the buffer and makes us print past the end of buffer. Pushed to master.

Re: [PATCH] backends,bpf: add proper relocation support

2018-06-16 Thread Mark Wielaard
R_BPF_64_32 10 We should sync this with glibc. This file really is a copy of elf/elf.h in glibc, which we periodically sync. It would be good if all projects agree on the constants. I would like to understand where the R_BPF_MAP_FD comes from. But I assume it was a typo for BPF_PSEUDO_MAP_FD from bpf.h (which has the same constant number 1). I'll sent a patch to libc-al...@sourceware.org unless you beat me to it. Thanks, Mark

Re: [PATCH] libdw: Make __libdw_dieabbrev more robust on failure.

2018-06-16 Thread Mark Wielaard
On Thu, 2018-06-14 at 00:42 +0200, Mark Wielaard wrote: > Make sure to always set die->abbrev to DWARF_END_ABBREV on failure. > DWARF_END_ABBREV is also what the function reports on failure. And it > will prevent trying to lookup the abbrev ever again. Pushed to master.

Re: [PATCH] readelf: Make sure print_form_data always consumes DW_FORM_strx[1234] data.

2018-06-16 Thread Mark Wielaard
On Thu, 2018-06-14 at 01:10 +0200, Mark Wielaard wrote: > Found by afl-fuzz. When printing DW_FORM_strx[1234] data eu-readelf didn't > increase readp which meant eu-readelf would keep printing the same line > dirs or files encoded with strx[1234] names. This meant that for insane

Re: [PATCH] readelf: Check there are at least 4 bytes available for DWARF_FORM_block4.

2018-06-16 Thread Mark Wielaard
On Thu, 2018-06-14 at 01:24 +0200, Mark Wielaard wrote: > Found by afl-fuzz. When printing a DWARF_FORM_block4 we checked there > were only 2 bytes available (copy/paste from DW_FORM_block2 right > before). Obviously we need at least 4 bytes to read the length of a > DW_FORM_block4

[Bug libdw/23301] free on unitialized value

2018-06-17 Thread Mark Wielaard
https://sourceware.org/bugzilla/show_bug.cgi?id=23301 Mark Wielaard changed: What|Removed |Added Status|UNCONFIRMED |ASSIGNED Last reconfirmed

Re: [PATCH] libdw, readelf: Don't handle DW_FORM_data16 as expression block/location.

2018-06-17 Thread Mark Wielaard
On Fri, Jun 15, 2018 at 04:30:14PM +0200, Mark Wielaard wrote: > Also found by afl-fuzz on the varlocs testcase. > DW_FORM_data16 is constant from according to the DWARF5 spec. > But since it is 128bits it isn't really representable as Dwarf_Word. > So we treat it as block fo

[PATCH] libdw: aggregate_size check NULL result from get_type.

2018-06-18 Thread Mark Wielaard
ff-by: Mark Wielaard --- libdw/ChangeLog | 4 libdw/dwarf_aggregate_size.c | 3 +++ 2 files changed, 7 insertions(+) diff --git a/libdw/ChangeLog b/libdw/ChangeLog index 329a994d..5dc70ba9 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -1,3 +1,7 @@ +2018-06-18 Mark Wie

[PATCH] libdw: dwarf_peel_type break long chains/cycles.

2018-06-18 Thread Mark Wielaard
Limit the number of chained modifiers to 64 (that is 8 chains for all 8 modifiers, most of which cannot be chained). This prevents loops in the DWARF DIE DW_AT_type references. Signed-off-by: Mark Wielaard --- libdw/ChangeLog | 4 libdw/dwarf_peel_type.c | 23

[PATCH] libdw: Break dwarf_aggregate_size recursion because of type cycles.

2018-06-18 Thread Mark Wielaard
Found by afl-fuzz. An array type (indirectly) referring to itself in the DIE tree could blow up the stack when dwarf_aggregate_size was called. Limit the recursion depth to MAX_DEPTH (256) entries. Signed-off-by: Mark Wielaard --- libdw/ChangeLog | 8 libdw

[PATCH] libelf: Don't return unaligned data returned from elf_getdata[_rawchunk].

2018-06-19 Thread Mark Wielaard
might even happen in our own code base and these are public functions that can be used by code that might rely on the data returned being correctly aligned for the ELF data type requested just always return correctly aligned data. Signed-off-by: Mark Wielaard --- libelf/ChangeLog

Re: [PATCH] backends: add abi_cfi and register_info callbacks for RISC-V

2018-06-20 Thread Mark Wielaard
Hi Andreas, On Mon, 2018-06-18 at 09:59 +0200, Andreas Schwab wrote: > On Jun 15 2018, Mark Wielaard wrote: > > > How does the result of make check look now on a native riscv > > system? > > FAIL: run-native-test.sh > > return_value_location is missing Sadly DWA

Re: [PATCH] libdw: aggregate_size check NULL result from get_type.

2018-06-20 Thread Mark Wielaard
On Mon, 2018-06-18 at 10:37 +0200, Mark Wielaard wrote: > aggregate_size can be called recursively with the result of get_type. > get_type can return NULL when dwarf_peel_type fails. Found by afl- > fuzz. > > dwarf_aggregate_size when called directly doesn't need a NULL chec

Re: [PATCH v2] backends,bpf: add proper relocation support

2018-06-20 Thread Mark Wielaard
nother revision >  once the libelf/elf.h is synced. The patch looks perfect. And the new testcase is good. I used the testfile to quickly test eu-readelf --debug-dump also got the relocations right, and it did of course. Just waiting for the glibc elf.h update/sync and then I'll push this to master. Thanks, Mark

Re: [PATCH] libdw: dwarf_peel_type break long chains/cycles.

2018-06-20 Thread Mark Wielaard
On Mon, 2018-06-18 at 10:42 +0200, Mark Wielaard wrote: > Limit the number of chained modifiers to 64 (that is 8 chains for all > 8 modifiers, most of which cannot be chained). This prevents loops in > the DWARF DIE DW_AT_type references. Pushed to master.

Re: [PATCH] libdw: Break dwarf_aggregate_size recursion because of type cycles.

2018-06-20 Thread Mark Wielaard
On Mon, 2018-06-18 at 12:44 +0200, Mark Wielaard wrote: > Found by afl-fuzz. An array type (indirectly) referring to itself in the > DIE tree could blow up the stack when dwarf_aggregate_size was called. > Limit the recursion depth to MAX_DEPTH (256) entries. Pushed to master.

Re: [PATCH] backends: add abi_cfi and register_info callbacks for RISC-V

2018-06-20 Thread Mark Wielaard
On Wed, 2018-06-20 at 14:38 +0200, Andreas Schwab wrote: > On Jun 20 2018, Mark Wielaard wrote: > > > > FAIL: run-low_high_pc.sh > > > > > > lowpc: 220, highpc: 220lx > > > ../../elfutils/src/size.c: [c84] 'handle_elf' highpc <= lowpc >

Re: [PATCH] backends: add abi_cfi and register_info callbacks for RISC-V

2018-06-20 Thread Mark Wielaard
all callers are internal (libdwfl/relocate.c and strip.c). Cheers, Mark

[COMMITTED] libelf: Sync elf.h from glibc.

2018-06-21 Thread Mark Wielaard
Add NT_PPC_PKEY, R_BPF_64_64 and R_BPF_64_32. Remove R_BPF_MAP_FD. Signed-off-by: Mark Wielaard --- backends/ChangeLog | 4 backends/bpf_reloc.def | 1 - libelf/ChangeLog | 4 libelf/elf.h | 5 - 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a

Re: [PATCH v2] backends,bpf: add proper relocation support

2018-06-21 Thread Mark Wielaard
On Wed, Jun 20, 2018 at 07:18:22AM -0700, Yonghong Song wrote: > On 6/20/18 4:41 AM, Mark Wielaard wrote: > > The patch looks perfect. And the new testcase is good. I used the > > testfile to quickly test eu-readelf --debug-dump also got the > > relocations right,

Re: [PATCH v2] backends,bpf: add proper relocation support

2018-06-21 Thread Mark Wielaard
e buildbot https://builder.wildebeest.org/buildbot/ keeps green on all arches, we should be good to go for a new release. Cheers, Mark

Re: [PATCH] libelf: Don't return unaligned data returned from elf_getdata[_rawchunk].

2018-06-22 Thread Mark Wielaard
On Wed, 2018-06-20 at 00:57 +0200, Mark Wielaard wrote: > For i386 and x86_64 we allow some unaligned data accesses. > We also return unaligned data from elf_getdata[_rawchunk]. > But that might go wrong if we then access the ELF types inside. > When build with gcc -O3 for example

[PATCH] libdw: Handle bogus CU length in dwarf_nextcu.

2018-06-22 Thread Mark Wielaard
The length field could be so big that it would wrap around the next_offset. We don't really care that length is bogus, but we don't want to use it to calculate the next offset if it is. Found by afl-fuzz. Signed-off-by: Mark Wielaard --- libdw/ChangeLog | 5 + libdw/dwarf_ne

[PATCH] libdw: Add dwarf_next_lines to read .debug_line tables without CUs.

2018-06-25 Thread Mark Wielaard
s it to show decoded line tables even if there is no .debug_info section. New tests have been added that mimic the get-files and get-lines tests but use dwarf_next_lines instead of iterating over all CUs. They produce identical output (modulo the CU information). Also add a new test file that contai

Re: [PATCH] libdw: Handle bogus CU length in dwarf_nextcu.

2018-06-25 Thread Mark Wielaard
On Fri, 2018-06-22 at 18:06 +0200, Mark Wielaard wrote: > The length field could be so big that it would wrap around the next_offset. > We don't really care that length is bogus, but we don't want to use it to > calculate the next offset if it is. Pushed to master.

[PATCH] libdw: Remove dwarf_getscn_info from libdw.h and libdw.map.

2018-06-26 Thread Mark Wielaard
This function was never actually implemented/provided by libdw. And it doesn't look like something we really want to implement. Signed-off-by: Mark Wielaard --- libdw/ChangeLog | 5 + libdw/libdw.h | 3 --- libdw/libdw.map | 1 - 3 files changed, 5 insertions(+), 4 deletions(-)

[PATCH] tests: Limit varlocs print_expr_block recursion depth.

2018-06-26 Thread Mark Wielaard
This is only useful for bad DWARF where an expression block might have an expression that refers to a DIE that contains the expression block itself. But that might happen with bad DWARF generated by a fuzzer. Signed-off-by: Mark Wielaard --- tests/ChangeLog | 7 +++ tests/varlocs.c | 30

[PATCH] libdw: Allow .debug_frame only Dwarf.

2018-06-27 Thread Mark Wielaard
.debug_frame is useful independent from the other .debug sections. Add a simplified variant of the addrcfi testcase dwarfcfi. dwarfcfi only uses dwarf_frame calls and no dwfl helpers. Signed-off-by: Mark Wielaard --- libdw/ChangeLog | 5 + libdw/dwarf_begin_elf.c

Re: dwarf_next_cfi returns -1

2018-06-27 Thread Mark Wielaard
re mentioned in the LSB exception frames spec: https://refspecs.linuxfoundation.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/ehframechpt.html#EHFRAME Totally untested patch attached. If you could test it that would be wonderful. I'll write a proper testcase tomorrow. Thanks, Mark diff --gi

[PATCH] libdw: Recognize zero terminator to end frame table in dwarf_next_cfi.

2018-06-28 Thread Mark Wielaard
check consistency (FDEs should point to existing CIEs). Also add a self check to make sure we can read the table from the just build elfutils binaries. Signed-off-by: Mark Wielaard --- libdw/ChangeLog| 4 ++ libdw/dwarf_next_cfi.c | 8 +++ tests/ChangeLog| 10

Re: [PATCH] libdw: Add dwarf_next_lines to read .debug_line tables without CUs.

2018-06-29 Thread Mark Wielaard
On Mon, 2018-06-25 at 15:12 +0200, Mark Wielaard wrote: > It is sometimes useful to read .debug_line tables on their own without > having an associated CU DIE. DWARF5 line tables are self-contained. > > Adjust dwarf_begin_elf to accept ELF files with just a .debug_line. > >

Re: [PATCH] libdw: Remove dwarf_getscn_info from libdw.h and libdw.map.

2018-06-29 Thread Mark Wielaard
On Tue, 2018-06-26 at 16:45 +0200, Mark Wielaard wrote: > This function was never actually implemented/provided by libdw. > And it doesn't look like something we really want to implement. Pushed to master.

Re: [PATCH] tests: Limit varlocs print_expr_block recursion depth.

2018-06-29 Thread Mark Wielaard
On Tue, 2018-06-26 at 16:50 +0200, Mark Wielaard wrote: > This is only useful for bad DWARF where an expression block might have > an expression that refers to a DIE that contains the expression block > itself. But that might happen with bad DWARF generated by a fuzzer. Pushed to master.

Re: [PATCH] libdw: Allow .debug_frame only Dwarf.

2018-06-29 Thread Mark Wielaard
On Wed, Jun 27, 2018 at 03:00:08PM +0200, Mark Wielaard wrote: > .debug_frame is useful independent from the other .debug sections. > > Add a simplified variant of the addrcfi testcase dwarfcfi. > dwarfcfi only uses dwarf_frame calls and no dwfl helpers. Pushed to master.

Re: [PATCH] libdw: Recognize zero terminator to end frame table in dwarf_next_cfi.

2018-06-29 Thread Mark Wielaard
On Fri, Jun 29, 2018 at 12:26:30AM +0200, Mark Wielaard wrote: > When the length is zero this is a the zero terminator that ends the > frame table. Return 1 (end of table) instead of -1 (error) in that case. > We cannot update next_off and don't want to caller to try again. > &

[COMMITTED] Prepare for 0.173

2018-06-29 Thread Mark Wielaard
Set version to 0.173. Mention new functionality in NEWS. Update po/*.po files. Signed-off-by: Mark Wielaard --- NEWS| 18 +++ config/elfutils.spec.in | 15 ++ configure.ac| 2 +- po/de.po| 317 po/es.po

elfutils 0.173 released

2018-06-29 Thread Mark Wielaard
CFI and knows about RISCV register types and names. * GIT SHORTLOG * Andreas Schwab (1): backends: add abi_cfi and register_info callbacks for RISC-V Luiz Angelo Daros de Luca (1): libdw: Initialize filelist earlier in dwarf_getsrclines.c read_srclines. Mark Wielaard (18

Re: dependency

2018-06-29 Thread Mark Wielaard
e other scheme? We could also have the buildbot create a "latest" or "current" from git once all builds are green for example. Which brings up the question, should we use "stable", "current" or "latest" as link name, or is there a better, more standard name to use for that? What do other projects use? Thanks, Mark

[PATCH] readelf: Don't shadow index function from string.h

2018-07-04 Thread Mark Wielaard
489: error: shadowed declaration is here This is silly of course, but easy to work around. Signed-off-by: Mark Wielaard --- src/ChangeLog | 6 ++ src/readelf.c | 14 +++--- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 6d962bb..2b711da 10

Re: dependency

2018-07-04 Thread Mark Wielaard
re shell account). Thanks for the suggestion. Cheers, Mark >From 954b1199737ca1047bc1bad82fcff6c3ce5ec2ec Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Wed, 4 Jul 2018 23:21:19 +0200 Subject: [PATCH] Add last release (and signature) links --- index.html | 4 +++- 1 file changed, 3 inser

[PATCH] tests: Handle compressed sections in next_cfi testcase.

2018-07-05 Thread Mark Wielaard
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 --- tests/ChangeLog

Re: [PATCH 1/2] Require gawk in maintainer mode

2018-07-05 Thread Mark Wielaard
On Wed, Jul 04, 2018 at 12:11:07PM +0100, Ross Burton wrote: > gawk is required to build known_dwarf.h, so check for it in configure.ac. Thanks. Added a ChangeLog entry and pushed to master.

Re: [PATCH 2/2] Consolidate error.h inclusion in system.h

2018-07-05 Thread Mark Wielaard
Thanks, added ChangeLog entries and pushed to master. But this isn't real solution. error is a useful GNU extension that is widely used in the code base. So I think if you really do want to use an alternative glibc implementation that it should just provide error. Cheers, Mark

Re: [PATCH] readelf: Don't shadow index function from string.h

2018-07-05 Thread Mark Wielaard
On Wed, Jul 04, 2018 at 04:13:26PM +0200, Mark Wielaard wrote: > 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: err

Re: [PATCH] backends: add set_initial_registers_tid callback for RISC-V

2018-07-13 Thread Mark Wielaard
On Wed, 2018-07-11 at 12:43 +0200, Andreas Schwab wrote: > This fixes the backtrace-dwarf and deleted tests, and lets > backtrace-native run a bit further. Looks good. Pushed to master. Funny that there is a dedicated register for the value zero. Cheers, Mark

Re: [PATCH 1/2] Remove previous test files before running the next round

2018-07-16 Thread Mark Wielaard
d. However, the test should fail > then. This makes sense and does uncover a bug as your second patch shows. I want to fix that first and only then commit this fix. That way we don't have the testsuite failing between commits. Thanks, Mark

Re: [PATCH 2/2] run-strip-reloc.sh: Skip debug file check for riscv

2018-07-16 Thread Mark Wielaard
rip doesn't produce a separate debug file. Andreas, could you provide an updated hello_riscv64.ko that is compiled with -g and does contain debuginfo? Thanks, Mark

Re: [PATCH 2/2] run-strip-reloc.sh: Skip debug file check for riscv

2018-07-17 Thread Mark Wielaard
On Tue, 2018-07-17 at 11:29 +0200, Andreas Schwab wrote: > On Jul 17 2018, Mark Wielaard wrote: > > The issue is that hello_riscv64.ko doesn't contain any debug > > sections. > > So strip doesn't produce a separate debug file. > > > > Andreas, could y

Re: [PATCH 2/2] run-strip-reloc.sh: Skip debug file check for riscv

2018-07-17 Thread Mark Wielaard
on Sep 17 00:00:00 2001 From: Mark Wielaard Date: Tue, 17 Jul 2018 12:27:51 +0200 Subject: [PATCH] tests: Update hello_riscv64.ko test file with debuginfo. Also document CONFIG_DEBUG_INFO=y. Updated test file provided by Andreas Schwab . Signed-off-by: Mark Wielaard --- tests/ChangeLog

Re: [PATCH 1/2] Remove previous test files before running the next round

2018-07-17 Thread Mark Wielaard
On Mon, 2018-07-16 at 23:57 +0200, Mark Wielaard wrote: > On Mon, Jul 16, 2018 at 12:01:21PM +0200, Ulf Hermann wrote: > > strip explicitly creates the new files. This will not work on > > windows if > > the files already exist. > > > > Also, if strip fails to cr

Re: [PATCH] backends: add core_note callback for RISC-V

2018-07-17 Thread Mark Wielaard
Looks good as far as I can tell. Pushed to master. But it would be really nice to have a testcase. Could you look at tests/run-readelf-mixed-corenote.sh and add something similar for RISC-V? Thanks, Mark

Re: [PATCH] Don't include sys/uio.h if we don't need it

2018-07-17 Thread Mark Wielaard
On Tue, Jul 17, 2018 at 01:40:26PM +0200, Ulf Hermann wrote: > > The PID attaching only works on linux. > > Change-Id: I00428a711b64cb490429363ef28a867b1347956e Thanks applied to master. I did remove the Change-Id tag. And normally we do require a Signed-off-by line. Cheers, Mark

Re: [PATCH] Fix typo in riscv_register_info

2018-07-19 Thread Mark Wielaard
Thanks. Typo looks obvious. Pushed to master.

Re: [PATCH] tests: Add core and strip tests for RISC-V

2018-07-19 Thread Mark Wielaard
Looks good and new tests pass for me locally. Pushed to master. Thanks, Mark

[PATCH] elfcompress: Swap fchmod and fchown calls on new file.

2018-07-21 Thread Mark Wielaard
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 Signed-off-by: Mark Wielaard

[PATCH] elfcompress: Don't rewrite file if no section data needs to be updated.

2018-07-21 Thread Mark Wielaard
g 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. Signed-off-by: Mark Wielaard --- src/ChangeLog | 6 ++ src/elfcompress.c | 43 +-- 2 fil

[PATCH] unstrip: Handle SHT_GROUP sections in ET_REL files.

2018-07-21 Thread Mark Wielaard
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 --- src/ChangeLog | 4 +++ src/unstrip.c

Re: [PATCH] elfcompress: Swap fchmod and fchown calls on new file.

2018-07-22 Thread Mark Wielaard
On Sat, Jul 21, 2018 at 05:05:43PM +0200, Igor Gnatenko wrote: > On Sat, Jul 21, 2018 at 4:56 PM Mark Wielaard wrote: > > > 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 >

Re: [PATCH] backends: add abi_cfi and set_initial_registers_tid callbacks for M68K

2018-07-22 Thread Mark Wielaard
On Sat, Jul 21, 2018 at 11:42:07PM +0200, Andreas Schwab wrote: > This fixes all testsuite failures. Nice. Looks good. Pushed to master. Thanks, Mark

Re: [PATCH] elfcompress: Don't rewrite file if no section data needs to be updated.

2018-07-22 Thread Mark Wielaard
ction even if it would become larger or update/rewrite the file even if no section would be (de)compressed Cheers, Mark >From d906260e480c4566da9173b50ee1f4fc229f4102 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Sat, 21 Jul 2018 17:07:12 +0200 Subj

Re: [PATCH] elfcompress: Don't rewrite file if no section data needs to be updated.

2018-07-22 Thread Mark Wielaard
Hi Igor, On Sun, Jul 22, 2018 at 10:06:47PM +0200, Igor Gnatenko wrote: > On Sun, Jul 22, 2018 at 5:20 PM Mark Wielaard wrote: > > > However, if nothing needs > > > compression/decompression - why to rewrite file? > > > > Indeed. That is why I wrote this pat

Re: [PATCH] elfcompress: Don't rewrite file if no section data needs to be updated.

2018-07-24 Thread Mark Wielaard
On Mon, Jul 23, 2018 at 06:36:37PM +0200, Igor Gnatenko wrote: > Acked-by: Igor Gnatenko Thanks. Pushed to master.

Re: [PATCH] elfcompress: Don't rewrite file if no section data needs to be updated.

2018-07-24 Thread Mark Wielaard
On Tue, Jul 24, 2018 at 09:57:28AM +0200, Mark Wielaard wrote: > On Mon, Jul 23, 2018 at 06:36:37PM +0200, Igor Gnatenko wrote: > > Acked-by: Igor Gnatenko > > Thanks. Pushed to master. BTW. For those at home just reading the mailinglist and wondering why they only see

[PATCH] unstrip: Also check sh_size in compare_unalloc_sections.

2018-07-24 Thread Mark Wielaard
ns created on i386 with the gcc annobin plugin. Signed-off-by: Mark Wielaard --- src/ChangeLog | 4 +++ src/unstrip.c | 6 tests/ChangeLog| 6 tests/Makefile.am | 1 + tests/run-annob

Re: [PATCH] backends: add abi_cfi and register_info callbacks for RISC-V

2018-07-26 Thread Mark Wielaard
to the translation types ELF_T_... I rather see the add/sub part be done as extra argument to the reloc_simple_type callback. Maybe simply as an int addsub, which can be -1, 0, 1. It does mean more code needs to be adjusted, but this is an internal interface, so it can just be changed. Thanks, Mark

Re: [PATCH] unstrip: Handle SHT_GROUP sections in ET_REL files.

2018-07-27 Thread Mark Wielaard
On Sat, 2018-07-21 at 23:54 +0200, Mark Wielaard wrote: > SHT_GROUP sections are put in both the stripped and debug file. > Handle correcting the symbol table/name entry of the group only once. Pushed to master.

Re: [PATCH] unstrip: Also check sh_size in compare_unalloc_sections.

2018-07-27 Thread Mark Wielaard
On Wed, 2018-07-25 at 00:15 +0200, Mark Wielaard wrote: > 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

[COMMITTED] libelf: Fix documentation of elf_getshdrstrndx and elf_getshstrndx.

2018-07-27 Thread Mark Wielaard
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 --- libelf/ChangeLog | 5 + libelf/libelf.h

[PATCH] RFC: strip with mixed allocated/non-allocated sections

2018-07-29 Thread Mark Wielaard
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, wit

Re: tests/backtrace-dwarf.c failure due to -freorder-blocks-and-partition

2018-08-03 Thread Mark Wielaard
Hi Martin, On Fri, 2018-08-03 at 09:41 +0200, Martin Liška wrote: > As slightly discussed with Mark, there are tests that expect 'main' > will be present in backtrace. That's not always true on x86_64 > because > -freorder-blocks-and-partition option is on by

Re: [PATCH] libelf/elf_end.c: check data_list.data.d.d_buf before free it

2018-08-16 Thread Mark Wielaard
es wrong? I don't fully understand what is going wrong. Is the section data pointing to the file data or something created by elf_newdata? Thanks, Mark

Re: [PATCH] libelf/elf_end.c: check data_list.data.d.d_buf before free it

2018-08-17 Thread Mark Wielaard
Hi Robert, [I don't have very good internet connectivity so cannot easily get all the bits and sources to replicate/inspect. So apologies if I am misinterpreting something.] On Fri, Aug 17, 2018 at 04:25:07PM +0800, Robert Yang wrote: > On 08/17/2018 03:25 AM, Mark Wielaard wrote: &g

[COMMITTED] libelf: Return error if elf_compress_gnu is used on SHF_COMPRESSED section.

2018-08-18 Thread Mark Wielaard
ction 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 --- libelf/ChangeLog | 7 +++ libelf/elf_compress_gnu.

[COMMITTED] libdw, readelf: Make sure there is enough data to read full aranges header.

2018-08-18 Thread Mark Wielaard
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 --- libdw/ChangeLog

[COMMITTED] libdw: Check end of attributes list consistently.

2018-08-18 Thread Mark Wielaard
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 --- libdw/ChangeLog

[COMMITTED] elflint: Fix check_sysv_hash[64] sanity checks to not overflow.

2018-08-18 Thread Mark Wielaard
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 --- src/ChangeLog | 7 +++ src/elflint.c | 7 +-- 2 files changed, 12 insertions(+), 2

Re: [PATCH] RFC: strip with mixed allocated/non-allocated sections

2018-08-30 Thread Mark Wielaard
On Mon, 2018-07-30 at 00:35 +0200, Mark Wielaard wrote: > 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 n

Re: tests/backtrace-dwarf.c failure due to -freorder-blocks-and-partition

2018-08-30 Thread Mark Wielaard
Hi Martin, Sorry for dropping this after you provided such an excellent analysis. So the problem really is that main gets split into main.cold which is jumped into, so a simple backtrace won't see the "hot" main anymore. If we would use the debuginfo we might be able to get the "correct" function

Re: Accessing String Table Indexes for .rodata

2018-08-30 Thread Mark Wielaard
If you mean that the sh_offset and sh_addr are the same then that not guaranteed. The mapping from file offset to addresses for allocated sections is given by the program headers. You can see how they are mapped exactly using eu-readelf -l. Cheers, Mark

Re: [PATCH V2] libelf/elf_end.c: check data_list.data.d.d_buf before free it

2018-08-30 Thread Mark Wielaard
n index outside of section > numbers > > The segmentation fault happens when prelink call elf_end(). Are you sure this isn't a bug in prelink like we discussed last time? If it isn't, can you give a short example how this issue happens? Thanks, Mark

Re: [PATCH V2] libelf/elf_end.c: check data_list.data.d.d_buf before free it

2018-08-31 Thread Mark Wielaard
gt; problem, the only problem I found is that elfutil's elf_end() free() a NULL > memory, so I made this patch. OK. So I believe that is because prelink's error handling seems wrong. It seems to assume it adding the ELF data buffer itself, so frees it, but the data actually seemed to come from elf_getdata, so shouldn't have been freed by prelink. Thanks, Mark

Re: Accessing String Table Indexes for .rodata

2018-08-31 Thread Mark Wielaard
string literals are defined/calculated when > ELF is created. No, that is not guaranteed. How data in an ELF file is mapped into memory is determined by the program headers (not the section headers). See also the picture showing the different ELF file data views in https ://en.wikipedia.org/wiki/Executable_and_Linkable_Format Cheers, Mark

Re: Accessing String Table Indexes for .rodata

2018-08-31 Thread Mark Wielaard
On Fri, 2018-08-31 at 20:35 +0800, Henry C wrote: > As you mentioned, it is not guaranteed, I wonder under what situation > Elf64_Shdr::sh_addr won't represent the virtual address of the > beginning of .rodata section. Try creating a shared library or compile your application with -pie to make an

Re: tests/backtrace-dwarf.c failure due to -freorder-blocks-and-partition

2018-09-11 Thread Mark Wielaard
On Thu, 2018-08-30 at 18:15 +0200, Mark Wielaard wrote: > Sorry for dropping this after you provided such an excellent analysis. > So the problem really is that main gets split into main.cold which is > jumped into, so a simple backtrace won't see the "hot" main anymor

[PATCH] libelf: Fix some issues with ELF_C_RDWR_MMAP.

2018-09-12 Thread Mark Wielaard
). 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 --- libelf/ChangeLog | 6 + libelf/elf32_updatefile.c | 10 +- libelf

Re: [PATCH] libelf: Fix some issues with ELF_C_RDWR_MMAP.

2018-09-13 Thread Mark Wielaard
On Wed, 2018-09-12 at 15:02 +0200, Mark Wielaard wrote: > 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 > m

Fix various issues with ELF files containing many sections

2018-09-13 Thread Mark Wielaard
Through an accident Fedora rawhide created various ELF files with thousands of sections. This showed various issues in libelf, libdw and some of the elfutils tools. When an ELF file has more than SHN_LORESERVE (0xff00, 65280) sections then the Ehdr e_shnum and e_shshstrndx fields are too small to h

[PATCH 05/10] libelf: Fix shnum and section zero handling.

2018-09-13 Thread Mark Wielaard
ce 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 --- libelf/ChangeLog | 6 +++ libelf/elf32_updatefile.c | 2 +- libelf/elf_getscn.c| 33 +

[PATCH 07/10] libdw: dwarf_begin_elf should use elf_getshdrstrndx to get section names.

2018-09-13 Thread Mark Wielaard
error. Signed-off-by: Mark Wielaard --- libdw/ChangeLog| 9 + libdw/dwarf_begin_elf.c| 27 +++ tests/ChangeLog| 6 ++ tests/Makefile.am | 6 -- tests/run-typeiter-many.sh | 31 +++ 5 files change

[PATCH 04/10] elfcmp: Get, check and shdrstrndx for section names.

2018-09-13 Thread Mark Wielaard
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 --- src/ChangeLog | 4 src/elfcmp.c | 20 ++-- 2 files changed

[PATCH 02/10] backends: Use elf_getshdrstrndx to find .odp section in ppc64_init

2018-09-13 Thread Mark Wielaard
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 --- backends/ChangeLog| 4 backends

[PATCH 09/10] readelf: Use elf_getshdrnum in print_shdr and print_phdr.

2018-09-13 Thread Mark Wielaard
print_shdr didn't print the correct number of sections if there were more than SHN_LORESERVE sections. print_phdr wouldn't match up the (allocated) sections and segements if there were more than SHN_LORESERVE sections in the ELF file. Signed-off-by: Mark Wielaard --- src/Chan

[PATCH 08/10] strip,unstrip: Use and set shdrstrndx consistently.

2018-09-13 Thread Mark Wielaard
flint, unstrip and elfcmp. Signed-off-by: Mark Wielaard --- src/ChangeLog| 7 + src/strip.c | 43 ++--- src/unstrip.c| 21 +- tests/ChangeLog | 6 tests/Makefile.am| 4 +-- tests/run-

[PATCH 06/10] elflint: Use shnum and shstrndx instead of ehdr field directly.

2018-09-13 Thread Mark Wielaard
We already got the right shnum and shstrndx. But were still using e_shnum in one check for ELFCLASS64 (it was correct for ELFCLASS32). And when getting section names in check_symtab we still used e_shstrndx in two places. Signed-off-by: Mark Wielaard --- src/ChangeLog | 7 +++ src/elflint.c

[PATCH 10/10] libdwfl: Document core memory and remote memory ELF shdrs reading.

2018-09-13 Thread Mark Wielaard
anyway. Signed-off-by: Mark Wielaard --- libdwfl/ChangeLog| 6 ++ libdwfl/dwfl_segment_report_module.c | 6 ++ libdwfl/elf-from-memory.c| 6 ++ 3 files changed, 18 insertions(+) diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog index 15d7511..5e9b986

[PATCH 03/10] libebl: Use elf_getshdrstrndx in ebl_section_strip_p.

2018-09-13 Thread Mark Wielaard
d-off-by: Mark Wielaard --- libebl/ChangeLog | 6 ++ libebl/eblsectionstripp.c | 7 +-- libebl/libebl.h | 2 +- src/ChangeLog | 5 + src/elfcmp.c | 4 ++-- src/strip.c | 4 ++-- 6 files changed, 21 insertions(+), 7 deletions(-)

[PATCH 01/10] backends: Always use elf_getshdrstrndx in check_special_symbol.

2018-09-13 Thread Mark Wielaard
igned-off-by: Mark Wielaard --- backends/ChangeLog| 10 ++ backends/aarch64_symbol.c | 9 ++--- backends/alpha_symbol.c | 1 - backends/ppc64_symbol.c | 7 +-- backends/ppc_symbol.c | 7 +-- backends/riscv_sym

[PATCH] Prepare for 0.174

2018-09-14 Thread Mark Wielaard
Set version to 0.174. Mention new functionality in NEWS. Update po/*.po files. Signed-off-by: Mark Wielaard --- NEWS| 16 + config/elfutils.spec.in | 11 + configure.ac|2 +- po/de.po| 2181

elfutils 0.174 released

2018-09-14 Thread Mark Wielaard
e and strip tests for RISC-V   backends: add abi_cfi and set_initial_registers_tid callbacks for M68K Mark Wielaard (27):   config: Add upload-release.sh script.   readelf: Don't shadow index function from string.h   tests: Handle compressed sections in next_cfi testcase.   tests: Update hello_

<    7   8   9   10   11   12   13   14   15   16   >