diff options
Diffstat (limited to 'libdwfl')
| -rw-r--r-- | libdwfl/ChangeLog | 33 | ||||
| -rw-r--r-- | libdwfl/cu.c | 7 | ||||
| -rw-r--r-- | libdwfl/dwfl_segment_report_module.c | 7 | ||||
| -rw-r--r-- | libdwfl/frame_unwind.c | 2 | ||||
| -rw-r--r-- | libdwfl/gzip.c | 5 | ||||
| -rw-r--r-- | libdwfl/linux-kernel-modules.c | 7 | ||||
| -rw-r--r-- | libdwfl/open.c | 10 |
7 files changed, 58 insertions, 13 deletions
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog index 04cadb43..04a39637 100644 --- a/libdwfl/ChangeLog +++ b/libdwfl/ChangeLog @@ -1,3 +1,36 @@ +2019-08-12 Mark Wielaard <[email protected]> + + * gzip.c (open_stream): Return DWFL_E_ERRNO on bad file operation. + * open.c (libdw_open_elf): New argument bad_elf_ok. Check it and + return DWFL_E_NOERROR in case it is set and error was DWFL_E_BADELF. + (__libdw_open_file): Call libdw_open_elf with bad_elf_ok false. + (__libdw_open_elf): Call libdw_open_elf with bad_elf_ok true. + +2019-08-05 Omar Sandoval <[email protected]> + + * dwfl_segment_report_module.c (dwfl_segment_report_module): Assign + mod->main.fd. + +2019-04-28 Mark Wielaard <[email protected]> + + * frame_unwind.c (expr_eval): Make sure we left shift a unsigned + 64bit value. + +2019-04-28 Mark Wielaard <[email protected]> + + * cu.c (addrarange): Only call realloc when naranges is not zero. + +2019-03-27 Mark Wielaard <[email protected]> + + * dwfl_segment_report_module.c (dwfl_segment_report_module): Check + ph_buffer_size vs xlatefrom.d_size after read_portion call. + +2019-02-24 Mark Wielaard <[email protected]> + + * linux-kernel-modules.c (intuit_kernel_bounds): Init *notes before + fopen. + (dwfl_linux_kernel_report_kernel): Remove fake note init empty asm. + 2019-01-25 Yonghong Song <[email protected]> * linux-proc-maps.c (proc_maps_report): Use PRIu64, not PRIi64, to diff --git a/libdwfl/cu.c b/libdwfl/cu.c index 94bfad8d..4de66248 100644 --- a/libdwfl/cu.c +++ b/libdwfl/cu.c @@ -83,8 +83,11 @@ addrarange (Dwfl_Module *mod, Dwarf_Addr addr, struct dwfl_arange **arange) /* Store the final array, which is probably much smaller than before. */ mod->naranges = naranges; - mod->aranges = (realloc (aranges, naranges * sizeof aranges[0]) - ?: aranges); + if (naranges > 0) + mod->aranges = (realloc (aranges, naranges * sizeof aranges[0]) + ?: aranges); + else if (aranges != NULL) + free (aranges); mod->lazycu += naranges; } diff --git a/libdwfl/dwfl_segment_report_module.c b/libdwfl/dwfl_segment_report_module.c index f6ad39b3..430e13d5 100644 --- a/libdwfl/dwfl_segment_report_module.c +++ b/libdwfl/dwfl_segment_report_module.c @@ -412,6 +412,12 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name, start + phoff, xlatefrom.d_size)) return finish (); + /* ph_buffer_size will be zero if we got everything from the initial + buffer, otherwise it will be the size of the new buffer that + could be read. */ + if (ph_buffer_size != 0) + xlatefrom.d_size = ph_buffer_size; + xlatefrom.d_buf = ph_buffer; bool class32 = ei_class == ELFCLASS32; @@ -961,6 +967,7 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name, { /* Install the file in the module. */ mod->main.elf = elf; + mod->main.fd = fd; elf = NULL; fd = -1; mod->main.vaddr = module_start - bias; diff --git a/libdwfl/frame_unwind.c b/libdwfl/frame_unwind.c index 8da691ee..d7dfa5a9 100644 --- a/libdwfl/frame_unwind.c +++ b/libdwfl/frame_unwind.c @@ -336,7 +336,7 @@ expr_eval (Dwfl_Frame *state, Dwarf_Frame *frame, const Dwarf_Op *ops, val1 >>= (addr_bytes - op->number) * 8; #else if (op->number < 8) - val1 &= (1 << (op->number * 8)) - 1; + val1 &= (1ULL << (op->number * 8)) - 1; #endif } if (! push (val1)) diff --git a/libdwfl/gzip.c b/libdwfl/gzip.c index c2c13baf..043d0b6e 100644 --- a/libdwfl/gzip.c +++ b/libdwfl/gzip.c @@ -139,14 +139,14 @@ open_stream (int fd, off_t start_offset, struct unzip_state *state) { int d = dup (fd); if (unlikely (d < 0)) - return DWFL_E_BADELF; + return DWFL_E_ERRNO; if (start_offset != 0) { off_t off = lseek (d, start_offset, SEEK_SET); if (off != start_offset) { close (d); - return DWFL_E_BADELF; + return DWFL_E_ERRNO; } } state->zf = gzdopen (d, "r"); @@ -288,6 +288,7 @@ unzip (int fd, off_t start_offset, if (result == DWFL_E_NOERROR && gzdirect (state.zf)) { gzclose (state.zf); + /* Not a compressed stream after all. */ return fail (&state, DWFL_E_BADELF); } diff --git a/libdwfl/linux-kernel-modules.c b/libdwfl/linux-kernel-modules.c index 360e4ee9..d46ab5aa 100644 --- a/libdwfl/linux-kernel-modules.c +++ b/libdwfl/linux-kernel-modules.c @@ -493,14 +493,14 @@ intuit_kernel_bounds (Dwarf_Addr *start, Dwarf_Addr *end, Dwarf_Addr *notes) { struct read_address_state state = { NULL, NULL, 0, 0, NULL, NULL }; + *notes = 0; + state.f = fopen (KSYMSFILE, "r"); if (state.f == NULL) return errno; (void) __fsetlocking (state.f, FSETLOCKING_BYCALLER); - *notes = 0; - int result; do result = read_address (&state, start) ? 0 : -1; @@ -695,9 +695,6 @@ dwfl_linux_kernel_report_kernel (Dwfl *dwfl) /* Try to figure out the bounds of the kernel image without looking for any vmlinux file. */ Dwarf_Addr notes; - /* The compiler cannot deduce that if intuit_kernel_bounds returns - zero NOTES will be initialized. Fake the initialization. */ - asm ("" : "=m" (notes)); int result = intuit_kernel_bounds (&start, &end, ¬es); if (result == 0) { diff --git a/libdwfl/open.c b/libdwfl/open.c index 74367359..35fc5283 100644 --- a/libdwfl/open.c +++ b/libdwfl/open.c @@ -118,7 +118,7 @@ what_kind (int fd, Elf **elfp, Elf_Kind *kind, bool *may_close_fd) static Dwfl_Error libdw_open_elf (int *fdp, Elf **elfp, bool close_on_fail, bool archive_ok, - bool never_close_fd) + bool never_close_fd, bool bad_elf_ok) { bool may_close_fd = false; @@ -164,6 +164,10 @@ libdw_open_elf (int *fdp, Elf **elfp, bool close_on_fail, bool archive_ok, && !(archive_ok && kind == ELF_K_AR)) error = DWFL_E_BADELF; + /* This basically means, we keep a ELF_K_NONE Elf handle and return it. */ + if (bad_elf_ok && error == DWFL_E_BADELF) + error = DWFL_E_NOERROR; + if (error != DWFL_E_NOERROR) { elf_end (elf); @@ -184,11 +188,11 @@ libdw_open_elf (int *fdp, Elf **elfp, bool close_on_fail, bool archive_ok, Dwfl_Error internal_function __libdw_open_file (int *fdp, Elf **elfp, bool close_on_fail, bool archive_ok) { - return libdw_open_elf (fdp, elfp, close_on_fail, archive_ok, false); + return libdw_open_elf (fdp, elfp, close_on_fail, archive_ok, false, false); } Dwfl_Error internal_function __libdw_open_elf (int fd, Elf **elfp) { - return libdw_open_elf (&fd, elfp, false, true, true); + return libdw_open_elf (&fd, elfp, false, true, true, true); } |
