Commit Graph

482 Commits

Author SHA1 Message Date
Alan Modra
be7d229ad4 Don't use bfd_size_type in readelf.c and dwarf.c
Replacing bfd_size_type with dwarf_size_type or uint64_t is mostly
cosmetic.  The point of the change is to avoid use of a BFD type
in readelf, where we'd like to keep as independent of BFD as
possible.  Also, the patch is a step towards using standard types.
2022-08-13 14:11:27 +09:30
Alan Modra
dfbc689c69 Sanity check loc_offsets index
Fixes a segfault found by the fuzzers.

	* dwarf.c (fetch_indexed_value): Return -1 on error.
	(read_and_display_attr_value): Don't display string when
	fetch_indexed_value returns an error.  Sanity check loc_offsets
	index.
2022-08-05 20:48:29 +09:30
Jan Beulich
188bc85476 binutils/Dwarf: avoid "shadowing" of glibc function name
As before: Old enough glibc has an (unguarded) declaration of index()
in string.h, which triggers a "shadows a global declaration" warning.
2022-08-05 12:48:17 +02:00
Alan Modra
e4e340a3ff PR29390, DW_CFA_AARCH64_negate_ra_state vs. DW_CFA_GNU_window_save
PR 29390
binutils/
	* dwarf.c (is_aarch64, DW_CFA_GNU_window_save_name): New.
	(display_debug_frames): Use them.
	(init_dwarf_regnames_aarch64): Set is_aarch64.
	(init_dwarf_regnames_by_elf_machine_code): Clear is_aarch64.
	(init_dwarf_regnames_by_bfd_arch_and_mach): Likewise.
gas/
	* testsuite/gas/aarch64/pac_ab_key.d: Adjust expected output.
	* testsuite/gas/aarch64/pac_negate_ra_state.d: Likewise.
2022-07-21 16:37:06 +09:30
Alan Modra
e82295b23d PR29337, readelf CU/TU mixup in .gdb_index
Commit 244e19c791 changed a number of variables in display_gdb_index
to count entries rather than words.

	PR 29337
	* dwarf.c (display_gdb_index): Correct use of cu_list_elements.
2022-07-21 14:54:54 +09:30
Alan Modra
695c6dfe7e PR29370, infinite loop in display_debug_abbrev
The PR29370 testcase is a fuzzed object file with multiple
.trace_abbrev sections.  Multiple .trace_abbrev or .debug_abbrev
sections are not a violation of the DWARF standard.  The DWARF5
standard even gives an example of multiple .debug_abbrev sections
contained in groups.  Caching and lookup of processed abbrevs thus
needs to be done by section and offset rather than base and offset.
(Why base anyway?)  Or, since section contents are kept, by a pointer
into the contents.

	PR 29370
	* dwarf.c (struct abbrev_list): Replace abbrev_base and
	abbrev_offset with raw field.
	(find_abbrev_list_by_abbrev_offset): Delete.
	(find_abbrev_list_by_raw_abbrev): New function.
	(process_abbrev_set): Set list->raw and list->next.
	(find_and_process_abbrev_set): Replace abbrev list lookup with
	new function.  Don't set list abbrev_base, abbrev_offset or next.
2022-07-21 13:35:51 +09:30
Alan Modra
f07c08e115 binutils/dwarf.c: abbrev caching
I'm inclined to think that abbrev caching is counter-productive.  The
time taken to search the list of abbrevs converted to internal form is
non-zero, and it's easy to decode the raw abbrevs.  It's especially
silly to cache empty lists of decoded abbrevs (happens with zero
padding in .debug_abbrev), or abbrevs as they are displayed when there
is no further use of those abbrevs.  This patch stops caching in those
cases.

	* dwarf.c (record_abbrev_list_for_cu): Add free_list param.
	Put abbrevs on abbrev_lists here.
	(new_abbrev_list): Delete function.
	(process_abbrev_set): Return newly allocated list.  Move
	abbrev base, offset and size checking to..
	(find_and_process_abbrev_set): ..here, new function.  Handle
	lookup of cached abbrevs here, and calculate start and end
	for process_abbrev_set.  Return free_list if newly alloc'd.
	(process_debug_info): Consolidate cached list lookup, new list
	alloc and processing into find_and_process_abbrev_set call.
	Free list when not cached.
	(display_debug_abbrev): Similarly.
2022-07-21 13:35:51 +09:30
Alan Modra
175b91507b miscellaneous dwarf.c tidies
* dwarf.c: Leading and trailing whitespace fixes.
	(free_abbrev_list): New function.
	(free_all_abbrevs): Use the above.  Free cu_abbrev_map here too.
	(process_abbrev_set): Print actual section name on error.
	(get_type_abbrev_from_form): Add overflow check.
	(free_debug_memory): Don't free cu_abbrev_map here..
	(process_debug_info): ..or here.  Warn on another case of not
	finding a neeeded abbrev.
2022-07-21 13:35:51 +09:30
Bhuvanendra Kumar N
ad349f2493 Descriptive DWARF operations dump support for DW_AT_rank
DW_AT_rank is a dwarf-5 feature.
2022-07-06 16:27:47 +05:30
Bhuvanendra Kumar N
4694a0e5fe Support for location and range lists for split-dwarf and dwarf-5.
Adding support for location and range lists for split-dwarf and dwarf-5.
Following issues are taken care.
1. Display of the index values for DW_FORM_loclistx and DW_FORM_rnglistx.
2. Display of .debug_loclists.dwo and .debug_rnglists.dwo sections.

        * dwarf.c(read_and_display_attr_value): Handle DW_FORM_loclistx
        and DW_FORM_rnglistx for .dwo files.
        (process_debug_info): Load .debug_loclists.dwo and
        .debug_rnglists.dwo if exists.
        (load_separate_debug_files): Load .debug_loclists and
        .debug_rnglists if exists.
        Include 2 entries in debug_displays table.
        * dwarf.h (enum dwarf_section_display_enum): Include 2 entries.
2022-07-05 16:56:13 +05:30
Bhuvanendra Kumar N
407115429b Modified changes for split-dwarf and dwarf-5.
* dwarf.c(process_debug_info): Include DW_TAG_skeleton_unit.
        (display_debug_str_offsets): While dumping .debug_str_offsets.dwo,
        pass proper str_offsets_base to fetch_indexed_string().
        (load_separate_debug_files): Skip DWO ID dump for dwarf-5.
2022-07-04 16:42:35 +05:30
Nick Clifton
1dd024239b Add newline to the end of the rnglists displsy. 2022-07-01 15:08:44 +01:00
Nick Clifton
aa40d66bb1 Fix implementation of readelf's -wE and -wN options,
* dwarf.c (dwarf_select_sections_by_name): If the entry's value is
	zero then clear the corresponding variable.
	(dwarf_select_sections_by_letters): Likewise.
	* testsuite/binutils-all/debuginfo.exp: Expect -WE and -wE
	debuginfod tests to fail.
2022-06-30 14:53:02 +01:00
Nick Clifton
dbcbf67ca5 Fix the display of the idnex values for DW_FORM_loclistx and DW_FORM_rnglistx. Correct the display of .debug.loclists sections.
PR 29267
	* dwarf.c (display_debug_rnglists): New function, broken out of..
	(display_debug_ranges): ... here.
	(read_and_display_attr_value): Correct calculation of index
	displayed for DW_FORM_loclistx and DW_FORM_rnglistx.
	* testsuite/binutils-all/x86-64/pr26808.dump: Update expected
	output.
2022-06-28 12:30:19 +01:00
Nick Clifton
e3e5ae0493 Replace a run-time assertion failure with a warning message when parsing corrupt DWARF data.
PR 29289
	* dwarf.c (display_debug_names): Replace assert with a warning
	message.
2022-06-27 13:43:02 +01:00
Nick Clifton
e98e7d9a70 Fix NULL pointer indirection when parsing corrupt DWARF data.
PR 29290
	* dwarf.c (read_and_display_attr_value): Check that debug_info_p
	is set before dereferencing it.
2022-06-27 13:30:35 +01:00
Nick Clifton
a3f1431a50 Stop bogus warnings about DWARF indexed string offsets being too big.
* dwarf.c (fetch_indexed_string): Do not use length of first table
	in string section as the length of every table in the section.
	* testsuite/binutils-all/pr26112.r: Update expected output.
2022-06-27 11:49:14 +01:00
Bhuvanendra Kumar N
2d1388e73c Fix location list offset address dump under DW_AT_location (dwarf-5)
For clang compiled objects with dwarf-5, location list offset address dump
under DW_AT_location is corrected, where DW_FORM_loclistx is used. While
dumping the location list offset, the address dumped is wrong where it was
refering to .debug_addr instead of .debug_loclists

      * dwarf.c (fetch_indexed_value): Add base_address as parameter and
      use it to access the section offset.
      (read_and_display_attr_value): Handle DW_FORM_loclistx form separately.
      Pass loclists_base to fetch_indexed_value().
2022-06-27 13:34:09 +05:30
Kumar N, Bhuvanendra
f18acc9c4e Binutils support for split-dwarf and dwarf-5
* dwarf.c (fetch_indexed_string): Added new parameter
	str_offsets_base to calculate the string offset.
	(read_and_display_attr_value): Read DW_AT_str_offsets_base
	attribute.
	(process_debug_info): While allocating memory and initializing
	debug_information, do it for do_debug_info also, if its true.
	(load_separate_debug_files): Load .debug_str_offsets if exists.
	* dwarf.h (struct debug_info): Add str_offsets_base field.
2022-06-22 17:07:25 +01:00
Alan Modra
581db2a29b PR29270, DW_FORM_udata signed output
PR 29270
	* dwarf.c (read_and_display_attr_value): Output DW_FORM_udata
	as unsigned.
2022-06-22 12:36:51 +09:30
Nick Clifton
ec41dd75c8 Binutils support for dwarf-5 (location and range lists related)
* dwarf.h (struct debug_info): Add rnglists_base field.
	* dwarf.c (read_and_display_attr_value): Read attribute DW_AT_rnglists_base.
	(display_debug_rnglists_list): While handling DW_RLE_base_addressx,
  	DW_RLE_startx_endx, DW_RLE_startx_length items, pass the proper parameter
	value to fetch_indexed_addr(), i.e. fetch the proper entry in .debug_addr section.
	(display_debug_ranges): Add rnglists_base to the .debug_rnglists base address.
	(load_separate_debug_files): Load .debug_addr section, if exists.
2022-06-21 16:37:27 +01:00
Alan Modra
68f7e451e5 Restore readelf -wF
Commit 94585d6d44 resulted in readelf -wF failing with
Unrecognized debug letter option 'F'

binutils/
	* dwarf.c (debug_dump_long_opts): Add letter.
	(debug_option_table): New, replacing..
	(opts_table, letter_table): ..these.
	(dwarf_select_sections_by_names): Adjust to suit.  Set
	do_debug_frames outside of loop.
	(dwarf_select_sections_by_letters): Similarly.
gas/
	* testsuite/gas/i386/ehinterp.d: Use readelf -wF.
2022-06-16 09:56:39 +09:30
Alan Modra
45bf072b34 PR29250, readelf erases CIE initial register state
PR 29250
binutils/
	* dwarf.c (display_debug_frames): Set col_type[reg] on sizing
	pass over FDE to cie->col_type[reg] if CIE specifies reg.
	Handle DW_CFA_restore and DW_CFA_restore_extended on second
	pass using the same logic.  Remove unnecessary casts.  Don't
	call frame_need_space on second pass over FDE.
gas/
	* testsuite/gas/i386/ehinterp.d,
	* testsuite/gas/i386/ehinterp.s: New test.
	* testsuite/gas/i386/i386.exp: Run it.
2022-06-16 09:54:55 +09:30
Alan Modra
22b8da0ae7 asan: applying zero offset to NULL pointer
* dwarf.c (fetch_indexed_string): Move initialisation of "curr"
	and "end" after checking for missing section.
2022-06-14 09:56:45 +09:30
Natarajan, Kavitha
3ac9da4937 Add bionutils support for DWARF v5's DW_OP_addrx. 2022-05-25 16:10:38 +01:00
Alan Modra
be38442dda PR29171, invalid read causing SIGSEGV
The fix here is to pass "section" down to read_and_display_attr_value.
The test in read_and_display_attr_value is a little bit of hardening.

	PR 29171
	* dwarf.c (display_debug_macro, display_debug_names): Pass section
	to read_and_display_attr_value2.
	(read_and_display_attr_value): Don't attempt to check for .dwo
	section name when section is NULL.
2022-05-24 12:05:39 +09:30
Alan Modra
5fbb38fcc5 PR29170, divide by zero displaying fuzzed .debug_names
PR 29170
	* dwarf.c (display_debug_names): Don't attempt to display bucket
	clashes when bucket count is zero.
2022-05-24 10:52:05 +09:30
Alan Modra
244e19c791 PR29169, invalid read displaying fuzzed .gdb_index
PR 29169
	* dwarf.c (display_gdb_index): Combine sanity checks.  Calculate
	element counts, not word counts.
2022-05-24 09:50:17 +09:30
Nick Clifton
94585d6d44 Stop readekf and objdump from aggressively following links.
* dwarf.c (dwarf_select_sections_by_names): Return zero if no
	sections were selected.
	(dwarf_select_sections_by_letters): Likewise.
	* dwarf.h: (dwarf_select_sections_by_names): Update prototype.
	(dwarf_select_sections_by_letters): Update prototype.
	* objdump.c (might_need_separate_debug_info): New function.
	(dump_bfd): Call new function before attempting to load separate
	debug info files.
	(main): Do not enable dwarf section dumping for -WK or -WN.
	* readelf.c (parse_args): Do not enable dwarf section dumping for
	-wK or -wN.
	(might_need_separate_debug_info): New function.
	(process_object): Call new function before attempting to load
	separate debug info files.
	* testsuite/binutils-all/debuginfo.exp: Expect -WE and -wE
	debuginfod tests to pass.
	* testsuite/binutils-all/objdump.Wk: Add extra regexps.
	* testsuite/binutils-all/readelf.k: Add extra regexps.
2022-05-20 16:55:36 +01:00
Jan Beulich
3569f4ab7e Dwarf: rename yet another instance of "index"
As before, on sufficiently old glibc this conflicts with a global
identifier in the library headers. While there also zap the unusual
padding by blanks.
2022-05-04 08:36:14 +02:00
Nick Clifton
19c26da69d Add code to display the contents of .debug_loclists sections which contain offset entry tables.
PR 28981
	* dwarf.c (fetch_indexed_value): Rename to fecth_indexed_addr and
	return the address, rather than a string.
	(fetch_indexed_value): New function - returns a value indexed by a
	DW_FORM_loclistx or DW_FORM_rnglistx form.
	(read_and_display_attr_value): Add support for DW_FORM_loclistx
	and DW_FORM_rnglistx.
	(process_debug_info): Load the loclists and rnglists sections.
	(display_loclists_list): Add support for DW_LLE_base_addressx,
	DW_LLE_startx_endx, DW_LLE_startx_length and
	DW_LLE_default_location.
	(display_offset_entry_loclists): New function.  Displays a
	.debug_loclists section that contains offset entry tables.
	(display_debug_loc): Call the new function.
	(display_debug_rnglists_list): Add support for
	DW_RLE_base_addressx, DW_RLE_startx_endx and DW_RLE_startx_length.
	(display_debug_ranges): Display the contents of the section's
	header.
	* dwarf.h (struct debug_info): Add loclists_base field.
	* testsuite/binutils-all/dw5.W: Update expected output.
	* testsuite/binutils-all/x86-64/pr26808.dump: Likewise.
2022-04-06 14:43:37 +01:00
Nick Clifton
bed566bbf6 Add option to objdump/readelf to disable access to debuginfod servers.
* dwarf.c (use_debuginfod): New variable.  Set to 1.
	(load_separate_debug_info): Only call
	debuginfod_fetch_separate_debug_info is use_debuginfod is true.
	(dwarf_select_sections_by_names): Add do-not-use-debuginfod and
	use-debuginfod options.
	(dwarf_select_sections_by_letters): Add D and E options.
	* dwarf.h (use_debuginfod): New extern.
	* objdump.c (usage): Mention the new options.
	* readelf.c (usage): Likewise.
	* doc/binutils.texi: Document the new options.
	* doc/debug-options.texi: Describe the new options.
	* NEWS: Mention the new feature.
	* testsuite/binutils-all/debuginfod.exp: Add tests of the new
	options.
2022-03-10 09:11:40 +00:00
Hans-Peter Nilsson
c4f5871457 objdump, readelf: Emit "CU:" format only when wide output is requested
As pre-approved by Alan in
https://sourceware.org/pipermail/binutils/2021-September/118019.html
and I believe people have run into getting testsuite failures for
test-environments with "long" directory names, at least once more
since that time.  Enough.  I grepped the gas, binutils and ld
testsuites for "CU:" to catch target-specific occurrences, but I
noticed none.  I chose to remove "CU:" on the objdump tests instead of
changing options to get the wide format, so as to keep the name of the
test consistent with actual options; but added it to the readelf
options for the gas test as I believe the "CU:" format is preferable.

Tested for cris-elf and native x86_64-pc-linux-gnu.

binutils:
	* dwarf.c (display_debug_lines_decoded): Don't check the
	string length of the directory, instead emit the "CU: dir/name"
	format only if wide output is requested.
	* testsuite/binutils-all/dw5.W, testsuite/binutils-all/objdump.WL:
	Adjust accordingly.

gas:
	* testsuite/gas/elf/dwarf-5-loc0.d: Add -W to readelf options.
2022-01-12 05:51:25 +01:00
Nick Clifton
40c01d1b3d Add ATTRIBUTE_UNUSED to load_build_id_debug_file()'s main_filename parameter. 2022-01-04 10:34:01 +00:00
Nick Clifton
e2c0cef94d Remove a spurious debugging message.
PR 28716
	* dwarf.c (load_build_id_debug_file): Remove spurious printf.
2022-01-04 10:26:15 +00:00
Alan Modra
a2c5833233 Update year range in copyright notice of binutils files
The result of running etc/update-copyright.py --this-year, fixing all
the files whose mode is changed by the script, plus a build with
--enable-maintainer-mode --enable-cgen-maint=yes, then checking
out */po/*.pot which we don't update frequently.

The copy of cgen was with commit d1dd5fcc38ead reverted as that commit
breaks building of bfp opcodes files.
2022-01-02 12:04:28 +10:30
Alan Modra
dbc6a0e2e4 try_build_id_prefix gcc-10 -Wformat-security errors
dwarf.c:11300:3: error: format not a string literal and no format arguments [-Werror=format-security]
11300 |   f += sprintf (f, prefix);

	PR 28697
	* dwarf.c (try_build_id_prefix): Avoid -Wformat-security error.
2021-12-17 11:42:18 +10:30
Nick Clifton
61ab1364c7 When loading separate debug info files, also attempt to locate a file based upon the build-id.
PR 28697
	* dwarf.c (load_build_id_debug_file): New function.
	(try_build_id_prefix): New function.
	(check_for_and_load_links): Call load_build_id_debug_file.
	(debug_displays): Add entry for .note.gnu.build-id.
	* dwarf.h (enum dwarf_section_display_enum): Add
	note_gnu_build_id.
	* testsuite/binutils-all/debuginfod.exp (test_fetch_debuglink):
	Fix regexp for loads via debuglink section.
2021-12-16 14:05:40 +00:00
H.J. Lu
40eb8b92a1 Don't return the main file as the separate debug info
On Fedora 35,

$ readelf -d /usr/bin/npc

caused readelf to run out of stack since load_separate_debug_info
returned the input main file as the separate debug info:

(gdb) bt
 #0  load_separate_debug_info (
    main_filename=main_filename@entry=0x510f50 "/export/home/hjl/.cache/debuginfod_client/dcc33c51c49e7dafc178fdb5cf8bd8946f965295/debuginfo",
    xlink=xlink@entry=0x4e5180 <debug_displays+4480>,
    parse_func=parse_func@entry=0x431550 <parse_gnu_debuglink>,
    check_func=check_func@entry=0x432ae0 <check_gnu_debuglink>,
    func_data=func_data@entry=0x7fffffffdb60, file=file@entry=0x51d430)
    at /export/gnu/import/git/sources/binutils-gdb/binutils/dwarf.c:11057
 #1  0x000000000043328d in check_for_and_load_links (file=0x51d430,
    filename=0x510f50 "/export/home/hjl/.cache/debuginfod_client/dcc33c51c49e7dafc178fdb5cf8bd8946f965295/debuginfo")
    at /export/gnu/import/git/sources/binutils-gdb/binutils/dwarf.c:11381
 #2  0x00000000004332ae in check_for_and_load_links (file=0x51b070,
    filename=0x518dd0 "/export/home/hjl/.cache/debuginfod_client/dcc33c51c49e7dafc178fdb5cf8bd8946f965295/debuginfo")

Return NULL if the separate debug info is the same as the input main
file to avoid infinite recursion.

	PR binutils/28679
	* dwarf.c (load_separate_debug_info): Don't return the input
	main file.
2021-12-10 17:52:40 -08:00
Nick Clifton
117e35f519 Fix illegal memory access whilst parsing corrupt DWARF debug information.
PR 28645
	* dwarf.c (process_cu_tu_index): Add test for overruning section
	whilst processing slots.
2021-12-02 17:48:20 +00:00
Nick Clifton
9745b5a753 Use dwarf_vma type for offsets, ranges and section sizes in DWARF decoder.
* dwarf.c (find_debug_info_for_offset): Use dwarf_vma type for
	offsets, sizes and ranges.
	(display_loc_list): Likewise.  Also use print_dwarf_vma to print
	the offset.
	(display_loclists_list): Likewise.
	(display_loc_list_dwo): Likewise.
	(display_debug_str): Likewise.
	(display_debug_aranges): Likewise.
	(display_debug_ranges_list): Likewise.
	(display_debug_rnglists_list): Likewise.
	(display_debug_ranges): Likewise.
2021-11-30 13:17:49 +00:00
Alan Modra
84f82c95bc PR28543, readelf entered an infinite loop
This little tweak terminates fuzzed binary readelf output a little
quicker.

	PR 28543
	* dwarf.c (read_and_display_attr_value): Consume a byte when
	form is unrecognized.
2021-11-10 09:20:10 +10:30
Alan Modra
ca8775833b PR28541, unstable cie offset in the output of readelf
Calculating "0 - pointer" can indeed result in seeming randomness as
the pointer address varies.

	PR 28541
	* dwarf.c (display_debug_frames): Don't print cie offset when
	invalid, print "invalid" instead.  Remove now redundant warning.
2021-11-05 21:32:02 +10:30
Tom Tromey
dac784d0e4 Use section name in warnings in display_debug_loc
While looking at an apparently malformed executable with
"readelf --debug-dump=loc", I got this warning:

    readelf: ./main: Warning: There is a hole [0x89 - 0x95] in .debug_loc section.

However, the executable only has a .debug_loclists section.

This patch fixes the warning messages in display_debug_loc to use the
name of the section that is being processed.

binutils/ChangeLog
2021-11-03  Tom Tromey  <tromey@adacore.com>

	* dwarf.c (display_debug_loc): Use section name in warnings.
2021-11-03 07:33:24 -06:00
Alan Modra
359c74415c asan: assert (addr_ranges) <= (start)
That assert would be more obvious if it were reported as
"addr_ranges <= end_ranges".  Fix that by using the obvious variable
in the final loop.  Stop the assertion by using a signed comparison:
It's possible for the rounding up of the arange pointer to exceed the
end of the block when the block size is fuzzed.

	* dwarf.c (display_debug_aranges): Use "end_ranges" in loop
	displaying ranges rather that "start".  Simplify rounding up
	to 2*address_size boundary.  Use signed comparison in loop.
2021-11-03 15:43:23 +10:30
Alan Modra
e7f024765a PR28459, readelf issues bogus warning
I'd missed the fact that the .debug_rnglists dump doesn't exactly
display the contents of the section.  Instead readelf rummages through
.debug_info looking for DW_AT_ranges entries, then displays the
entries in .debug_rnglists pointed at, sorted.  A simpler dump of the
actual section contents might be more useful and robust, but it was
likely done that way to detect overlap and holes.

Anyway, the headers in .debug_rnglists besides the first are ignored,
and limiting to the unit length of the first header fails if there is
more than one unit.

	PR 28459
	* dwarf.c (display_debug_ranges): Don't constrain data to length
	in header.
2021-10-17 20:01:34 +10:30
Alan Modra
fba9460f7c PR27202, readelf -wL doesn't work on ".loc 0"
For DWARF revision 4 and earlier, display_debug_lines_decoded
populates the file_table array with entries read from .debug_line
after the directory table.  file_table[0] contains the first entry.
DWARF rev 4 line number programs index this entry as file number one.
DWARF revision 5 changes .debug_line format quite extensively, and in
particular gives file number zero a meaning.

	PR 27202
	* dwarf.c (display_debug_lines_decoded): Correct indexing used
	for DWARF5 files.
2021-09-29 12:07:37 +09:30
Nick Clifton
c58830e49d Updated Swedish translation for the binutils sub-directory 2021-07-16 13:57:15 +01:00
Clément Chigot
51d29b8cac objdump: add DWARF support for AIX
DWARF sections have special names on AIX which need be handled
by objdump in order to correctly print them.
This patch also adds the correlation in bfd for future uses.

bfd/
	* libxcoff.h (struct xcoff_dwsect_name): Add DWARF name.
	* coff-rs6000.c (xcoff_dwsect_names): Update.
	* coffcode.h (sec_to_styp_flags): Likewise.
	(coff_new_section_hook): Likewise.
binutils/
	* dwarf.h (struct dwarf_section): Add XCOFF name.
	* dwarf.c (struct dwarf_section_display): Update.
	* objdump.c (load_debug_section): Add XCOFF name handler.
	(dump_dwarf_section): Likewise.
gas/
	* config/tc-ppc.c (ppc_change_debug_section): Update to
	match new name's field.
2021-07-14 21:40:05 +09:30
Alan Modra
9039747fb4 PR28069, assertion fail in dwarf.c:display_discr_list
We shouldn't be asserting on anything to do with leb128 values, or
reporting file and line numbers when something unexpected happens.
leb128 data is of indeterminate length, perfect for fuzzer mayhem.
It would only make sense to assert or report dwarf.c/readelf.c source
lines if the code had already sized and sanity checked the leb128
values.

After removing the assertions, the testcase then gave:

    <37>   DW_AT_discr_list  : 5 byte block: 0 0 0 0 0 	(label 0, label 0, label 0, label 0, <corrupt>
readelf: Warning: corrupt discr_list - unrecognized discriminant byte 0x5

    <3d>   DW_AT_encoding    : 0	(void)
    <3e>   DW_AT_identifier_case: 0	(case_sensitive)
    <3f>   DW_AT_virtuality  : 0	(none)
    <40>   DW_AT_decimal_sign: 5	(trailing separate)

So the DW_AT_discr_list was showing more data than just the 5 byte
block.  That happened due to "end" pointing a long way past the end of
block, and uvalue decrementing past zero on one of the leb128 bytes.

	PR 28069
	* dwarf.c (display_discr_list): Remove assertions.  Delete "end"
	parameter, use initial "data" pointer as the end.  Formatting.
	Don't count down bytes as they are read.
	(read_and_display_attr_value): Adjust display_discr_list call.
	(read_and_print_leb128): Don't pass __FILE__ and __LINE__ to
	report_leb_status.
	* dwarf.h (report_leb_status): Don't report file and line
	numbers.  Delete file and lnum parameters,
	(READ_ULEB, READ_SLEB): Adjust.
2021-07-10 13:23:54 +09:30
Alan Modra
40e1d303ce PR28047, readelf crash due to assertion failure
DW_FORM_ref1, DW_FORM_ref2, DW_FORM_ref4, DW_FORM_ref1, and
DW_FORM_ref_udata are all supposed to be within the containing unit.

	PR 28047
	* dwarf.c (get_type_abbrev_from_form): Add cu_end parameter.
	Check DW_FORM_ref1 etc. arg against cu_end rather than end of
	section.  Adjust all callers.
2021-07-05 20:04:21 +09:30
Alan Modra
4ff0bb2df5 PR28048, heap-buffer-overflow on readelf -Ww
PR 28048
	* dwarf.c (get_type_signedness): Don't run off end of buffer
	printing DW_FORM_string attribute.
2021-07-02 23:19:43 +09:30
Nick Clifton
c63fc3680a Handle DW_FORM_implicit_const when displaying an attribute
* dwarf.c (read_and_display_attr_value): Handle
	DW_FORM_implicit_const.
2021-06-30 16:17:46 +01:00
Richard Henderson
280c57ff58 Fix signedness of def_cfa_sf and def_cfa_offset_sf
* dwarf.c (display_debug_frames): Both DW_CFA_def_cfa_sf
 and DW_CFA_def_cfa_offset_sf have a signed offset.
2021-06-30 12:11:54 +01:00
Alan Modra
539b54f03d dwarf.c: string_fortify.h strncpy error
In function 'strncpy',
    inlined from 'display_debug_lines_decoded' at /home/alan/src/binutils-gdb/binutils/dwarf.c:5434:5,
    inlined from 'display_debug_lines' at /home/alan/src/binutils-gdb/binutils/dwarf.c:5567:21:
/usr/include/bits/string_fortified.h:95:10: error: '__builtin_strncpy' specified bound 36 equals destination size [-Werror=stringop-truncation]

No need for strncpy here, the string being copied always fits the
destination buffer.

	* dwarf.c (display_debug_lines_decoded): Use memcpy rather than
	strncpy when trimming file name length to MAX_FILENAME_LENGTH.
	Don't make an unnecessary copy when length is good.
2021-06-19 11:08:00 +09:30
Eric Botcazou
0121f438e8 Use consistent type in binutils/dwarf.c
If you look at the type used for implicit_const objects in binutils/dwarf.c,
you'll get sometimes bfd_signed_vma and sometimes dwarf_signed_vma.

They are the same on 64-bit hosts, but not on 32-bit hosts, and the latter
discrepancy, in particular in process_abbrev_set, is responsible for the
following error issued by objdump on some object files containing DWARF 5:

binutils/dwarf.c:1108: read LEB value is too large to store in destination
variable

binutis/
	* dwarf.c (struct abbrev_attr): Change type of implicit_const.
	(add_abbrev_attr): Likewise.
	(process_abbrev_set): Likewise.
	(display_debug_abbrev): Adjust to above change.
2021-06-14 15:45:55 +02:00
Jan Beulich
6bee34a1dc fix Dwarf2 build with certain gcc versions
Older gcc reports:

.../bfd/dwarf2.c: In function 'read_ranges':
.../bfd/dwarf2.c:3107: error: comparison between signed and unsigned
.../bfd/dwarf2.c: In function 'read_rnglists':
.../bfd/dwarf2.c:3189: error: comparison between signed and unsigned

Similarly for binutils/dwarf.c. Arrange for the left sides of the > to
also be unsigned quantities.
2021-06-07 08:48:26 +02:00
Eli Schwartz
c485e47599 Fix a build problem if ENABLE_CHECKING is not defined.
* dwarf.c (ENABLE_CHECKING): Define to 0 if not previously set.
2021-05-19 12:08:30 +01:00
Alan Modra
1b3892bedc PR27884, skip_attr_bytes: Assertion (data) <= (end) failed
PR 27884
	* dwarf.c (get_type_abbrev_from_form): Replace cu_offset_return
	param with map_return, and return map for DW_FORM_ref_addr.
	(get_type_signedness): Adjust calls to get_type_abbrev_from_form.
	Pass returned cu map start and end to recursive call.
	(read_and_display_attr_value): Similarly.
2021-05-19 11:07:41 +09:30
Alan Modra
b9c0d70312 process_cu_tu_index
* dwarf.c (process_cu_tu_index): Avoid pointer UB.  Use _mul_overflow.
	Delete dead code.
2021-05-15 15:40:51 +09:30
Alan Modra
bb19bf1269 display_gdb_index
* dwarf.c (display_gdb_index): Avoid pointer UB and overflow in
	length calculations.
2021-05-15 15:38:58 +09:30
Alan Modra
d7870f6304 display_debug_names
* dwarf.c (display_debug_names): Complain when header length is
	too small.  Avoid pointer UB.  Sanity check augmentation string,
	CU table, TU table and foreign TU table sizes.
2021-05-15 15:36:53 +09:30
Alan Modra
5897a38984 display_debug_frames
* dwarf.c (display_debug_frames): Delete initial_length_size.
	Avoid pointer UB.  Constrain data reads to length given in header.
	Sanity check cie header length.  Only skip up to next FDE on
	finding augmentation data too long.
2021-05-15 15:29:36 +09:30
Alan Modra
c93c4a8540 read_cie
* dwarf.c (read_cie): Add more sanity checks to ensure data
	pointer is not bumped past end.
2021-05-15 15:23:53 +09:30
Alan Modra
b495154607 display_debug_ranges
* dwarf.c (display_debug_ranges): Delete initial_length_size.
	Correct fallback size calculated on finding a reloc.  Constrain
	data reads to length given in header.  Avoid pointer UB.
2021-05-15 15:22:25 +09:30
Alan Modra
669f463dbc display_debug_rnglists_list
* dwarf.c (display_debug_rnglists_list): Avoid pointer UB.
2021-05-15 15:17:46 +09:30
Alan Modra
5250d2f0a5 display_debug_str_offsets
* dwarf.c (display_debug_str_offsets): Constrain reads to length
	given in header.
2021-05-15 15:16:35 +09:30
Alan Modra
6ca0735017 display_debug_aranges
* dwarf.c (display_debug_aranges): Delete initial_length_size.
	Use end_ranges to constrain data reads to header length.  Avoid
	pointer UB.
2021-05-15 15:15:35 +09:30
Alan Modra
7848009791 display_loc_list
* dwarf.c (display_loc_list): Avoid pointer UB.  Correct check
	before reading uleb length.  Warn on excess length.
2021-05-15 15:13:45 +09:30
Alan Modra
b0d461ec37 display_debug_macro
* dwarf.c (display_debug_macro): Print strings that might not
	be zero terminated with %*s.  Don't bump curr if unterminated.
2021-05-15 15:10:29 +09:30
Alan Modra
46d1214d88 get_line_filename_and_dirname
* dwarf.c (get_line_filename_and_dirname): Delete initial_length_size.
	Simplify length sanity check, and check for too small lengths.
	Constrain data reads to header length.  Avoid pointer UB.
2021-05-15 15:09:01 +09:30
Alan Modra
c03df92247 display_debug_macinfo
The existing code went to the bother of using strnlen for scanning but
went wild when printing, and possibly incremented curr past end.

	* dwarf.c (display_debug_macinfo): Print strings that might not
	be zero terminated with %*s.  Don't bump curr if unterminated.
2021-05-15 15:05:29 +09:30
Alan Modra
35b2c89ec8 display_debug_pubnames_worker
* dwarf.c (display_debug_pubnames_worker): Delete initial_length_size.
	Simplify length check.  Constrain reads to length given by header.
2021-05-15 15:01:39 +09:30
Alan Modra
56051e28a3 display_debug_lines_decoded
The directory_table strnlen used the negative of the proper size.  After
fixing that I realised we don't need strnlen here.

	* dwarf.c (display_debug_lines_decoded): Don't use strnlen when
	we have already checked for NUL termination.
2021-05-15 14:57:38 +09:30
Alan Modra
37195e23e7 read_debug_line_header
This patch also better constrains the data read, and removes pointer UB.

	* dwarf.c (read_debug_line_header): Delete initial_length_size.
	Avoid pointer UB.  Keep within length specified by header.
	Delete dead code.
2021-05-15 14:54:05 +09:30
Alan Modra
edba4e4aba process_debug_info
This patch constrains process_debug_info to stay within the data
specified by the CU length rather than allowing access up to the end
of the section.

	* dwarf.c (process_debug_info): Always do the first CU length
	scan for sanity checks.  Remove initial_length_size var and
	instead calculate end_cu.  Use end_cu to limit data reads.
	Delete now dead code checking length.
2021-05-15 14:48:33 +09:30
Alan Modra
ebb1786492 SAFE_BYTE_GET_INTERNAL
We won't want this assert triggering in the next release.

	* dwarf.c (SAFE_BYTE_GET_INTERNAL): Assert only when ENABLE_CHECKING.
2021-05-15 14:38:42 +09:30
Alan Modra
fc5e0925d4 _mul_overflow and get_encoded_value
A sufficiently mad compiler optimiser can take undefined behaviour
according to the C standard as an opportunity to remove code.  Since
"data + size" might be seen to be past the end of an array,
calculating such an expression is UB.

_mul_overflow is infrastructure for later patches.

	* bucomm.h (_mul_overflow): Define.
	* dwarf.c (get_encoded_value): Avoid pointer UB.
2021-05-15 14:36:54 +09:30
Nick Clifton
0522d0165a revert previous delta 2021-05-13 14:33:39 +01:00
Nick Clifton
c4375dd764 Fix an infinite loop in the DWARF decoder when parsing a corrupt string table.
PR 27861
	* dwarf.c (display_debug_str_offsets): Warn if the length field is
	larger than the amount of data remaining in the section.
2021-05-13 14:31:09 +01:00
Alan Modra
b96a1bcb81 PR27861, Infinite loop in dwarf.c:7507-7526
PR 27861
	* dwarf.c (display_debug_str_offsets): Sanity check dwarf5
	header length.
2021-05-13 22:49:17 +09:30
Alan Modra
d21f875d67 PR27860, Segmentation fault on readelf -w
Well it didn't take long for the SAFE_BYTE_GET assert to trigger.

	PR 27860
	* dwarf.c (display_debug_frames): Sanity check cie_off before
	attempting to read cie.
2021-05-13 22:49:17 +09:30
Alan Modra
a7077ce760 Ensure data pointer kept within bounds
* dwarf.c (process_extended_line_op): Don't bump data pointer past
	end when strnlen doesn't find string terminator.
	(decode_location_expression): Remove dead code.
	(skip_attr_bytes): Remove const from end param.  Ensure data
	pointer doesn't pass end.
	(get_type_signedness): Remove const from end param.
	(read_and_display_attr_value): Ensure data pointer doesn't pass end.
	(display_debug_lines_raw, display_debug_lines_decoded): Likewise.
	(display_debug_pubnames_worker): Likewise.
	(display_debug_pubnames_worker): Use SAFE_BYTE_GET_AND INC rather
	than blindly incrementing data pointer.
	(display_debug_addr, display_debug_str_offsets): Likewise.  Don't
	compare pointers, compare lengths.
2021-05-12 21:29:25 +09:30
Alan Modra
6d1ad6f783 SAFE_BYTE_GET
This rearranges SAFE_BYTE_GET* macros, eliminating some duplication,
and making sure that the _INC variants never increment their PTR arg
past END.  I've added an assertion that should show us places where we
use them improperly with user derived PTR args, which I'm sure the
fuzzers will find for us.

	* dwarf.c (SAFE_BYTE_GET_INTERNAL): Define.
	(SAFE_BYTE_GET, SAFE_BYTE_GET_AND_INC): Define using the above.
	(SAFE_SIGNED_BYTE_GET, SAFE_SIGNED_BYTE_GET_AND_INC): Likewise.
	(display_discr_list): Use SAFE_BYTE_GET_AND_INC rather than
	SAFE_BYTE_GET followed by increment.
	(process_debug_info): Likewise, and test bytes remaining before
	incrementing section_begin rather than using pointer comparison.
	(display_debug_names): Pass lvalue as SAFE_BYTE_GET PTR.
	(process_cu_tu_index): Likewise for SAFE_BYTE_GET_AND_INC.
2021-05-12 21:17:35 +09:30
Alan Modra
af2ddf69ab SAFE_BYTE_GET64
Functions dealing with lack of a 64-bit integer type can disappear now
that we require C99.  Printing using dwarf_vmatoa is better too.

binutils/
	* dwarf.c (dwarf_vmatoa64, SAFE_BYTE_GET64, add64): Delete.
	(skip_attr_bytes): Replace use of SAFE_BYTE_GET64 with
	SAFE_BYTE_GET_AND_INC.
	(read_and_display_attr_value): Likewise.  Print using dwarf_vmatoa.
	(process_debug_info, process_cu_tu_index): Likewise.
	* elfcomm.c (byte_put, byte_put_little_endian, byte_put_big_endian),
	(byte_get, byte_get_little_endian, byte_get_big_endian),
	(byte_get_signed): Make size param unsigned.  Remove code dealing
	with 4-byte elf_vma.
	(byte_get_64): Delete.
	* elfcomm.h  (byte_put, byte_put_little_endian, byte_put_big_endian),
	(byte_get, byte_get_little_endian, byte_get_big_endian),
	(byte_get_signed): Update prototypes.
	(byte_get_64): Delete.
gas/
	* testsuite/gas/elf/dwarf-5-file0.d: Update.
	* testsuite/gas/i386/dwarf5-line-1.d: Update.
2021-05-12 21:10:33 +09:30
Alan Modra
0d872fca02 PR27836, readelf -w pointer comparison UB
PR 27836
	* dwarf.c (display_debug_frames): Don't compare pointers derived
	from user input.  Test offset against bounds instead.
2021-05-12 21:10:33 +09:30
Alan Modra
55b26492bb PR27853, Infinite loop in dwarf.c
Not quite infinite but much longer than it need be.  The problem is
triggered by read_and_display_attr_value incrementing "data" past
"end".  read_and_display_attr_value shouldn't do that, but be
defensive.

	PR 27853
	* dwarf.c (display_formatted_table): Test for data >= end rather
	than data == end.
	(process_extended_line_op): Likewise.
	(display_debug_lines_raw): Likewise.
	(display_debug_lines_decoded): Likewise.
2021-05-12 15:41:10 +09:30
Alan Modra
5ab3907543 PR27849, heap-buffer-overflow on readelf -w
PR 27849
	* dwarf.c (fetch_indexed_string): Correct length sanity checks.
	Sanity check section size for version and padding too.  Correct
	index sanity check.  Handle multiple tables in .debug_str_offsets.
2021-05-12 15:41:10 +09:30
Hans-Peter Nilsson
d30182b51e dwarf.c (process_abbrev_set): Properly parenthesize, fix fallout
Building as ILP32 shows:

 gcc -m32 -DHAVE_CONFIG_H -I. -I/checkout/binutils  -I. -I/checkout/binutils -I../bfd -I/checkout/binutils/../bfd -I/checkout/binutils/../include -DLOCALEDIR="\"/usr/local/share/locale\"" -Dbin_dummy_emulation=bin_vanilla_emulation  -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wstack-usage=262144 -Werror -I/checkout/binutils/../zlib -g -O2   -MT dwarf.o -MD -MP -MF $depbase.Tpo -c -o dwarf.o /checkout/binutils/dwarf.c &&\
 mv -f $depbase.Tpo $depbase.Po
 In file included from /checkout/binutils/sysdep.h:101:0,
                  from /checkout/binutils/dwarf.c:21:
 /checkout/binutils/dwarf.c: In function 'process_abbrev_set':
 /checkout/binutils/dwarf.c:1072:15: error: format '%lx' expects argument of type 'long unsigned int', but argument 2 has type 'dwarf_vma {aka long long unsigned int}' [-Werror=format=]
        warn (_("Debug info is corrupted, abbrev size (%lx) is larger than "
                ^
 /checkout/binutils/dwarf.c:1072:13: note: in expansion of macro '_'
        warn (_("Debug info is corrupted, abbrev size (%lx) is larger than "
              ^
 cc1: all warnings being treated as errors
 Makefile:1101: recipe for target 'dwarf.o' failed

The recent commit, casting one of the terms, has an obvious
typo.  To wit, the (non-cast) term abbrev_size is a
dwarf_vma and causes the whole expression to (still) be 64
bits.

binutils:
	* dwarf.c (process_abbrev_set): Properly parenthesize before
	casting to unsigned long.
2021-05-11 16:26:30 +02:00
Alan Modra
f2f9554bf0 PR27845, readelf heap-buffer-overflow
PR 27845
	* dwarf.c (process_abbrev_set): Replace start and end parameters
	with section, abbrev_base, abbrev_size, abbrev_offset.  Update
	all callers.  Sanity check parameters correctly and emit warnings
	here rather than..
	(process_debug_info): ..here.
2021-05-11 19:07:02 +09:30
Alan Modra
2d4b49864e Avoid possible pointer wrap
PTR supplied to these macros can be read from user input, END is an
end of buffer pointer.  It's safer to do arithmetic on END than on PTR.

	* dwarf.c (SAFE_BYTE_GET): Check bounds by subtracting amount from
	END rather than adding amount to PTR.
	(SAFE_SIGNED_BYTE_GET, SAFE_BYTE_GET64): Likewise.
2021-05-10 10:03:00 +09:30
Michael Forney
4896932e62 dwarf: Don't omit second operand of '?' operator
This is a GNU C extension and is not valid in ISO C.

	* dwarf.c: Don't omit second operand of '?' operator.
2021-05-07 16:54:00 +09:30
Nick Clifton
bfbfa6e7f4 Fix attempt to free non-allocated pointer when parsing .debug_sup sections.
PR 27796
	* dwarf.c (load_debug_sup_file): Allocate memory for filename in
	.debug_sup section.
2021-04-30 12:28:39 +01:00
Nick Clifton
3d64c987c7 Reject debuglink sections with no associated filename.
PR 27779
	* dwarf.c (parse_gnu_debuglink): Reject empty names.
	(parse_gnu_debugaltlink): Likewise.
2021-04-27 15:19:41 +01:00
Alan Modra
87b9f2556d C99 binutils configury
* configure.ac: Assume long long is available.  Don't test for
	strings.h, stdlib.h, limits.h, locale.h, or wchar.h.  Check
	inttypes.h, stdint.h, sys/stat.h and sys/types.h. Don't check for
	strcoll, setlocale, setmode or location of time_t.  Don't check
	for fprintf, getenv, snprintf, strnlen, strstr or vsnprintf decls.
	(AC_ISC_POSIX, AXC_HEADER_STRING, AC_FUNC_ALLOCA): Don't invoke.
	* sysdep.h: Don't include alloca-conf.h, include config.h instead.
	Test HAVE_SYS_TYPES_H and reorder includes.  Include limits.h,
	locale.h, string.h and stdlib.h unconditionally.  Remove various
	fallback declarations.  Assume long long is available.
	* addr2line.c: Don't test HAVE_SETLOCALE.
	* ar.c: Likewise.
	* coffdump.c: Likewise.
	* dlltool.c: Likewise.
	* dllwrap.c: Likewise.
	* elfedit.c: Likewise.
	* nm.c: Likewise.
	* objcopy.c: Likewise.
	* objdump.c: Likewise.
	* readelf.c: Likewise.
	* size.c: Likewise.
	* srconv.c: Likewise.
	* strings.c: Likewise.
	* sysdump.c: Likewise.
	* windmc.c: Likewise.
	* windres.c: Likewise.
	* bucomm.c: Don't test HAVE_TIME_T_IN_TIME_H or HAVE_TIME_T_IN_TYPES_H.
	* dwarf.c: Include limits.h unconditionally.  Assume long long
	is available.
	* nm.c: Don't test HAVE_STRCOLL.
	* readelf.c: Don't test HAVE_WCHAR_H.
	* strings.c: Assume long long is available.
	* syslex.l: Include string.h unconditionally.
	* aclocal.m4: Regenerate.
	* config.in: Regenerate.
	* configure: Regenerate.
	* Makefile.in: Regenerate.
	* doc/Makefile.in: Regenerate.
2021-04-05 15:30:22 +09:30
Martin Liska
24d127aa9f Replace const_strneq with startswith.
binutils/ChangeLog:

	* dwarf.c (display_debug_lines_raw): Replace const_strneq with
	startswith.
	(display_debug_lines_decoded): Likewise.
	(display_debug_links): Likewise.
	* elfcomm.c (setup_archive): Likewise.
	* elfcomm.h (const_strneq): Likewise.
	* readelf.c (process_section_headers): Likewise.
	(slurp_ia64_unwind_table): Likewise.
	(slurp_hppa_unwind_table): Likewise.
	(decode_arm_unwind): Likewise.
	(display_debug_section): Likewise.
	(process_note): Likewise.
2021-04-01 14:58:36 +02:00
Alan Modra
015dc7e1f8 Use bool in binutils
* sysdep.h (POISON_BFD_BOOLEAN): Define.
	* addr2line.c, * ar.c, * arsup.c, * bfdtest2.c, * binemul.c,
	* binemul.h, * bucomm.c, * bucomm.h, * budbg.h, * coffgrok.c,
	* debug.c, * debug.h, * dlltool.c, * dwarf.c, * dwarf.h,
	* elfedit.c, * emul_aix.c, * mclex.c, * nm.c, * objcopy.c,
	* objdump.c, * od-macho.c, * prdbg.c, * rdcoff.c, * rddbg.c,
	* readelf.c, * rename.c, * stabs.c, * strings.c, * windint.h,
	* windmc.c, * windmc.h, * windres.c, * winduni.c,
	* wrstabs.c: Replace bfd_boolean with bool, FALSE with false,
	and TRUE with true throughout.
2021-03-31 10:49:23 +10:30
Alan Modra
3dfb1b6d34 Remove bfd_stdint.h
If we require C99 for binutils then stdint.h is available.

bfd/
	* .gitignore: Delete bfd_stdint.h entry.
	* Makefile.am (bfdinclude_HEADERS): Delete bfd_stdint.h.
	(BUILD_HFILES, LOCAL_H_DEPS): Likewise.
	* bfd-in.h: Include stdint.h in place of bfd_stdint.h.
	* configure.ac: Don't invoke GCC_HEADER_STDINT.
	* configure.com: Don't create bfd_stdint.h.
	* Makefile.in: Regenerate.
	* aclocal.m4: Regenerate.
	* bfd-in2.h: Regenerate.
	* config.in: Regenerate.
	* configure: Regenerate.
	* doc/Makefile.in: Regenerate.
	* po/BLD-POTFILES.in: Regenerate.
binutils/
	* coffdump.c: Include stdint.h in place of bfd_stdint.h.
	* dwarf.c: Likewise.
gas/
	* config/tc-aarch64.c: Include stdint.h in place of bfd_stdint.h.
	* config/tc-crx.c: Likewise.
	* config/tc-nds32.h: Likewise.
include/
	* cgen/basic-modes.h: Include stdint.h in place of bfd_stdint.h.
	* elf/nfp.h: Likewise.
	* opcode/aarch64.h: Likewise.
	* opcode/cgen.h: Likewise.
	* opcode/nfp.h: Likewise.
	* opcode/ppc.h: Likewise.
ld/
	* elf-hints-local.h: Include stdint.h in place of bfd_stdint.h.
	* emultempl/nds32elf.em: Likewise.
	* testsuite/ld-elf/mbind2b.c: Likewise.
	* testsuite/ld-elf/pr18718.c: Likewise.
	* testsuite/ld-elf/pr18720a.c: Likewise.
	* testsuite/ld-elf/pr25749-1.c: Likewise.
	* testsuite/ld-elf/pr25749-1a.c: Likewise.
	* testsuite/ld-elf/pr25749-1b.c: Likewise.
	* testsuite/ld-elf/pr25749-1c.c: Likewise.
	* testsuite/ld-elf/pr25749-1d.c: Likewise.
	* testsuite/ld-elf/pr25749-2.c: Likewise.
	* testsuite/ld-elf/pr25754-1a.c: Likewise.
	* testsuite/ld-elf/pr25754-2a.c: Likewise.
	* testsuite/ld-elf/pr25754-3a.c: Likewise.
	* testsuite/ld-elf/pr25754-4a.c: Likewise.
	* testsuite/ld-elf/pr25754-5a.c: Likewise.
	* testsuite/ld-elf/pr25754-6a.c: Likewise.
opcodes/
	* aarch64-dis.c: Include stdint.h in place of bfd_stdint.h.
	* aarch64-dis.h: Likewise.
	* aarch64-opc.c: Likewise.
	* avr-dis.c: Likewise.
	* csky-dis.c: Likewise.
	* nds32-asm.c: Likewise.
	* nds32-dis.c: Likewise.
	* nfp-dis.c: Likewise.
	* riscv-dis.c: Likewise.
	* s12z-dis.c: Likewise.
	* wasm32-dis.c: Likewise.
2021-03-31 10:49:23 +10:30
Alan Modra
63b4cc53dc TRUE/FALSE simplification
There is really no need to write code like "foo != 0 ? TRUE : FALSE"
unless we had stupidly defined FALSE as something other than 0 or TRUE
as something other than 1.  The simpler "foo != 0" does just as well.
Similarly "(condition == TRUE)" or "(condition == FALSE) can be
simplified to "(condition)" and "(!condition)" respectively.

I'll note that there is reason to use "integer_expression != 0" when
assigning a bfd_boolean rather than the simpler "integer_expression",
if you expect the variable to have 0 or 1 value.  It's probably even a
good idea to not rely on implicit conversion if bfd_boolean were _Bool.

bfd/
	* aoutx.h (aout_link_write_symbols): Don't cast boolean expression
	to bfd_boolean.
	* elf32-or1k.c (or1k_set_got_and_rela_sizes): Dont compare booleans
	against FALSE.
	* elf32-arc.c (name_for_global_symbol): Don't compare boolean to TRUE.
	(is_reloc_PC_relative): Don't use "boolean_condition ? TRUE : FALSE".
	(is_reloc_SDA_relative, is_reloc_for_GOT): Likewise.
	(is_reloc_for_PLT, is_reloc_for_TLS): Likewise.
	* elf32-arm.c (stm32l4xx_need_create_replacing_stub): Likewise.
	* elf32-nds32.c (insert_nds32_elf_blank): Likewise.
	* elf32-rx.c (rx_set_section_contents): Likewise.
	* elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Likewise.
	* elfxx-mips.c (_bfd_mips_elf_ignore_undef_symbol): Likewise.
	* mach-o.c (bfd_mach_o_read_command): Likewise.
	* targets.c (bfd_get_target_info): Likewise.
binutils/
	* dlltool.c (main): Don't use "boolean_condition ? TRUE : FALSE".
	* dwarf.c (read_and_display_attr_value): Likewise.
	(display_debug_str_offsets): Likewise.
	* objdump.c (dump_bfd): Likewise.
	* readelf.c (dump_section_as_strings): Likewise.
	(dump_section_as_bytes): Likewise.
gas/
	* atof-generic.c (FALSE, TRUE): Don't define.
	* config/obj-elf.h (FALSE, TRUE): Don't define.
	* config/obj-som.h (FALSE, TRUE): Don't define.
	* config/tc-hppa.h (FALSE, TRUE): Don't define.
	* config/tc-pdp11.c (FALSE, TRUE): Don't define.
	* config/tc-iq2000.h (obj_fix_adjustable): Delete.
	* config/tc-m32r.h (TC_FIX_ADJUSTABLE): Delete.
	* config/tc-mt.h (obj_fix_adjustable): Delete.
	* config/tc-nds32.h (TC_FIX_ADJUSTABLE): Delete.
	* config/tc-arc.c (parse_opcode_flags): Simplify boolean expression.
	(relaxable_flag, relaxable_operand, assemble_insn): Likewise.
	(tokenize_extregister): Likewise.
	* config/tc-csky.c (parse_opcode, get_operand_value): Likewise.
	(parse_operands_op, parse_operands, md_assemble): Likewise.
	* config/tc-d10v.c (build_insn): Likewise.
	* config/tc-score.c (s3_gen_insn_frag): Likewise.
	* config/tc-score7.c (s7_gen_insn_frag, s7_relax_frag): Likewise.
	* config/tc-tic6x.c (tic6x_update_features, md_assemble): Likewise.
	* config/tc-z80.c (emit_byte): Likewise.
include/
	* opcode/aarch64.h (alias_opcode_p): Simplify boolean expression.
	(opcode_has_alias, pseudo_opcode_p, optional_operand_p): Likewise.
	(opcode_has_special_coder): Likewise.
ld/
	* emultempl/aix.em (gld${EMULATION_NAME}_before_allocation): Simplify
	boolean expression.
	* lexsup.c (parse_args): Likewise.
	* pe-dll.c (pe_dll_id_target): Likewise.
opcodes/
	* aarch64-opc.c (vector_qualifier_p): Simplify boolean expression.
	(fp_qualifier_p, get_data_pattern): Likewise.
	(aarch64_get_operand_modifier_from_value): Likewise.
	(aarch64_extend_operator_p, aarch64_shift_operator_p): Likewise.
	(operand_variant_qualifier_p): Likewise.
	(qualifier_value_in_range_constraint_p): Likewise.
	(aarch64_get_qualifier_esize): Likewise.
	(aarch64_get_qualifier_nelem): Likewise.
	(aarch64_get_qualifier_standard_value): Likewise.
	(get_lower_bound, get_upper_bound): Likewise.
	(aarch64_find_best_match, match_operands_qualifier): Likewise.
	(aarch64_print_operand): Likewise.
	* aarch64-opc.h (operand_has_inserter, operand_has_extractor): Likewise.
	(operand_need_sign_extension, operand_need_shift_by_two): Likewise.
	(operand_need_shift_by_four, operand_maybe_stack_pointer): Likewise.
	* arm-dis.c (print_insn_mve, print_insn_thumb32): Likewise.
	* tic6x-dis.c (tic6x_check_fetch_packet_header): Likewise.
	(print_insn_tic6x): Likewise.
2021-03-29 11:22:22 +10:30
Nick Clifton
d296b73620 Fix the dislay of .debug_macro.dwo sections.
PR 27387
	* dwarf.c (display_debug_macro): Handle the displaying of
	DW_MACRO_define_strp and DW_MACRO_undef_strp in v4
	.debug_macro.dwo sections.
2021-03-05 12:56:24 +00:00