Commit Graph

374 Commits

Author SHA1 Message Date
David Anderson
acae971371 added new error code
libdwarf/dwarf_errmsg_list.c
libdwarf/libdwarf.h.in

Test for inconsistent line table header data
and provide a default string indicating failure
in case the inconsistency test is inadequate.
libdwarf/dwarf_line.c
libdwarf/dwarf_line_table_reader_common.c
2016-05-22 12:55:53 -07:00
David Anderson
6fa3f710ee modified: bugxml/data.txt
modified:   bugxml/readbugs.py

Fixed an incorrect length check to prevent a crash.
modified:   dwarfdump/print_frames.c

Set a macro structure field that was left unset.
No longer creates a zero-length malloc field.
modified:   libdwarf/dwarf_macro5.c
2016-05-22 08:46:35 -07:00
David Anderson
8f0690dae1 Improve the output with respect to things tested.
More like other configure setups.
dwarfdump/configure.in

Regenerate.
dwarfdump/configure

Fix spelling mistakes, and an erroneous . in column 1.
dwarfdump/dwarfdump.1

CFLAGS is no on HOST_CFLAGS.
libdwarf/Makefile.in

Improve the output with respect to things tested.
More like other configure setups.
libdwarf/configure.in

Regenerate.
libdwarf/configure
2016-05-19 13:47:52 -07:00
David Anderson
ac6673e32f dwarfdump
* print_die.c: Fix typo in error message.
* print_frames.c: Do additional checks for incorrect data
  when printing frame instructions to avoid dwarfdump crash..

libdwarf
    * dwarf_form.c: Directly check expression length against
      section length in case expression length very very large.
    * dwarf_query.c: _dwarf_calculate_info_section_*() routines
      made clearer and the *_start_ptr() instance also now returns
      the length (via a pointer arg).
    * dwarf_xu_index.c: Check data read from the section so
      a wildly large columns count or slots count will be caught
      and an error returned.
2016-05-18 18:50:58 -07:00
David Anderson
10ca310f64 Updated bug text for clarity.
bugxml/data.txt

Harden to account for corrupt relocation records.
libdwarf/dwarf_elf_access.c

Remove trailing whitespace.
libdwarf/dwarf_macro5.c
2016-05-17 07:03:22 -07:00
David Anderson
82d8e00785 bugxml/data.txt
Moved a couple functions between source files
and made them static. A couple commentary changes.
print_frames.c, though, needed hardening against
corrupt frame data.
dwarfdump/globals.h
dwarfdump/print_aranges.c
dwarfdump/print_die.c
dwarfdump/print_frames.c
dwarfdump/print_sections.c

All data reads from an object ensure the
read is actually in a section.
It is always possible something was overlooked, but
all the reading macros and functions now do checks.
libdwarf/dwarf_arange.c
libdwarf/dwarf_die_deliv.c
libdwarf/dwarf_errmsg_list.c
libdwarf/dwarf_form.c
libdwarf/dwarf_frame.c
libdwarf/dwarf_frame2.c
libdwarf/dwarf_global.c
libdwarf/dwarf_line.c
libdwarf/dwarf_line_table_reader_common.c
libdwarf/dwarf_loc.c
libdwarf/dwarf_loc2.c
libdwarf/dwarf_macro5.c
libdwarf/dwarf_opaque.h
libdwarf/dwarf_print_lines.c
libdwarf/dwarf_query.c
libdwarf/dwarf_ranges.c
libdwarf/dwarf_util.c
libdwarf/dwarf_util.h
libdwarf/dwarf_xu_index.c
libdwarf/libdwarf.h.in
2016-05-12 07:39:36 -07:00
David Anderson
71e02f3e62 Updated mm files with spelling fixes and nothing else.
Regenerated .pdf
libdwarf2.1.mm
libdwarf2.1.pdf
libdwarf2p.1.mm
libdwarf2p.1.pdf
2016-05-07 15:49:11 -07:00
David Anderson
b3c1706d48 Update version strings.
dwarfdump/common.c
dwarfdump/dwarfdump.c

Inserted local variable initialization-at-definition.
dwarfdump/print_frames.c

Notice frame data corruption and generate an error.
libdwarf/dwarf_errmsg_list.c
libdwarf/dwarf_frame.c
libdwarf/dwarf_frame.h
libdwarf/dwarf_frame2.c
libdwarf/dwarf_line.c
libdwarf/libdwarf.h.in
2016-05-07 13:50:17 -07:00
David Anderson
b6ec2dfd85 More to do here.
bugxml/data.txt

libdwarf
* dwarf_errmsg_list.c: Added DW_DLE_ZLIB_SECTION_SHORT.
    * dwarf_form.c: Now checking for section overrun.
    * dwarf_init_finish.c: Now checking zlib reading
      for section overrun.
    * dwarf_macro5.c: Now checking for section overrun and
      also fixing double delete caused by having
      _dwarf_get_alloc() space pointing at other _dwarf_get_alloc()
      space. Because in case of error the order of free
      of such is unpredictable!
    * dwarf_macro5.h: Added comment on mc_srcfiles member.
    * libdwarf.h.in: Added DW_DLE_ZLIB_SECTION_SHORT.
2016-05-06 17:16:15 -07:00
David Anderson
eb1472afac New bugr reports.
bugxml/data.txt

Now prints strings so that
control characters do not
cause problems. Easier to read too.
dwarfdump/Makefile.in
dwarfdump/NEWS
dwarfdump/dwarfdump.1
dwarfdump/dwarfdump.c
dwarfdump/globals.h
dwarfdump/print_die.c
dwarfdump/print_frames.c
dwarfdump/print_lines.c
dwarfdump/print_macro.c
dwarfdump/print_macros.c
dwarfdump/sanitized.c

Removed trailing whitespace.
dwarfexample/simplereader.c

New checking for corrupt input.
libdwarf/dwarf_errmsg_list.c
libdwarf/dwarf_form.c
libdwarf/dwarf_line.c
libdwarf/dwarf_opaque.h
libdwarf/dwarf_query.c
libdwarf/dwarf_util.h
libdwarf/libdwarf.h.in
2016-05-06 08:26:36 -07:00
David Anderson
43612f3866 Move up 3 lines of code( a test for NULL) so we do
not dereference a NULL pointer.
libdwarf/dwarf_macro5.c
2016-05-04 07:25:49 -07:00
David Anderson
98a3da1e82 Improve some error checks. Fix line printing for
standard tables: header says lno now,
for line number (row was incorrect).
dwarfdump/dwarfdump.c
dwarfdump/print_die.c
dwarfdump/print_lines.c

New checks for correctness and section overrun.
Fixed duplicate free due to bug in DWARF5 macro
handling.
libdwarf/dwarf_arange.c
libdwarf/dwarf_die_deliv.c
libdwarf/dwarf_elf_access.c
libdwarf/dwarf_errmsg_list.c
libdwarf/dwarf_frame2.c
libdwarf/dwarf_leb.c
libdwarf/dwarf_line.c
libdwarf/dwarf_line.h
libdwarf/dwarf_line_table_reader_common.c
libdwarf/dwarf_macro5.c
libdwarf/dwarf_util.h
libdwarf/libdwarf.h.in
2016-05-04 06:45:00 -07:00
David Anderson
cbea749340 libdwarf:
* dwarf_arange.c,dwarf_util.c: first use of READ_UNALIGNED_CK.
    * dwarf_errmsg_list.c, libdwarf.h.in: DW_DLE_READ_LITTLEENDIAN_ERROR
      and DW_DLE_READ_BIGENDIAN_ERROR are errors possible
      in READ_UNALIGNED_CK.
    * dwarf_query.c: Using local variables for shorter lines.
    * dwarf_util.h: Implement READ_UNALIGNED_CK macros.
2016-04-30 15:58:55 -07:00
David Anderson
6d1f2536d0 switch to using DECODE_LEB*_CK everywhere applicable..
Preventing a wide class of crashes due to damaged
object files.

libdwarf/dwarf_arange.c
libdwarf/dwarf_frame.c
libdwarf/dwarf_frame.h
libdwarf/dwarf_frame2.c
libdwarf/dwarf_line_table_reader_common.c
libdwarf/dwarf_loc2.c
2016-04-30 13:01:56 -07:00
David Anderson
0c259d4b70 libdwarf
* dwarf_die_deliv.c: Deleted unused local variable.
    * dwarf_form.c,dwarf_macro.c, dwarf_macro5.c: Now uses
      DCODE_LEB128*_CK nearly everywhere
      for better checking for corrupted data.
    * dwarf_opaque.h:New argument to _dwarf_get_addr_index_itself()
      for better data checks..
    * dwarf_query.c: Uses revised _dwarf_get_addr_index_itself()
      interface.
    * dwarf_util.c: Fixed formatting errors.
2016-04-30 07:15:22 -07:00
David Anderson
d15483a528 libdwarf: Catching leb errors/corruption
and simplifying the code.
   dwarf_line_table_reader_common.c
   dwarf_macro.c
   dwarf_macro5.c
   dwarf_util.c
   dwarf_util.h
2016-04-29 15:41:16 -07:00
David Anderson
6e55f02d7e libdwarf:
* dwarf_die_deliv.c: Now _dwarf_next_die_info_ptr() has
      a section end argument.
    * dwarf_query.c, dwarf_util.c: Now uses the checked version
      of leb reading.
    * dwarf_util.h: Now _dwarf_get_size_of_val() has
      section_end_ptr argument for checking leb values
      do not overrun end of section.
2016-04-28 17:49:03 -07:00
David Anderson
f01360225d Update version string.
dwarfdump/common.c
dwarfdump/dwarfdump.c

Add a new test that chatches an object
file with bad DWARF (corrupted DWARF).
libdwarf/dwarf_frame2.c
2016-04-27 18:25:41 -07:00
David Anderson
76b6fb5846 Remove duplicative print of error number.
dwarfdump/dwarfdump.c

Ensure dependency on dwarf_errmsg_list.c
libdwarf/Makefile.in

Do much much more testing to ensure we do not
run off the end of section or accept a bogus
leb number.
libdwarf/dwarf_abbrev.c
libdwarf/dwarf_die_deliv.c
libdwarf/dwarf_errmsg_list.c
libdwarf/dwarf_frame.c
libdwarf/dwarf_frame.h
libdwarf/dwarf_frame2.c
libdwarf/dwarf_frame3.c
libdwarf/dwarf_leb.c
libdwarf/dwarf_line.c
libdwarf/dwarf_line.h
libdwarf/dwarf_line_table_reader_common.c
libdwarf/dwarf_opaque.h
libdwarf/dwarf_query.c
libdwarf/dwarf_util.c
libdwarf/dwarf_util.h
libdwarf/libdwarf.h.in
2016-04-27 13:00:06 -07:00
David Anderson
82afa79cd6 libdwarf:
Makefile.in: The new errmsg_check dependency
      line was a bit wrong. libdwarf.h should not have $(srcdir)
2016-04-26 14:12:52 -07:00
David Anderson
a1b6d0594d libdwarf:
* dwarf_errmsg_list.c: When -DTESTING ensure all the
      error messages have a value in () so we can check
      that value.
2016-04-25 14:53:15 -07:00
David Anderson
5b6a4074df libdwarf:
* dwarf_tied.c: A C11-ism crept in. Fixed.
      Added 'static' to local function declaration.
      Removed unused local variable.
    * dwarf_errmsg_list.c: Now checks that the number in ()
      matches the index (and still checks that the array size
      is the declared size) when compiled -DTESTING.
2016-04-25 14:08:01 -07:00
David Anderson
76fe128b2c libdwarf:
dwarf_errmsg_list.c: Fixed indent mistakes.
dwarf_leb.c: Fixed places where leb128_length
      was assumed non-null (dwarf_form.c passes NULL!).
      Made the NULL tests more consistent in appearance.
2016-04-25 13:18:24 -07:00
David Anderson
08efeebcf3 Remove the unneccessary typedef for 'string'
and just use char*.

Ensure the getopt tests still work.

modified:   dwarfdump/dwarfdump.c
modified:   dwarfdump/dwgetopt.c
modified:   dwarfdump/esb.c
modified:   dwarfdump/esb.h
modified:   dwarfdump/getopttest.c
modified:   dwarfdump/globals.h
modified:   dwarfdump/print_die.c
modified:   dwarfdump/print_frames.c
modified:   dwarfdump/print_lines.c
modified:   dwarfdump/print_strings.c
modified:   dwarfdump/tag_attr.c
modified:   dwarfdump/tag_tree.c

Fixing errnumber->string array and arranging
that we test it during build.

modified:   libdwarf/Makefile.in
renamed:    libdwarf/dwarf_error.c -> libdwarf/dwarf_errmsg_list.c
modified:   libdwarf/dwarf_error.c
2016-04-25 13:01:30 -07:00
David Anderson
74681a0a34 Merge branch 'carlos_enciso'
Changes that enable Windows compilation with a C++ compiler
though the code in libdwarf is all C90.
And fix a bug with esb* interfaces that was found by
testing code not in libdwarf or dwarfdump.
2016-04-25 08:50:08 -07:00
David Anderson
51c8c08ef4 libdwarf/dwarf_error.c: The error description
"DW_DLE_GDB_INDEX_INDEX_ERROR(264)" was missing the
      comma so following errors were reporting the wrong string.
2016-04-25 08:18:51 -07:00
Carlos Alberto Enciso
720e94b7db Use the _WIN32 macro to identify a WINDOWS specific code.
The macro is automatically defined by the VS C/C++ compiler.
2016-04-21 09:47:04 +01:00
David Anderson
d820dd3dcd libdwarf
* dwarf_util.c(_dwarf_get_abbrev_for_code):
      Changed 'byte' to 'byte pair'
      in a comment.  Where we read abbreviation AT/FORM lists.
      For correctness.
2016-03-14 16:06:58 -07:00
David Anderson
67e007a29c Fixed compiler warnings (--enable-wall)
dwarfexample/frame1.c

Added new options for test coverage.
dwarfexample/simplereader.c

Notes about changes new this year.
libdwarf/NEWS

Better words about error handling.
libdwarf/dwarf_error.c
libdwarf/libdwarf2.1.mm
libdwarf/libdwarf2.1.pdf
2016-03-14 14:19:58 -07:00
David Anderson
cb5b47a1a0 libdwarf2.1.mm documents Dwarf_Handler and gives example.
libdwarf2.1.pdf regenerated. 2.47
2016-03-14 07:46:44 -07:00
David Anderson
f0994cfc0a tweaked libdwarf/ChangeLog for completeness. 2016-03-14 07:13:27 -07:00
David Anderson
3f9c12e062 Add a new option to simplereader
(for testing libdwarf it's no longer so simple).
Support configure --enable-wall.
dwarfexample/Makefile.in
dwarfexample/configure
dwarfexample/configure.in
dwarfexample/simplereader.c

Now works with DW_FORM_GNU_strp_alt and DW_FORM_strp_sup
(as well as it can) even if there is no error argument passed
in to dwarf_formstring (and now dwarf_diename()
and dwarf_die_text() call dwarf_formstring() so all
types of string values are handled).
libdwarf/dwarf_form.c
libdwarf/dwarf_query.c
2016-03-14 07:07:12 -07:00
David Anderson
0a5438abb4 Improved reporting of abbreviations
dwarfdump/print_abbrevs.c
dwarfdump/print_die.c

libdwarf/dwarf_abbrev.c
libdwarf/dwarf_abbrev.h
libdwarf/dwarf_die_deliv.c
libdwarf/dwarf_die_deliv.h
libdwarf/dwarf_query.c
libdwarf/dwarf_util.c
libdwarf/libdwarf.h.in
libdwarf/libdwarf2.1.mm
libdwarf/libdwarf2.1.pdf
2016-03-12 17:07:20 -08:00
David Anderson
ebf7f8b181 * dwarf_die_deliv.c: Fixed issues with handling NULL
Dwarf_Error*  and with mistakes treating DW_DLV_NO_ENTRY
      as if it were DW_DLV_ERROR.
    * dwarf_form.c: Only do dwarf_errno(*error) when error is non-null.
    * dwarf_macro5.c, dwarf_query.c, dwarf_ranges.c: Avoid the
      possibility of
      doing dwarf_errno(*error) when error is null.
    * dwarf_util.c(_dwarf_error_mv_s_to_t): Added code to
      ensure that nothing crash-worthy happens
      even if a future internal caller calls it with one or more NULL
      arguments.
    * libdwarf2.1.mm: Added a few words about Error Handling in general
      to clarify earlier wording (earlier wording  was not as explicit
      as it should have been).
    * libdwarf2.1.pdf: Regenerated. Version 2.45
    * dwarf_sort_line.c: Though no longer built or used, added
      an initializer to a local variable for correctness.
2016-03-11 12:41:28 -08:00
David Anderson
d527848e6c Add a comment about pr use in building a pdf.
Makefile.in
2016-03-11 08:00:43 -08:00
David Anderson
af3995c68f Minor alteration. No real content change.
libdwarf2.1.mm
libdwarf2.1.pdf  Rev 2.44
2016-03-09 09:52:57 -08:00
David Anderson
86a5812582 dwarfdump/dwarfdump.c
dwarfdump/globals.h
dwarfdump/print_aranges.c
dwarfdump/print_die.c
dwarfdump/print_frames.c
dwarfdump/print_lines.c
dwarfdump/print_macro.c
dwarfdump/print_pubnames.c
      print_lines.c,print_macro.c,print_pubnames.c:
      Remove the global dieprint_cu_offset, use local vars and pass around instead.
      Ensure the traverse() logic when checking type references do not evaluate
      references to other sections. Many argument lists got an additional argument or two.

libdwarf/dwarf_form.c
fix a comment
2016-03-09 08:42:50 -08:00
David Anderson
45573a89f5 libdwarf: document dwarf_dietype() and the new
function dwarf_offset_list()
checkexamples.c
libdwarf2.1.mm
libdwarf2.1.pdf
2016-03-07 11:33:19 -08:00
Carlos Alberto Enciso
e8701c78b8 Memory corruption due to incorrect usage of memory allocator type.
dwarf_alloc.h, dwarf_alloc.c, dwarf_base_types.h, dwarf_opaque.h:
  New allocator type (DW_DLA_CHAIN_2), to allow a list of addressed
  types (address, offset).

dwarf_query.c: Use the new allocator type.
2016-02-19 14:39:14 +00:00
Carlos Alberto Enciso
e7471e8add * dwarf_query.c, libdwarf.h.in: New function to get the children
offsets for a given offset.
2016-02-18 16:25:02 +00:00
David Anderson
5654c549d1 Changed a couple [] to [ ]
as apparently cross-compiling fails with []

dwarfdump/configure.in
dwarfdump/configure Regenerated
libdwarf/configure.in
libdwarf/configure Regenerated
2016-02-14 08:28:44 -08:00
David Anderson
3c19fc1b05 Fixed typo in libdwarf2.1.mm.
Regenerated pdf, now is version 2.42.
2016-02-14 07:48:49 -08:00
David Anderson
3f7aba30b8 dwarfdump.c,globals.h,print_aranges.c,print_die.c,
print_frames.c,print_lines.c,print_locs.c,print_macro.c,
      print_pubnames.c,print_reloc.ckprint_static_funcs.c,
      print_static_vars.c,print_strings.c,print_types.c,
      print_weaknames.c: Removed global Dwarf_Error err
      and provided local Dwarf_Error as needed.

libdwarf2.1.mm: Added dwarf_lineoff_b() documentation.
Fixed a typo in dwarf_formexprloc() documentation.
libdwarf2.1.pdf: Regenerated. Version 2.41
2016-02-13 12:53:11 -08:00
David Anderson
4e8d8c0f10 Add local Dwarf_Error and
rename variables to avoid shadowing confusion.

dwarfdump/configure
dwarfdump/configure.in
dwarfdump/dwarf_tsearchbal.c
dwarfdump/dwarfdump.c
dwarfdump/globals.h
dwarfdump/print_abbrevs.c
dwarfdump/print_aranges.c
dwarfdump/print_debugfission.c
dwarfdump/print_die.c
dwarfdump/print_frames.c
dwarfdump/print_gdbindex.c
dwarfdump/print_lines.c
dwarfdump/print_pubnames.c
dwarfdump/print_ranges.c
dwarfdump/print_sections.c
dwarfdump/tag_attr.c
dwarfdump/tag_tree.c

Add local Dwarf_Error and
rename variables to avoid shadowing confusion.
Make cross-build a littl easier.

libdwarf/Makefile.in
libdwarf/README
libdwarf/common.c
libdwarf/common.h
libdwarf/configure
libdwarf/configure.in
libdwarf/dwarf_die_deliv.c
libdwarf/dwarf_frame2.c
libdwarf/dwarf_line.c
libdwarf/dwarf_line_table_reader_common.c
libdwarf/dwarf_macro5.c
libdwarf/dwarf_print_lines.c
libdwarf/dwarf_ranges.c
libdwarf/gennames.c
2016-02-13 08:37:24 -08:00
David Anderson
c446254e5e Add support for SHF_COMPRESSED
libdwarf/README
libdwarf/dwarf_elf_access.c
libdwarf/dwarf_error.c
libdwarf/dwarf_init_finish.c
libdwarf/dwarf_opaque.h
libdwarf/libdwarf.h.in
libdwarf/libdwarfdefs.h
2016-02-10 09:05:27 -08:00
David Anderson
d02c7b92b5 Some places in the hash functions were not
using DW_TSHASHTYPE. Now they are.
libdwarf/dwarf_alloc.c
libdwarf/dwarf_tied.c
libdwarf/dwarf_tsearchhash.c
2016-02-08 09:11:40 -08:00
David Anderson
cd130546c1 libdwarf:
* dwarf_init_finish.c: Fix indents. remove a trailing space.
    * dwarf_tsearch.h,dwarf_tsearchhash.c: Now DW_TSHASHTYPE (if not defined
      otherwise) defines the type returned by the hash function
      used in tsearchhash.
    * pro_alloc.c: Removed trailing whitespace.

tsearch:
* RUNTEST: the script had a couple of problems (typos). Fixed.
       Added comments about running the tests.
     * dwarf_tsearch.h: Provide a default DW_TSHASHTYPE
       for tsearchhash and use DW_TSHASHTYPE.
     * dwarf_tsearchbal.c,dwarf_tsearchbin.c,dwarf_tsearchepp.c,
       dwarf_tsearchred.c: Use DW_TSHASHTYPE.
     * dwarf_tsearchhash.c: use DW_TSHASHTYPE, add UNUSEDARG use.
       Now the primes list starts at 79, not 5 (the low numbers
       were really only for basic testing). Add UNUSEDARG
       though it is defined as empty here (it is for gcc
       to suppress some warnings).
     * tsearch_tester.c: Use DW_TSHASHTYPE.  Changed one
       error message to help match with input test files.
2016-02-07 13:35:42 -08:00
David Anderson
9ced54f5ad Fix typo
libdwarf/ChangeLog
2016-02-07 06:38:39 -08:00
David Anderson
33dd0d8f3c update version string
dwarfdump/common.c
dwarfdump/dwarfdump.c

Document https://github.com/jrfonseca/drmingw/tree/master/src/mgwhelp
and include a little help for mingw users.
libdwarf/README
libdwarf/dwarf_init_finish.c
2016-02-07 06:36:42 -08:00
David Anderson
4945a195c3 Removed trailing whitespace.
dwarfdump/print_die.c
dwarfdump/tag_attr.c
dwarfdump/tag_tree.c

libdwarf/dwarf_elf_access.c
libdwarf/dwarf_original_elf_init.c
libdwarf/dwarf_tsearchhash.c
libdwarf/libdwarfdefs.h
2016-02-06 14:38:13 -08:00