Commit Graph

3614 Commits

Author SHA1 Message Date
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
Nick Alcock
10909ea819 binutils, ld: make objdump --ctf's parameter optional
ld by default (and always, unless adjusted with a hand-rolled linker
script) emits deduplicated CTF into the .ctf section.  But viewing
it needs you to explicitly tell objdump this: it doesn't default
its argument, even though what you always end up typing is
--ctf=.ctf.

This is annoying, so make the argument optional.

binutils/ChangeLog
2021-10-25  Nick Alcock  <nick.alcock@oracle.com>

	* objdump.c (usage): --ctf now has an optional argument.
	(main): Adjust accordingly.
	(dump_ctf): Default it.
	* doc/ctf.options.texi: Adjust.

ld/ChangeLog
2021-10-25  Nick Alcock  <nick.alcock@oracle.com>

	* testsuite/ld-ctf/array.d: Change --ctf=.ctf to --ctf.
	* testsuite/ld-ctf/conflicting-cycle-1.B-1.d: Likewise.
	* testsuite/ld-ctf/conflicting-cycle-1.B-2.d: Likewise.
	* testsuite/ld-ctf/conflicting-cycle-1.parent.d: Likewise.
	* testsuite/ld-ctf/conflicting-cycle-2.A-1.d: Likewise.
	* testsuite/ld-ctf/conflicting-cycle-2.A-2.d: Likewise.
	* testsuite/ld-ctf/conflicting-cycle-2.parent.d: Likewise.
	* testsuite/ld-ctf/conflicting-cycle-3.C-1.d: Likewise.
	* testsuite/ld-ctf/conflicting-cycle-3.C-2.d: Likewise.
	* testsuite/ld-ctf/conflicting-cycle-3.parent.d: Likewise.
	* testsuite/ld-ctf/conflicting-enums.d: Likewise.
	* testsuite/ld-ctf/conflicting-typedefs.d: Likewise.
	* testsuite/ld-ctf/cross-tu-cyclic-conflicting.d: Likewise.
	* testsuite/ld-ctf/cross-tu-cyclic-nonconflicting.d: Likewise.
	* testsuite/ld-ctf/cross-tu-into-cycle.d: Likewise.
	* testsuite/ld-ctf/cross-tu-noncyclic.d: Likewise.
	* testsuite/ld-ctf/cycle-1.d: Likewise.
	* testsuite/ld-ctf/cycle-2.A.d: Likewise.
	* testsuite/ld-ctf/cycle-2.B.d: Likewise.
	* testsuite/ld-ctf/cycle-2.C.d: Likewise.
	* testsuite/ld-ctf/data-func-conflicted.d: Likewise.
	* testsuite/ld-ctf/diag-cttname-null.d: Likewise.
	* testsuite/ld-ctf/diag-cuname.d: Likewise.
	* testsuite/ld-ctf/diag-parlabel.d: Likewise.
	* testsuite/ld-ctf/enum-forward.d: Likewise.
	* testsuite/ld-ctf/enums.d: Likewise.
	* testsuite/ld-ctf/forward.d: Likewise.
	* testsuite/ld-ctf/function.d: Likewise.
	* testsuite/ld-ctf/nonrepresentable.d: Likewise.
	* testsuite/ld-ctf/slice.d: Likewise.
	* testsuite/ld-ctf/super-sub-cycles.d: Likewise.
2021-10-25 11:17:03 +01:00
Nick Alcock
80b56fad5c binutils: make objdump/readelf --ctf-parent actually useful
This option has been present since the very early days of the
development of libctf as part of binutils, and it shows.  Back in the
earliest days, I thought we might handle ambiguous types by introducing
new ELF sections on the fly named things like .ctf.foo.c for ambiguous
types found only in foo.c, etc.  This turned out to be a terrible idea,
so we moved to using a CTF archive in the .ctf section which contained
all the CTF dictionaries -- but the --ctf-parent option in objdump and
readelf was never adjusted, and lingered as a mechanism to specify CTF
parent dictionaries in sections other than .ctf, even though the linker
has no way to produce parent dictionaries in different sections from
their children, libctf's ctf_open can't handle such split-up
parent/child dicts, and they are never found in the wild, emitted by GNU
ld or by any known third-party linking tool.

Meanwhile, the actually-useful ctf_link feature (albeit not used by ld)
which lets you remap the names of CTF archive members (so you can end up
with a parent archive member named something other than ".ctf", still
contained with all its children in a single .ctf section) had no support
in objdump or readelf: there was no way to tell them that these members
were parents, so all the types in the associated child dicts always
appeared corrupted, referencing nonexistent types from a parent objdump
couldn't find.

So adjust --ctf-parent so that rather than taking a section name it
takes a member name instead (if not specified, the name is ".ctf", which
is what GNU ld emits).  Because the option was always useless before
now, this is expected to have no backward-compatibility implications.

As part of this, we have to slightly adjust the code which skips the
archive member name if redundant: right now it skips it if it's ".ctf",
on the assumption that this name will almost always be at the start
of the objdump output and thus we'll end up with a shared dump
and then smaller, headed dumps for the per-TU child dicts; but if
the parent name has been changed, that won't be true any more.

So change the rules to "members named .ctf which appear first in the
first have their member name skipped".  Since we now need to count
members, move from ctf_archive_iter (for which passing in extra
parameters requires defining a new struct and is clumsy) to
ctf_archive_next, allowing us to just *call* dump_ctf_archive_member and
maintain a member count in the obvious way.  In the process we fix a
tiny difference between readelf and objdump: if a ctf_dump ever failed,
readelf skipped every later member, while objdump tried to keep going as
much as it could.  For a dumping tool the former is clearly preferable.

binutils/ChangeLog
2021-10-25  Nick Alcock  <nick.alcock@oracle.com>

	* objdump.c (usage): --ctf-parent now takes a name, not a section.
	(dump_ctf): Don't open a separate section; use the parent_name in
	ctf_dict_open instead.  Use ctf_archive_next, not ctf_archive_iter,
	so we can pass down a member count.
	(dump_ctf_archive_member): Add the member count; don't return
	anything.  Import parents into children no matter what the
	parent's name, while still avoiding displaying the header for the
	common parent name of ".ctf".
	* readelf.c (usage): Adjust similarly.
	(dump_section_as_ctf): Likewise.
	(dump_ctf_archive_member): Likewise.  Never stop iterating over
	archive members, even if ctf_dump of one member fails.
	* doc/ctf.options.texi: Adjust.
2021-10-25 11:17:03 +01:00
Nick Clifton
cf487499e0 Fix a potential illegal memory access when testing for a special LTO symbol name.
bfd	* linker.c (_bfd_generic_link_add_one_symbol): Test for a NULL
	name before checking to see if the symbol is __gnu_lto_slim.
	* archive.c (_bfd_compute_and_write_armap): Likewise.
binutils
	* nm.c (filter_symbols): Test for a NULL name before checking to
	see if the symbol is __gnu_lto_slim.
	* objcopy.c (filter_symbols): Likewise.
2021-10-19 16:02:49 +01:00
Nick Clifton
7325ba796b make objcopy fail if it is asked to redefine symbols in an object file containing LTO information.
* objcopy.c (filter_symbols): Fail if attempting to dredefine
	symbols in an LTO object file.
2021-09-30 12:56:19 +01:00
Nick Alcock
b9004024b9 configure: regenerate in all projects that use libtool.m4
(including sim/, which has no changelog.)

bfd/ChangeLog
2021-09-27  Nick Alcock  <nick.alcock@oracle.com>

	* configure: Regenerate.

binutils/ChangeLog
2021-09-27  Nick Alcock  <nick.alcock@oracle.com>

	* configure: Regenerate.

gas/ChangeLog
2021-09-27  Nick Alcock  <nick.alcock@oracle.com>

	* configure: Regenerate.

gprof/ChangeLog
2021-09-27  Nick Alcock  <nick.alcock@oracle.com>

	* configure: Regenerate.

ld/ChangeLog
2021-09-27  Nick Alcock  <nick.alcock@oracle.com>

	* configure: Regenerate.

libctf/ChangeLog
2021-09-27  Nick Alcock  <nick.alcock@oracle.com>

	* configure: Regenerate.
	* Makefile.in: Regenerate.

opcodes/ChangeLog
2021-09-27  Nick Alcock  <nick.alcock@oracle.com>

	* configure: Regenerate.

zlib/ChangeLog
2021-09-27  Nick Alcock  <nick.alcock@oracle.com>

	* configure: Regenerate.
2021-09-27 20:31:24 +01:00
Andrew Burgess
6a7f57668a riscv: print .2byte or .4byte before an unknown instruction encoding
When the RISC-V disassembler encounters an unknown instruction, it
currently just prints the value of the bytes, like this:

  Dump of assembler code for function custom_insn:
     0x00010132 <+0>:	addi	sp,sp,-16
     0x00010134 <+2>:	sw	s0,12(sp)
     0x00010136 <+4>:	addi	s0,sp,16
     0x00010138 <+6>:	0x52018b
     0x0001013c <+10>:	0x9c45

My proposal, in this patch, is to change the behaviour to this:

  Dump of assembler code for function custom_insn:
     0x00010132 <+0>:	addi	sp,sp,-16
     0x00010134 <+2>:	sw	s0,12(sp)
     0x00010136 <+4>:	addi	s0,sp,16
     0x00010138 <+6>:	.4byte	0x52018b
     0x0001013c <+10>:	.2byte	0x9c45

Adding the .4byte and .2byte opcodes.  The benefit that I see here is
that in the patched version of the tools, the disassembler output can
be fed back into the assembler and it should assemble to the same
binary format.  Before the patch, the disassembler output is invalid
assembly.

I've started a RISC-V specific test file under binutils so that I can
add a test for this change.

binutils/ChangeLog:

	* testsuite/binutils-all/riscv/riscv.exp: New file.
	* testsuite/binutils-all/riscv/unknown.d: New file.
	* testsuite/binutils-all/riscv/unknown.s: New file.

opcodes/ChangeLog:

	* riscv-dis.c (riscv_disassemble_insn): Print a .%dbyte opcode
	before an unknown instruction, '%d' is replaced with the
	instruction length.
2021-09-20 09:45:34 +01:00
Luis Machado
64dbf74d42 Revert: [AArch64] MTE corefile support
bfd     * elf.c (elfcore_make_memtag_note_section): New function.
                (elfcore_grok_note): Handle NT_MEMTAG note types.

        binutils* readelf.c (get_note_type): Handle NT_MEMTAG note types.

        include * elf/common.h (NT_MEMTAG): New constant.
                (NT_MEMTAG_TYPE_AARCH_MTE): New constant.
2021-09-07 11:03:20 -03:00
Nick Clifton
4f212c5520 Updated Portuguese translation for the binutils sub-directory. 2021-08-11 13:40:37 +01:00
Nick Clifton
3ee0cd9e55 Updated Serbian and Russian translations for various sub-directories 2021-08-10 16:40:37 +01:00
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
Nick Clifton
0200b0feb8 Updated French translation for the binutils sub-directory 2021-07-12 14:20:14 +01:00
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
Rainer Orth
b737d3047c Check for strnlen declaration to fix Solaris 10 build
binutils currently fails to compile on Solaris 10:

/vol/src/gnu/binutils/hg/binutils-2.37-branch/git/bfd/opncls.c: In function 'bfd_get_debug_link_info_1':
/vol/src/gnu/binutils/hg/binutils-2.37-branch/git/bfd/opncls.c:1231:16: error: implicit declaration of function 'strnlen' [-Werror=implicit-function-declaration]
 1231 |	  crc_offset = strnlen (name, size) + 1;
      |		       ^~~~~~~
/vol/src/gnu/binutils/hg/binutils-2.37-branch/git/bfd/opncls.c:1231:16: error: incompatible implicit declaration of built-in function 'strnlen' [-Werror]
/vol/src/gnu/binutils/hg/binutils-2.37-branch/git/bfd/opncls.c: In function 'bfd_get_alt_debug_link_info':
/vol/src/gnu/binutils/hg/binutils-2.37-branch/git/bfd/opncls.c:1319:20: error: incompatible implicit declaration of built-in function 'strnlen' [-Werror]
 1319 |	  buildid_offset = strnlen (name, size) + 1;
      |			   ^~~~~~~

and in a couple of other places.  The platform lacks strnlen, and while
libiberty.h can provide a fallback declaration, the necessary configure
test isn't run.

Fixed with the following patch.  Tested on i386-pc-solaris2.10.

2021-07-06  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	bfd:
	* configure.ac: Check for strnlen declaration.
	* configure, config.in: Regenerate.

	binutils:
	* configure.ac: Check for strnlen declaration.
	* configure, config.in: Regenerate.
2021-07-07 13:49:27 +02:00
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
Nick Clifton
346d80ef33 Update version number and regenerate files 2021-07-03 15:16:48 +01:00
Nick Clifton
514192487e Add markers for 2.37 branch 2021-07-03 14:50:57 +01:00
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
1b8d1f5f38 Partially fix debuginfod tests in binutils testsuite.
PR 28029
	* testsuite/binutils-all/debuginfod.exp: Replace -wK with -wk.
2021-07-01 14:10:38 +01:00
Andrei Homescu
75a2da57a1 readelf: Reset file position to beginning for thin archive members
* readelf.c (process_archive): Reset file position to the
	beginning when calling process_object for thin archive members.
	* testsuite/binutils-all/readelf.exp: Add test.
	* testsuite/binutils-all/readelf.h.thin: New file.
2021-07-01 12:01:55 +01:00
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
H.J. Lu
5a767724d7 elf: Add GNU_PROPERTY_UINT32_AND_XXX/GNU_PROPERTY_UINT32_OR_XXX
Implement GNU_PROPERTY_UINT32_AND_XXX/GNU_PROPERTY_UINT32_OR_XXX:

https://sourceware.org/pipermail/gnu-gabi/2021q1/000467.html

1. GNU_PROPERTY_UINT32_AND_LO..GNU_PROPERTY_UINT32_AND_HI

 #define GNU_PROPERTY_UINT32_AND_LO 0xb0000000
 #define GNU_PROPERTY_UINT32_AND_HI 0xb0007fff

A bit in the output pr_data field is set only if it is set in all
relocatable input pr_data fields.  If all bits in the the output
pr_data field are zero, this property should be removed from output.

If the bit is 1, all input relocatables have the feature.  If the
bit is 0 or the property is missing, the info is unknown.

2. GNU_PROPERTY_UINT32_OR_LO..GNU_PROPERTY_UINT32_OR_HI

 #define GNU_PROPERTY_UINT32_OR_LO 0xb0008000
 #define GNU_PROPERTY_UINT32_OR_HI 0xb000ffff

A bit in the output pr_data field is set if it is set in any
relocatable input pr_data fields. If all bits in the the output
pr_data field are zero, this property should be removed from output.

If the bit is 1, some input relocatables have the feature.  If the
bit is 0 or the property is missing, the info is unknown.

bfd/

	* elf-properties.c (_bfd_elf_parse_gnu_properties): Handle
	GNU_PROPERTY_UINT32_AND_LO, GNU_PROPERTY_UINT32_AND_HI,
	GNU_PROPERTY_UINT32_OR_LO and GNU_PROPERTY_UINT32_OR_HI.
	(elf_merge_gnu_properties): Likewise.

binutils/

	* readelf.c (print_gnu_property_note): Handle
	GNU_PROPERTY_UINT32_AND_LO, GNU_PROPERTY_UINT32_AND_HI,
	GNU_PROPERTY_UINT32_OR_LO and GNU_PROPERTY_UINT32_OR_HI.

include/

	* elf/common.h (GNU_PROPERTY_UINT32_AND_LO): New.
	(GNU_PROPERTY_UINT32_AND_HI): Likewise.
	(GNU_PROPERTY_UINT32_OR_LO): Likewise.
	(GNU_PROPERTY_UINT32_OR_HI): Likewise.

ld/

	* testsuite/ld-elf/property-and-1.d: New file.
	* testsuite/ld-elf/property-and-1.s: Likewise.
	* testsuite/ld-elf/property-and-2.d: Likewise.
	* testsuite/ld-elf/property-and-2.s: Likewise.
	* testsuite/ld-elf/property-and-3.d: Likewise.
	* testsuite/ld-elf/property-and-3.s: Likewise.
	* testsuite/ld-elf/property-and-4.d: Likewise.
	* testsuite/ld-elf/property-and-empty.s: Likewise.
	* testsuite/ld-elf/property-or-1.d: Likewise.
	* testsuite/ld-elf/property-or-1.s: Likewise.
	* testsuite/ld-elf/property-or-2.d: Likewise.
	* testsuite/ld-elf/property-or-2.s: Likewise.
	* testsuite/ld-elf/property-or-3.d: Likewise.
	* testsuite/ld-elf/property-or-3.s: Likewise.
	* testsuite/ld-elf/property-or-4.d: Likewise.
	* testsuite/ld-elf/property-or-empty.s: Likewise.
2021-06-18 07:19:01 -07:00
Nick Clifton
c8795e1f2f Allow readelf to recognise GO buildid notes.
binutils * readelf.c (get_note_type): Add support for NT_GO_BUILDID.

include	 * elf/common.h (NT_GO_BUILDID): Define.
2021-06-15 11:43:43 +01:00
Alan Modra
93df3340fd readelf: report DF_1_PIE as "Position-Independent Executable"
I finally found time to teach readelf to identify PIEs in the file
header display and program header display.  So in place of
"DYN (Shared object file)" which isn't completely true, show
"DYN (Position-Independent Executable file)".

It requires a little bit of untangling code in readelf due to
process_program_headers setting up dynamic_addr and dynamic_size,
needed to scan .dynamic for the DT_FLAGS_1 entry, and
process_program_headers itself wanting to display the file type in
some cases.  At first I modified process_program_header using a
"probe" parameter similar to get_section_headers in order to inhibit
output, but decided it was cleaner to separate out
locate_dynamic_sections.

binutils/
	* readelf.c (locate_dynamic_section, is_pie): New functions.
	(get_file_type): Replace e_type parameter with filedata.  Call
	is_pie for ET_DYN.  Update all callers.
	(process_program_headers): Use local variables dynamic_addr and
	dynamic_size, updating filedata on exit from function.  Set
	dynamic_size of 1 to indicate no dynamic section or segment.
	Update tests of dynamic_size throughout.
	* testsuite/binutils-all/x86-64/pr27708.dump: Update expected output.
ld/
	* testsuite/ld-pie/vaddr-0.d: Update expected output.
gdb/
	* testsuite/lib/gdb.exp (exec_is_pie): Match new PIE readelf output.
2021-06-15 13:24:57 +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
Alan Modra
8c60e272c7 readelf: don't clear section_headers in process_file_header
* readelf.c (process_file_header): Don't clear section_headers.
2021-06-12 12:01:26 +09:30
Alan Modra
e331b18d42 Re: readelf section reading
Fix commit 4de91c10cd, which cached the single section header read
to pick up file header extension fields.  Also, testing e_shoff in
get_section_headers opened a hole for fuzzers where we'd end up with
segfaults due to non-zero e_shnum but NULL section_headers.

	* readelf.c (get_section_headers): Don't test e_shoff here, leave
	that to get_32bit_section_headers or get_64bit_section_headers.
	(process_object): Throw away section header read to print file
	header extension.
2021-06-12 11:00:32 +09:30
Alan Modra
066f8fbede readelf info leaks from one object to the next
A number of filedata entries were not cleared.  Make sure they are
all cleared out, except the ones needed for archive handling.

	* readelf.c (struct filedata): Move archive_file_offset and
	archive_file_size earlier.
	(free_filedata): Clear using memset.
2021-06-11 14:23:18 +09:30
Alan Modra
4de91c10cd readelf section reading
This is a followup to git commit 8ff66993e0, a patch aimed at
segfaults found invoking readelf multiple times with fuzzed objects.
In that patch I added code to clear more stashed data early in
process_section_headers, along with any stashed section headers.  This
patch instead relies on clearing out the stash at the end of
process_object, making sure that process_object doesn't exit early.

The patch also introduces some new wrapper functions.

	* readelf.c (GET_ELF_SYMBOLS): Delete.  Replace with..
	(get_elf_symbols): ..this new function throughout.
	(get_32bit_section_headers): Don't free section_headers.
	(get_64bit_section_headers): Likewise.
	(get_section_headers): New function, use throughout in place of
	32bit and 64bit variants.
	(get_dynamic_section): Similarly.
	(process_section_headers): Don't free filedata memory here.
	(get_file_header): Don't get section headers here..
	(process_object): ..Read them here instead.  Don't exit without
	freeing filedata memory.
2021-06-11 14:12:07 +09:30
Nick Clifton
cc96519fdc Remove Daniel Jacobwitz from the maintainers list 2021-06-09 17:02:54 +01: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
Alan Modra
63e47e1072 Re: readelf and objdump help
Fix a last-minute change..

	* objdump (usage): Add missing \n.
2021-05-29 22:47:44 +09:30
Alan Modra
d6249f5f1c readelf and objdump help
Splitting up help strings makes it more likely that at least some of
the help translation survives adding new options.

	* readelf.c (parse_args): Call dwarf_select_sections_all on
	--debug-dump without optarg.
	(usage): Associate -w and --debug-dump options closely.
	Split up help message.  Remove extraneous blank lines around
	ctf help.
	* objdump.c (usage): Similarly.
2021-05-29 20:59:27 +09:30
Maciej W. Rozycki
9204ccd4b1 MIPS/opcodes: Do not use CP0 register names for control registers
The CP0 control register set has never been defined, however encodings
for the CFC0 and CTC0 instructions remained available for implementers
up until the MIPS32 ISA declared them invalid and causing the Reserved
Instruction exception[1].  Therefore we handle them for both assembly
and disassembly, however in the latter case the names of CP0 registers
from the regular set are incorrectly printed if named registers are
requested.  This is because we do not define separate operand classes
for coprocessor regular and control registers respectively, which means
the disassembler has no way to tell the two cases apart.  Consequently
nonsensical disassembly is produced like:

	cfc0	v0,c0_random

Later the MIPSr5 ISA reused the encodings for XPA ASE MFHC0 and MTHC0
instructions[2] although it failed to document them in the relevant
opcode table until MIPSr6 only.

Correct the issue then by defining a new register class, OP_REG_CONTROL,
and corresponding operand codes, `g' and `y' for the two positions in
the machine instruction a control register operand can take.  Adjust the
test cases affected accordingly.

While at it swap the regular MIPS opcode table "cfc0" and "ctc0" entries
with each other so that they come in the alphabetical order.

References:

[1] "MIPS32 Architecture For Programmers, Volume II: The MIPS32
    Instruction Set", MIPS Technologies, Inc., Document Number: MD00086,
    Revision 1.00, August 29, 2002, Table A-9 "MIPS32 COP0 Encoding of
    rs Field", p. 242

[2] "MIPS Architecture For Programmers, Volume II-A: The MIPS32
    Instruction Set", MIPS Technologies, Inc., Document Number: MD00086,
    Revision 5.04, December 11, 2013, Section 3.2 "Alphabetical List of
    Instructions", pp. 195, 216

	include/
	* opcode/mips.h: Document `g' and `y' operand codes.
	(mips_reg_operand_type): Add OP_REG_CONTROL enumeration
	constant.

	gas/
	* tc-mips.c (convert_reg_type) <OP_REG_CONTROL>: New case.
	(macro) <M_TRUNCWS, M_TRUNCWD>: Use the `g' rather than `G'
	operand code.

	opcodes/
	* mips-dis.c (print_reg) <OP_REG_COPRO>: Move control register
	handling code over to...
	<OP_REG_CONTROL>: ... this new case.
	* mips-opc.c (decode_mips_operand) <'g', 'y'>: New cases.
	(mips_builtin_opcodes): Update "cfc1", "ctc1", "cttc1", "cttc2",
	"cfc0", "ctc0", "cfc2", "ctc2", "cfc3", and "ctc3" entries
	replacing the `G' operand code with `g'.  Update "cftc1" and
	"cftc2" entries replacing the `E' operand code with `y'.
	* micromips-opc.c (decode_micromips_operand) <'g'>: New case.
	(micromips_opcodes): Update "cfc1", "cfc2", "ctc1", and "ctc2"
	entries replacing the `G' operand code with `g'.

	binutils/
	* testsuite/binutils-all/mips/mips-xpa-virt-1.d: Correct CFC0
	operand disassembly.
	* testsuite/binutils-all/mips/mips-xpa-virt-3.d: Likewise.
2021-05-29 03:26:32 +02:00
Maciej W. Rozycki
9623cc5d1f MIPS/binutils/testsuite: Fix XPA and Virtualization ASE cases
Fix commit 9785fc2a4d ("MIPS: Fix XPA base and Virtualization ASE
instruction handling") and explicitly use the `mips:3000' machine for
disassembly across the XPA base and XPA Virtualization ASE test cases,
providing actual coverage for the `virt' and `xpa' disassembler options
and removing failures for targets that default to those ASEs enabled:

mipsisa32r2-elf  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 1
mipsisa32r2-elf  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 2
mipsisa32r2-elf  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 3
mipsisa32r2-linux  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 1
mipsisa32r2-linux  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 2
mipsisa32r2-linux  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 3
mipsisa32r2el-elf  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 1
mipsisa32r2el-elf  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 2
mipsisa32r2el-elf  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 3
mipsisa32r2el-linux  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 1
mipsisa32r2el-linux  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 2
mipsisa32r2el-linux  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 3
mipsisa32r3-elf  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 1
mipsisa32r3-elf  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 2
mipsisa32r3-elf  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 3
mipsisa32r3-linux  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 1
mipsisa32r3-linux  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 2
mipsisa32r3-linux  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 3
mipsisa32r3el-elf  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 1
mipsisa32r3el-elf  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 2
mipsisa32r3el-elf  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 3
mipsisa32r3el-linux  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 1
mipsisa32r3el-linux  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 2
mipsisa32r3el-linux  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 3
mipsisa32r5-elf  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 1
mipsisa32r5-elf  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 2
mipsisa32r5-elf  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 3
mipsisa32r5-linux  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 1
mipsisa32r5-linux  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 2
mipsisa32r5-linux  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 3
mipsisa32r5el-elf  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 1
mipsisa32r5el-elf  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 2
mipsisa32r5el-elf  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 3
mipsisa32r5el-linux  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 1
mipsisa32r5el-linux  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 2
mipsisa32r5el-linux  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 3
mipsisa32r6-elf  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 1
mipsisa32r6-elf  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 2
mipsisa32r6-elf  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 3
mipsisa32r6-linux  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 1
mipsisa32r6-linux  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 2
mipsisa32r6-linux  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 3
mipsisa32r6el-elf  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 1
mipsisa32r6el-elf  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 2
mipsisa32r6el-elf  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 3
mipsisa32r6el-linux  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 1
mipsisa32r6el-linux  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 2
mipsisa32r6el-linux  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 3
mipsisa64r2-elf  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 1
mipsisa64r2-elf  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 2
mipsisa64r2-elf  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 3
mipsisa64r2-linux  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 1
mipsisa64r2-linux  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 2
mipsisa64r2-linux  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 3
mipsisa64r2el-elf  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 1
mipsisa64r2el-elf  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 2
mipsisa64r2el-elf  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 3
mipsisa64r2el-linux  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 1
mipsisa64r2el-linux  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 2
mipsisa64r2el-linux  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 3
mipsisa64r3-elf  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 1
mipsisa64r3-elf  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 2
mipsisa64r3-elf  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 3
mipsisa64r3-linux  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 1
mipsisa64r3-linux  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 2
mipsisa64r3-linux  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 3
mipsisa64r3el-elf  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 1
mipsisa64r3el-elf  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 2
mipsisa64r3el-elf  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 3
mipsisa64r3el-linux  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 1
mipsisa64r3el-linux  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 2
mipsisa64r3el-linux  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 3
mipsisa64r5-elf  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 1
mipsisa64r5-elf  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 2
mipsisa64r5-elf  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 3
mipsisa64r5-linux  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 1
mipsisa64r5-linux  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 2
mipsisa64r5-linux  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 3
mipsisa64r5el-elf  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 1
mipsisa64r5el-elf  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 2
mipsisa64r5el-elf  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 3
mipsisa64r5el-linux  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 1
mipsisa64r5el-linux  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 2
mipsisa64r5el-linux  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 3
mipsisa64r6-elf  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 1
mipsisa64r6-elf  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 2
mipsisa64r6-elf  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 3
mipsisa64r6-linux  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 1
mipsisa64r6-linux  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 2
mipsisa64r6-linux  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 3
mipsisa64r6el-elf  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 1
mipsisa64r6el-elf  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 2
mipsisa64r6el-elf  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 3
mipsisa64r6el-linux  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 1
mipsisa64r6el-linux  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 2
mipsisa64r6el-linux  -FAIL: MIPS XPA and Virtualization ASE instruction disassembly 3

This is because the test cases rely on these ASEs being disabled for
disassembly by default and expect instructions belonging to these ASEs
not to be shown unless explicitly enabled.  The `mips-xpa-virt-4' test
case passes regardless, but we want it to verify the explicit options do
work, so use the `mips:3000' machine to set the defaults there as well.

	binutils/
	* testsuite/binutils-all/mips/mips-xpa-virt-1.d: Use `mips:3000'
	machine for disassembly.
	* testsuite/binutils-all/mips/mips-xpa-virt-2.d: Likewise.
	* testsuite/binutils-all/mips/mips-xpa-virt-3.d: Likewise.
	* testsuite/binutils-all/mips/mips-xpa-virt-4.d: Likewise.
2021-05-29 03:26:32 +02:00
H.J. Lu
1273b2f8ac x86: Restore PC16 relocation overflow check
The x86-64 psABI has

---
A program or object file using R_X86_64_8, R_X86_64_16, R_X86_64_PC16
or R_X86_64_PC8 relocations is not conformant to this ABI, these
relocations are only added for documentation purposes.
---

Since x86 PC16 relocations have been used for 16-bit programs in an ELF32
or ELF64 container, PC16 relocation should wrap-around in 16-bit address
space.  Revert

commit a7664973b2
Author: Jan Beulich <jbeulich@suse.com>
Date:   Mon Apr 26 10:41:35 2021 +0200

    x86: correct overflow checking for 16-bit PC-relative relocs

and xfail the related tests.  Also revert

commit 50c95a739c
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Wed May 26 12:13:13 2021 -0700

    x86: Propery check PC16 reloc overflow in 16-bit mode instructions

while keeping PR ld/27905 tests for PC16 relocation in 16-bit programs.

bfd/

	PR ld/27905
	* elf32-i386.c: Don't include "libiberty.h".
	(elf_howto_table): Revert commits a7664973b2 and 50c95a739c.
	(elf_i386_rtype_to_howto): Revert commit 50c95a739c.
	(elf_i386_info_to_howto_rel): Likewise.
	(elf_i386_tls_transition): Likewise.
	(elf_i386_relocate_section): Likewise.
	* elf64-x86-64.c (x86_64_elf_howto_table): Revert commits
	a7664973b2 and 50c95a739c.
	(elf_x86_64_rtype_to_howto): Revert commit 50c95a739c.
	* elfxx-x86.c (_bfd_x86_elf_parse_gnu_properties): Likewise.
	* elfxx-x86.h (elf_x86_obj_tdata): Likewise.
	(elf_x86_has_code16): Likewise.

binutils/

	PR ld/27905
	* readelf.c (decode_x86_feature_2): Revert commit 50c95a739c.

gas/

	PR ld/27905
	* config/tc-i386.c (set_code_flag): Revert commit 50c95a739c.
	(set_16bit_gcc_code_flag): Likewise.
	(x86_cleanup): Likewise.
	* testsuite/gas/i386/code16-2.d: Updated.
	* testsuite/gas/i386/x86-64-code16-2.d: Likewise.

include/

	PR ld/27905
	* elf/common.h (GNU_PROPERTY_X86_FEATURE_2_CODE16): Removed.

ld/

	PR ld/27905
	* testsuite/ld-i386/pcrel16-2.d: xfail.
	* testsuite/ld-x86-64/pcrel16-2.d: Likewise.
2021-05-28 09:34:28 -07:00
Alan Modra
6643bb0010 readelf -w and --debug-dump option help
* readelf (usage): Order -w letters to match --debug-dump= and
	move common '=' for --debug-dump out of brackets.
2021-05-27 10:47:13 +09:30
H.J. Lu
50c95a739c x86: Propery check PC16 reloc overflow in 16-bit mode instructions
commit a7664973b2
Author: Jan Beulich <jbeulich@suse.com>
Date:   Mon Apr 26 10:41:35 2021 +0200

    x86: correct overflow checking for 16-bit PC-relative relocs

caused linker failure when building 16-bit program in a 32-bit ELF
container.  Update GNU_PROPERTY_X86_FEATURE_2_USED with

 #define GNU_PROPERTY_X86_FEATURE_2_CODE16 (1U << 12)

to indicate that 16-bit mode instructions are used in the input object:

https://groups.google.com/g/x86-64-abi/c/UvvXWeHIGMA

to indicate that 16-bit mode instructions are used in the object to
allow linker to properly perform relocation overflow check for 16-bit
PC-relative relocations in 16-bit mode instructions.

1. Update x86 assembler to always generate the GNU property note with
GNU_PROPERTY_X86_FEATURE_2_CODE16 for .code16 in ELF object.
2. Update i386 and x86-64 linkers to use 16-bit PC16 relocations if
input object is marked with GNU_PROPERTY_X86_FEATURE_2_CODE16.

bfd/

	PR ld/27905
	* elf32-i386.c: Include "libiberty.h".
	(elf_howto_table): Add 16-bit R_386_PC16 entry.
	(elf_i386_rtype_to_howto): Add a BFD argument.  Use 16-bit
	R_386_PC16 if input has 16-bit mode instructions.
	(elf_i386_info_to_howto_rel): Update elf_i386_rtype_to_howto
	call.
	(elf_i386_tls_transition): Likewise.
	(elf_i386_relocate_section): Likewise.
	* elf64-x86-64.c (x86_64_elf_howto_table): Add 16-bit
	R_X86_64_PC16 entry.
	(elf_x86_64_rtype_to_howto): Use 16-bit R_X86_64_PC16 if input
	has 16-bit mode instructions.
	* elfxx-x86.c (_bfd_x86_elf_parse_gnu_properties): Set
	elf_x86_has_code16 if relocatable input is marked with
	GNU_PROPERTY_X86_FEATURE_2_CODE16.
	* elfxx-x86.h (elf_x86_obj_tdata): Add has_code16.
	(elf_x86_has_code16): New.

binutils/

	PR ld/27905
	* readelf.c (decode_x86_feature_2): Support
	GNU_PROPERTY_X86_FEATURE_2_CODE16.

gas/

	PR ld/27905
	* config/tc-i386.c (set_code_flag): Update x86_feature_2_used
	with GNU_PROPERTY_X86_FEATURE_2_CODE16 for .code16 in ELF
	object.
	(set_16bit_gcc_code_flag): Likewise.
	(x86_cleanup): Always generate the GNU property note if
	x86_feature_2_used isn't 0.
	* testsuite/gas/i386/code16-2.d: New file.
	* testsuite/gas/i386/code16-2.s: Likewise.
	* testsuite/gas/i386/x86-64-code16-2.d: Likewise.
	* testsuite/gas/i386/i386.exp: Run code16-2 and x86-64-code16-2.

include/

	PR ld/27905
	* elf/common.h (GNU_PROPERTY_X86_FEATURE_2_CODE16): New.

ld/

	PR ld/27905
	* testsuite/ld-i386/code16.d: New file.
	* testsuite/ld-i386/code16.t: Likewise.
	* testsuite/ld-x86-64/code16.d: Likewise.
	* testsuite/ld-x86-64/code16.t: Likewise.
	* testsuite/ld-i386/i386.exp: Run code16.
	* testsuite/ld-x86-64/x86-64.exp: Likewise.
2021-05-26 12:13:24 -07:00
Chenghua Xu
01a8c731aa elf: Use official name LoongArch for EM_LOONGARCH.
The official name for Loongson Architecture is LoongArch, it is better
to use LoongArch instead of Loongson Loongarch for EM_LOONGARCH to avoid
confusion and keep consistent with the various of software in the future.

The official documentation in Chinese:
http://www.loongson.cn/uploadfile/cpu/LoongArch.pdf

The translated version in English:
https://loongson.github.io/LoongArch-Documentation/

    binutils/
        * readelf.c (get_machine_name): Change Loongson Loongarch to
	LoongArch.

    include/
        * elf/common.h (EM_LOONGARCH): Change Loongson Loongarch to
	LoongArch.
2021-05-23 10:35:48 +08:00
Luis Machado
3b2bef8bbd [Binutils] Update NT_ARM note types for readelf
binutils * readelf.c (get_note_type): Add missing NT_ARM_* entries.
2021-05-21 10:43:52 +01:00
Luis Machado
894982bfcc [AArch64] MTE corefile support
bfd	* elf.c (elfcore_make_memtag_note_section): New function.
	(elfcore_grok_note): Handle NT_MEMTAG note types.

binutils* readelf.c (get_note_type): Handle NT_MEMTAG note types.

include	* elf/common.h (NT_MEMTAG): New constant.
	(NT_MEMTAG_TYPE_AARCH_MTE): New constant.
2021-05-21 10:40:32 +01: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
9d9e2a340b PR27879, stack-buffer-overflow on sysdump
PR 27879
	* sysdump.c (getBARRAY): Sanity check size against max.
	(getINT): Avoid UB shift left.
2021-05-19 11:07:17 +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