Commit Graph

4203 Commits

Author SHA1 Message Date
Luis Machado
d0ff5ca959 [AArch64] Support AArch64 MTE memory tag dumps in core files
The Linux kernel can dump memory tag segments to a core file, one segment
per mapped range. The format and documentation can be found in the Linux
kernel tree [1].

The following patch adjusts bfd and binutils so they can handle this new
segment type and display it accordingly. It also adds code required so GDB
can properly read/dump core file data containing memory tags.

Upon reading, each segment that contains memory tags gets mapped to a
section named "memtag". These sections will be used by GDB to lookup the tag
data. There can be multiple such sections with the same name, and they are not
numbered to simplify GDB's handling and lookup.

There is another patch for GDB that enables both reading
and dumping of memory tag segments.

Tested on aarch64-linux Ubuntu 20.04.

[1] Documentation/arm64/memory-tagging-extension.rst (Core Dump Support)
2022-07-19 15:24:27 +01:00
Alan Modra
b95830931f Regenerate with automake-1.15.1
Until we update the recommended versions of autoconf/automake, files
should be regenerated with automake-1.15.1 and autoconf-2.69.  That's
not because we think those versions are golden, and newer versions are
bad.  It's simply because maintainers want to be able to update
configury files without trouble, and if someone regenerates files with
automake-1.16.5 then --enable-maintainer-mode builds will hit errors:

checking that generated files are newer than configure... configure.ac:26: error: version mismatch.  This is Automake 1.15.1,
configure.ac:26: but the definition used by this AM_INIT_AUTOMAKE
configure.ac:26: comes from Automake 1.16.5.  You should recreate
configure.ac:26: aclocal.m4 with aclocal and run automake again.
WARNING: 'automake-1.15' is probably too old.

Correcting this requires regenerating the files by hand.
2022-07-09 20:10:47 +09:30
Nick Clifton
e1ec7b9f9f Update release README with new version numbers 2022-07-08 11:55:59 +01:00
Nick Clifton
631ec08cb1 Update version to 2.39.50 and regenerate files 2022-07-08 11:19:44 +01:00
Nick Clifton
0bd0932314 Add markers for 2.39 branch 2022-07-08 10:41:07 +01:00
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
Alan Modra
0772daccb3 objcopy: bfd_alloc orelocation
This fixes an inconsequential objcopy memory leak.  I'd normally
ignore reports of leaks like this one, that are merely one block or
fewer per section processed, since objcopy soon exits and frees all
memory.  However I thought it worth providing support for allocating
memory on a bfd objalloc in objcopy and other utils.

	PR 29233
	* bucomm.c (bfd_xalloc): New function.
	* bucomm.h (bfd_xalloc): Declare.
	* objcopy.c (copy_relocations_in_section): Use it to allocate
	array of reloc pointers.  Rewrite code stripping relocs to do
	without extra memory allocation.
2022-07-04 22:51:56 +09: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
Clément Chigot
fadaf8f7f9 windres: add quotes around preprocessor cmd if needed
This patch ensures that the gcc binary called by windres is quoted if
needed. Otherwise, errors can occur if the gcc is under a folder having
a name containing a space (eg "Program Files").

binutils/
	* resrc.c (DEFAULT_PREPROCESSOR): Split into...
	(DEFAULT_PREPROCESSOR_CMD): that...
	(DEFAULT_PREPROCESSOR_ARGS): and that.
	(look_for_default): Add quotes around the command if needed.
	(read_rc_file): Adapt to new defines.
2022-06-28 16:53:23 +02: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
Jan Beulich
ddd7bf3e28 drop XC16x bits
Commit 04f096fb9e ("Move the xc16x target to the obsolete list") moved
the architecture from the "obsolete but still available" to the
"obsolete / support removed" list in config.bfd, making the architecture
impossible to enable (except maybe via "enable everything" options").

Note that I didn't touch */po/*.po{,t} on the assumption that these
would be updated by some (half)automatic means.
2022-06-27 11:11:46 +02: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
Marcus Nilsson
4491a7c1aa readelf: replace xmalloc with malloc in slurp_relr_relocs
Using xmalloc makes the null check redundant since failing allocation
will exit the program. Instead use malloc and let the error be
conveyed up the call chain.
2022-06-22 10:36:03 +02: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
0d02e70b19 PR29262, memory leak in pr_function_type
PR 29262
	* prdbg.c (pr_function_type): Free "s" on failure path.
2022-06-20 10:40:50 +09:30
Alan Modra
8a24927bc8 PR29261, memory leak in parse_stab_struct_fields
PR 29261
	* stabs.c (parse_stab_struct_fields): Free "fields" on failure path.
2022-06-20 10:39:52 +09:30
Alan Modra
d6e1d48c83 PR29255, memory leak in make_tempdir
PR 29255
	* bucomm.c (make_tempdir, make_tempname): Free template on all
	failure paths.
2022-06-17 21:09:06 +09:30
Alan Modra
0ebc886149 PR29254, memory leak in stab_demangle_v3_arg
PR 29254
	* stabs.c (stab_demangle_v3_arg): Free dt on failure path.
2022-06-17 21:08:41 +09:30
Alan Modra
370426d0da Always free matching vector from bfd_check_format_matches
At least one place calling list_matching_formats failed to free the
"matching" vector from bfd_check_format_matches afterwards.  Fix that
by calling free inside list_matching_formats.

binutils/
	* bucomm.c (list_matching_formats): Free arg.
	* addr2line.c (process_file): Adjust to suit.
	* ar.c (open_inarch, ranlib_touch): Likewise.
	* coffdump.c (main): Likewise.
	* nm.c (display_archive, display_file): Likewise.
	* objcopy.c (copy_file): Likewise.
	* objdump.c (display_object_bfd): Likewise.
	* size.c (display_bfd): Likewise.
	* srconv.c (main): Likewise.
ld/
	* ldlang.c (load_symbols): Free "matching".
2022-06-16 15:01:14 +09:30
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
Alan Modra
99f647e200 Trailing spaces in objdump -r header
git commit 202be274a4 went a little wild in removing trailing spaces
in gas/testsuite/gas/i386/{secidx.d,secrel.d}, causing
x86_64-w64-mingw32  +FAIL: i386 secrel reloc
x86_64-w64-mingw32  +FAIL: i386 secidx reloc

I could have just replaced the trailing space, but let's fix the
objdump output instead.  Touches lots of testsuite files.
2022-05-31 11:25:09 +09:30
Alan Modra
0e3c1eebb2 Remove use of bfd_uint64_t and similar
Requiring C99 means that uses of bfd_uint64_t can be replaced with
uint64_t, and similarly for bfd_int64_t, BFD_HOST_U_64_BIT, and
BFD_HOST_64_BIT.  This patch does that, removes #ifdef BFD_HOST_*
and tidies a few places that print 64-bit values.
2022-05-27 22:08:59 +09:30
Natarajan, Kavitha
f85c0e1e20 Re: Add bionutils support for DWARF v5's DW_OP_addrx
Testsuite files belonging to commit 3ac9da4937.
2022-05-26 09:12:09 +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
Nick Clifton
95086e1e54 Fix potentially uninitialised variables in the Windows tools 2022-05-19 15:05:12 +01:00
Jan Beulich
6db1e45d7b COFF/PE: don't leave zero timestamp after objcopy / strip
Fill the timestamp field suitably for _bfd_XXi_only_swap_filehdr_out().
Instead of re-arranging the present if(), fold this logic with that of
copying the optional header.
2022-05-19 12:44:32 +02:00
Nick Clifton
2c3cc81e06 Add a --no-weak option to nm.
PR 29135
	* nm.c (non_weak): New variable.
	(filter_symbols): When non-weak is true, ignore weak symbols.
	(long_options): Add --no-weak.
	(usage): Mention --no-weak.
	(main): Handle -W/--no-weak.
	* doc/binutils.texi: Document new feature.
	* NEWS: Mention the new feature.
	* testsuite/binutils-all/nm.exp: Add test of new feature.
	* testsuite/binutils-all/no-weak.s: New test source file.
2022-05-18 13:15:22 +01:00
Alan Modra
fa44522195 PR29142, segv in ar with empty archive and libdeps specified
PR 29142
	* ar.c (main): Properly handle libdeps for zero file_count.
2022-05-12 11:49:45 +09:30
Nick Clifton
aa02037b08 nm: use -U as an alias for --defines-only, in line with llvm-nm 2022-05-11 13:54:30 +01:00
Nick Clifton
b773a1808d Fix compiling binutils/resbin.c with Clang version 14 2022-05-10 12:41:56 +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
ba951afb99 Add a linker warning when creating potentially dangerous executable segments. Add tests, options to disabke and configure switches to choose defaults. 2022-05-03 11:42:24 +01:00
Andrew Burgess
4bb461e42c objdump: fix styled printing of addresses
Previous work to add styled disassembler output missed a case in
objdump_print_addr, which is fixed in this commit.
2022-05-03 10:51:21 +01:00
Nick Clifton
0d38576a34 Emit a note warning the user that creating an executable stack because of a missing .note.GNU-stack section is deprecated.
PR 29072
bfd	* elflink.c (bfd_elf_size_dynamic_sections): Display a note to the
	user that the current ehaviour of creating an executable stack
	because of a missing .note.GNU-stack section is deprecated and
	will be changed in a future release.

binutils* testsuite/lib/binutils-common.exp (prune_warnings_extra): Filter
	out notes about the executable stacjk behaviour beign deprecated.

ld	* testsuite/ld-elf/pr29072.b.warn: Update to include the note
	about the linker's behaviour being depreccated.
2022-04-25 12:53:08 +01:00
Alan Modra
333cd559ba prune .note.GNU-stack warning from testsuite
binutils/
	* testsuite/lib/binutils-common.exp (prune_warnings_extra): Remove
	.note.GNU-stack warning.
	(run_dump_test): Call prune_warnings for ld and objcopy output.
ld/
	* testsuite/ld-elf/elf.exp: Disable prune_warnings_extra temporarily
	around test for absent .note.GNU-stack
	* testsuite/ld-cris/globsymw2.s,
	* testsuite/ld-cris/warn3.d: Modify "is not implemented" message
	to avoid dejagnu prune_warnings.
2022-04-21 15:31:39 +09:30
Nick Clifton
278c98c830 Stop strip from removing debuglink sections.
PR 28992
	* objcopy.c (is_strip_section_1): Do not delete debuglink sections
	when stripping debug information.
2022-04-12 13:34:06 +01:00