[PATCH] libdw: Explicitly check we could decode diridx in dwarf_getsrclines.

2018-06-05 Thread Mark Wielaard
It is highly unlikely dwarf_formudata fails because we setup the attribute ourselves, but better to explicitly mark diridx as bad if it does. Signed-off-by: Mark Wielaard --- libdw/ChangeLog | 5 + libdw/dwarf_getsrclines.c | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-

[PATCH] readelf: Always initialize .debug_addr unit_length, even without a header.

2018-06-05 Thread Mark Wielaard
We would print a "fake" .debug_addr header, but didn't always setup the unit_length (in case there was a mix of GNU DebugFission and DWARF5 tables). Make sure to always set the unit_length (we do always calculate the next unit offset already). Signed-off-by: Mark Wielaard --- src/ChangeLog | 5 +

[PATCH] readelf: Set begin properly for DW_LLE_GNU_start_end_entry on addrx failure.

2018-06-05 Thread Mark Wielaard
When printing the GNU DebugFission location entries we want to print the start idx as begin, if we cannot find the address index. A copy/paste error set up end instead of begin in that case causing us to print garbage (in the unlikely event the .debug_addr table wasn't found for this entry). Signe

[PATCH] libdw: Don't leak arange if we cannot figure out which CU it belongs to.

2018-06-05 Thread Mark Wielaard
In the unlikely case that __libdw_findcu fails to find the associated CU we would leak one arange because it wasn't linked into the arangelist list yet. Make sure to free it immediately. Signed-off-by: Mark Wielaard --- libdw/ChangeLog | 5 + libdw/dwarf_getaranges.c | 7 ++- 2

[PATCH] libdw: Make sure dirarray is always properly freed in dwarf_getsrclines.

2018-06-05 Thread Mark Wielaard
If there were more than 256 directories in the table and there was illegal DWARF before we read them all, then we might not free the dirarray (or the wrong one). Fix by defining the dirarray early (before the first data sanity check) and making sure it is not (still) equal to dirstack before freein

[PATCH] readelf: Don't leak lengths array when detecting an invalid hash chain.

2018-06-05 Thread Mark Wielaard
In both handle_sysv_hash and handle_sysv_hash64 we check the has chain isn't too long. If it is we would report an error and leak the lengths array. Just clean up the array even in the error case. Signed-off-by: Mark Wielaard --- src/ChangeLog | 6 ++ src/readelf.c | 14 -- 2 fi

[PATCH] libdw: Make sure id_path can contain max number of build id bytes.

2018-06-05 Thread Mark Wielaard
The MAX_BUILD_ID_BYTES is fairly large (64), while normally build-ids are only 20 bytes long. But if we would encounter a jumbo build-id we should have enough room to construct the full build-id path. We used to substract 2 bytes from the max, because 2 chars are used as subdir. But that should be

[PATCH] readelf: Make room for DW_MACRO_hi_user opcode if used.

2018-06-05 Thread Mark Wielaard
The vendor array should have room for all vendor opcode, including DW_MACRO_hi_user if used. Signed-off-by: Mark Wielaard --- src/ChangeLog | 5 + src/readelf.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ChangeLog b/src/ChangeLog index cc12d83..c376a5b 100644 -

Re: dwarf_next_cfi returns -1

2018-06-05 Thread Mark Wielaard
On Mon, 2018-06-04 at 16:16 +, Sasha Da Rocha Pinheiro wrote: > We had a case where dwarf_next_cfi returns -1 but the offset does not > update, as we should expect by the comment: > >  330    On errors, returns -1.  Some format errors will permit safely >  331    skipping to the next CFI entry