Commit Graph

4016 Commits

Author SHA1 Message Date
Vivek Das Mohapatra
a5da3dee21 Handle DT_GNU_FLAGS_1 in readelf
* readelf.c (get_dynamic_type): Handle DT_GNU_FLAGS_1.
	(process_dynamic_section): Likewise.
2020-12-15 18:45:09 +10:30
Cary Coutant
4cf2ad7200 Update ELF headers and readelf with recent e_machine assignments.
binutils/
	* readelf.c (get_machine_name): Update list of e_machine values.

include/
	* elf/common.h: Update list of e_machine values.
2020-12-13 15:22:30 -08:00
Sebastian Huber
b143e2d506 Fix a build problem when using FreeBSD 12.
* ar.c (write_archive): Cast iostream pointer to FILE *.
	* arsup.c (ar_save): Likewise.
	* objcopy.c (copy_file): Likewise.
2020-12-11 13:27:45 +00:00
Nick Clifton
846141822b Remove references to the unofficial SHF_GNU_BUILD_NOTE section flag.
binutils	* objcopy.c (is_mergeable_note_section): Remove reference to
	SHF_GNU_BUILD_NOTE.

include	* elf/common.h (SHF_GNU_BUILD_NOTE): Delete.
2020-12-07 16:17:40 +00:00
Siddhesh Poyarekar
014cc7f849 binutils: Make smart_rename safe too
smart_rename is capable of handling symlinks by copying and it also
tries to preserve ownership and permissions of files when they're
overwritten during the rename.  This is useful in objcopy where the
file properties need to be preserved.

However because smart_rename does this using file names, it leaves a
race window between renames and permission fixes.  This change removes
this race window by using file descriptors from the original BFDs that
were used to manipulate these files wherever possible.

The file that is to be renamed is also passed as a file descriptor so
that we use fchown/fchmod on the file descriptor, thus making sure
that we only modify the file we have opened to write.  Further, in
case the file is to be overwritten (as is the case in ar or objcopy),
the permissions that need to be restored are taken from the file
descriptor that was opened for input so that integrity of the file
status is maintained all the way through to the rename.

binutils/

	* rename.c
	* ar.c
	(write_archive) [!defined (_WIN32) || defined (__CYGWIN32__)]:
	Initialize TARGET_STAT and OFD to pass to SMART_RENAME.
	* arsup.c
	(ar_save) [defined (_WIN32) || defined (__CYGWIN32__)]:
	Likewise.
	* bucomm.h (smart_rename): Add new arguments to declaration.
	* objcopy.c
	(strip_main)[defined (_WIN32) || defined (__CYGWIN32__)]:
	Initialize COPYFD and pass to SMART_RENAME.
	(copy_main) [defined (_WIN32) || defined (__CYGWIN32__)]:
	Likewise.
	* rename.c (try_preserve_permissions): New function.
	(smart_rename): Use it and add new arguments.
2020-12-07 20:48:33 +05:30
Siddhesh Poyarekar
1a1c3b4cc1 objcopy: Get input file stat after BFD open
Get file state from the descriptor opened by copy_file for the input
BFD.  This ensures continuity in the view of the input file through
the descriptor.  At the moment it is only to preserve timestamps
recorded at the point that we opened the file for input but in the
next patch this state will also be used to preserve ownership and
permissions wherever applicable.

binutils/

	* objcopy.c (copy_file): New argument IN_STAT.  Return stat of
	ibfd through it.
	(strip_main): Remove redundant stat calls.  adjust copy_file
	calls.
	(copy_main): Likewise.
2020-12-07 20:48:28 +05:30
Siddhesh Poyarekar
365f5fb6d0 binutils: Use file descriptors from make_tempname
The purpose of creating a temporary file securely using mkstemp is
defeated if it is closed in make_tempname and reopened later for use;
it is as good as using mktemp.  Get the file descriptor instead and
then use it to create the BFD object.

bfd/

	* opncls.c (bfd_fdopenw): New function.
	* bfd-in2.h: Regenerate.

binutils/

	* bucomm.c (make_tempname): Add argument to return file
	descriptor.
	* bucomm.h (make_tempname): Likewise.
	* ar.c: Include libbfd.h.
	(write_archive): Adjust for change in make_tempname.  Call
	bfd_fdopenw instead of bfd_openw.
	* objcopy.c: Include libbfd.h.
	(copy_file): New argument OFD.  Use bfd_fdopenw instead of
	bfd_openw.
	(strip_main): Adjust for change in make_tempname and
	copy_file.
	(copy_main): Likewise.
2020-12-07 20:48:23 +05:30
Nick Clifton
a315d3902d README-how-to-make-a-release (point releases): Add a note to update the milestone list on sourceware's bugzilla. 2020-12-07 11:08:34 +00:00
Alan Modra
288f0ba264 asan: readelf: memory leaks
This tidies some code used by readelf, hopefully fixing some
intermittent oss-fuzz bug reports that likely could only be reproduced
by feeding readelf two or more object files on the command line.  The
second and subsequent file may see non-zero state in .bss variables,
and non-initial values in .data variables.  This patch fixes some of
those, and moves some .data variables to .rodata.

	* dwarf.c (frame_display_row): Do without static variable "sloc".
	(cu_tu_indexes_read): Move to file scope.
	(free_debug_memory): Reset it here, along with level_type_signed.
	Free and clear a number of other static variables.
	* readelf.c (arm_attr_public_tag <table>): Constify, updating..
	(arm_attr_tag_*): ..all these uses.
	(process_mips_specific): Free "rels" on error path.
2020-12-04 11:12:21 +10:30
Nick Clifton
21c33bcbe3 Allow spaces in the name of the external preprocessor used by windres.
PR 26865
	* windres.c (main): If the preprocessor name includes spaces,
	ensure that it is quoted.
2020-11-27 14:19:56 +00:00
Jozef Lawrynowicz
2c6f3e56cb ELF: Support .noinit and .persistent sections
The ".persistent" section is for data that should be initialized during
load, but not during application reset.

The ".noinit" section is for data that should not be initialized during
load or application reset.

Targets utilizing the elf.sc linker script template can define
HAVE_{NOINIT,PERSISTENT}=yes to include the .noinit or .persistent
output sections in the generated linker script.

Targets with existing support for .noinit did not handle unique
.noinit.* and .gnu.linkonce.n.* sections the .noinit output section,
this patch also fixes that.

bfd/ChangeLog:

	* elf.c (special_sections_g): Add .gnu.linkonce.n and .gnu.linkonce.p.
	(special_sections_n): Add .noinit.
	(special_sections_p): Add .persistent.

binutils/ChangeLog:

	* testsuite/lib/binutils-common.exp (supports_noinit_section): New.
	(supports_persistent_section): New.

gas/ChangeLog:

	* testsuite/gas/elf/elf.exp: Run new tests.
	* testsuite/gas/elf/section25.d: New test.
	* testsuite/gas/elf/section25.s: New test.
	* testsuite/gas/elf/section26.d: New test.
	* testsuite/gas/elf/section26.s: New test.

ld/ChangeLog:

	* emulparams/armelf.sh (OTHER_SECTIONS): Remove .noinit section
	definition.
	Define HAVE_{NOINIT,PERSISTENT}=yes.
	* scripttempl/avr.sc (.noinit): Add .noinit.* and .gnu.linkonce.n.*
	input section wildcard patterns.
	* scripttempl/elf.sc: Define .noinit and .persistent sections when
	HAVE_NOINIT or HAVE_PERSISTENT are defined to "yes".
	* scripttempl/elf32msp430.sc (.noinit): Add .noinit.* and
	.gnu.linkonce.n.*. input section wildcard patterns.
	(.persistent): Add .persistent.* and
	.gnu.linkonce.p.*. input section wildcard patterns.
	* scripttempl/elfarcv2.sc (.noinit): Add .noinit.* and
	.gnu.linkonce.n.*. input section wildcard patterns.
	* scripttempl/pru.sc: Likewise.
	* testsuite/ld-elf/noinit-sections-1.d: New test.
	* testsuite/ld-elf/noinit-sections-2.d: New test.
	* testsuite/ld-elf/noinit-sections-2.l: New test.
	* testsuite/ld-elf/noinit-sections.s: New test.
	* testsuite/ld-elf/persistent-sections-1.d: New test.
	* testsuite/ld-elf/persistent-sections-2.d: New test.
	* testsuite/ld-elf/persistent-sections-2.l: New test.
	* testsuite/ld-elf/persistent-sections.s: New test.
2020-11-27 10:45:35 +00:00
Nick Alcock
96c61be508 binutils: readelf: support CTF dicts with non-native-endian symtabs
Now we have a way to tell libctf what the endianness of the symtab is,
get readelf to use it.  (objdump doesn't need to do so, nor does ld,
because they both use BFD-aware mechanisms to open CTF dicts, so libctf
can automatically figure the symtab endianness out.)

binutils/ChangeLog
2020-11-23  Nick Alcock  <nick.alcock@oracle.com>

	* readelf.c (dump_section_as_ctf): Call ctf_arc_symsect_endianness.
2020-11-25 19:11:35 +00:00
Alan Modra
6595cf3ce8 nm ifunc test tweaks
* testsuite/binutils-all/nm.exp (ifunc): xfail more targets.
2020-11-25 16:36:50 +10:30
Nick Clifton
9d37f01307 Add missing test file 2020-11-20 14:06:14 +00:00
Nick Alcock
3d16b64e28 bfd, include, ld, binutils, libctf: CTF should use the dynstr/sym
This is embarrassing.

The whole point of CTF is that it remains intact even after a binary is
stripped, providing a compact mapping from symbols to types for
everything in the externally-visible interface of an ELF object: it has
connections to the symbol table for that purpose, and to the string
table to avoid duplicating symbol names.  So it's a shame that the hooks
I implemented last year served to hook it up to the .symtab and .strtab,
which obviously disappear on strip, leaving any accompanying the CTF
dict containing references to strings (and, soon, symbols) which don't
exist any more because their containing strtab has been vaporized.  The
original Solaris design used .dynsym and .dynstr (well, actually,
.ldynsym, which has more symbols) which do not disappear. So should we.

Thankfully the work we did before serves as guide rails, and adjusting
things to use the .dynstr and .dynsym was fast and easy.  The only
annoyance is that the dynsym is assembled inside elflink.c in a fairly
piecemeal fashion, so that the easiest way to get the symbols out was to
hook in before every call to swap_symbol_out (we also leave in a hook in
front of symbol additions to the .symtab because it seems plausible that
we might want to hook them in future too: for now that hook is unused).
We adjust things so that rather than being offered a whole hash table of
symbols at once, libctf is now given symbols one at a time, with st_name
indexes already resolved and pointing at their final .dynstr offsets:
it's now up to libctf to resolve these to names as needed using the
strtab info we pass it separately.

Some bits might be contentious.  The ctf_new_dynstr callback takes an
elf_internal_sym, and this remains an elf_internal_sym right down
through the generic emulation layers into ldelfgen.  This is no worse
than the elf_sym_strtab we used to pass down, but in the future when we
gain non-ELF CTF symtab support we might want to lower the
elf_internal_sym to some other representation (perhaps a
ctf_link_symbol) in bfd or in ldlang_ctf_new_dynsym.  We rename the
'apply_strsym' hooks to 'acquire_strings' instead, becuse they no longer
have anything to do with symbols.

There are some API changes to pieces of API which are technically public
but actually totally unused by anything and/or unused by anything but ld
so they can change freely: the ctf_link_symbol gains new fields to allow
symbol names to be given as strtab offsets as well as strings, and a
symidx so that the symbol index can be passed in.  ctf_link_shuffle_syms
loses its callback parameter: the idea now is that linkers call the new
ctf_link_add_linker_symbol for every symbol in .dynsym, feed in all the
strtab entries with ctf_link_add_strtab, and then a call to
ctf_link_shuffle_syms will apply both and arrange to use them to reorder
the CTF symtab at CTF serialization time (which is coming in the next
commit).

Inside libctf we have a new preamble flag CTF_F_DYNSTR which is always
set in v3-format CTF dicts from this commit forwards: CTF dicts without
this flag are associated with .strtab like they used to be, so that old
dicts' external strings don't turn to garbage when loaded by new libctf.
Dicts with this flag are associated with .dynstr and .dynsym instead.
(The flag is not the next in sequence because this commit was written
quite late: the missing flags will be filled in by the next commit.)

Tests forthcoming in a later commit in this series.

bfd/ChangeLog
2020-11-20  Nick Alcock  <nick.alcock@oracle.com>

	* elflink.c (elf_finalize_dynstr): Call examine_strtab after
	dynstr finalization.
	(elf_link_swap_symbols_out): Don't call it here.  Call
	ctf_new_symbol before swap_symbol_out.
	(elf_link_output_extsym): Call ctf_new_dynsym before
	swap_symbol_out.
	(bfd_elf_final_link): Likewise.
	* elf.c (swap_out_syms): Pass in bfd_link_info.  Call
	ctf_new_symbol before swap_symbol_out.
	(_bfd_elf_compute_section_file_positions): Adjust.

binutils/ChangeLog
2020-11-20  Nick Alcock  <nick.alcock@oracle.com>

	* readelf.c (dump_section_as_ctf): Use .dynsym and .dynstr, not
	.symtab and .strtab.

include/ChangeLog
2020-11-20  Nick Alcock  <nick.alcock@oracle.com>

	* bfdlink.h (struct elf_sym_strtab): Replace with...
	(struct elf_internal_sym): ... this.
	(struct bfd_link_callbacks) <examine_strtab>: Take only a
	symstrtab argument.
	<ctf_new_symbol>: New.
	<ctf_new_dynsym>: Likewise.
	* ctf-api.h (struct ctf_link_sym) <st_symidx>: New.
	<st_nameidx>: Likewise.
	<st_nameidx_set>: Likewise.
	(ctf_link_iter_symbol_f): Removed.
	(ctf_link_shuffle_syms): Remove most parameters, just takes a
	ctf_dict_t now.
	(ctf_link_add_linker_symbol): New, split from
	ctf_link_shuffle_syms.
	* ctf.h (CTF_F_DYNSTR): New.
	(CTF_F_MAX): Adjust.

ld/ChangeLog
2020-11-20  Nick Alcock  <nick.alcock@oracle.com>

	* ldelfgen.c (struct ctf_strsym_iter_cb_arg): Rename to...
	(struct ctf_strtab_iter_cb_arg): ... this, changing fields:
	<syms>: Remove.
	<symcount>: Remove.
	<symstrtab>: Rename to...
	<strtab>: ... this.
	(ldelf_ctf_strtab_iter_cb): Adjust.
	(ldelf_ctf_symbols_iter_cb): Remove.
	(ldelf_new_dynsym_for_ctf): New, tell libctf about a single
	symbol.
	(ldelf_examine_strtab_for_ctf): Rename to...
	(ldelf_acquire_strings_for_ctf): ... this, only doing the strtab
	portion and not symbols.
	* ldelfgen.h: Adjust declarations accordingly.
	* ldemul.c (ldemul_examine_strtab_for_ctf): Rename to...
	(ldemul_acquire_strings_for_ctf): ... this.
	(ldemul_new_dynsym_for_ctf): New.
	* ldemul.h: Adjust declarations accordingly.
	* ldlang.c (ldlang_ctf_apply_strsym): Rename to...
	(ldlang_ctf_acquire_strings): ... this.
	(ldlang_ctf_new_dynsym): New.
	(lang_write_ctf): Call ldemul_new_dynsym_for_ctf with NULL to do
	the actual symbol shuffle.
	* ldlang.h (struct elf_strtab_hash): Adjust accordingly.
	* ldmain.c (bfd_link_callbacks): Wire up new/renamed callbacks.

libctf/ChangeLog
2020-11-20  Nick Alcock  <nick.alcock@oracle.com>

	* ctf-link.c (ctf_link_shuffle_syms): Adjust.
	(ctf_link_add_linker_symbol): New, unimplemented stub.
	* libctf.ver: Add it.
	* ctf-create.c (ctf_serialize): Set CTF_F_DYNSTR on newly-serialized
	dicts.
	* ctf-open-bfd.c (ctf_bfdopen_ctfsect): Check for the flag: open the
	symtab/strtab if not present, dynsym/dynstr otherwise.
	* ctf-archive.c (ctf_arc_bufpreamble): New, get the preamble from
	some arbitrary member of a CTF archive.
	* ctf-impl.h (ctf_arc_bufpreamble): Declare it.
2020-11-20 13:34:07 +00:00
Nick Alcock
83d59285d5 objdump, readelf: Report errors from CTF archive iteration
We were failing to report errors from ctf_archive_iter, which results in
silent early termination if (for example) one CTF archive member in a
.ctf section is corrupted and cannot be opened.  Report the error in the
usual fashion instead.

binutils/ChangeLog
2020-11-20  Nick Alcock  <nick.alcock@oracle.com>

	* objdump.c (dump_ctf): Report errors from ctf_archive_iter.
	* readelf.c (dump_section_as_ctf): Likewise.
2020-11-20 13:34:06 +00:00
Nick Alcock
ae41200ba8 libctf, include, binutils, gdb: rename CTF-opening functions
The functions that return ctf_dict_t's given a ctf_archive_t and a name
are very clumsily named.  It sounds like they return *archives*, not
dictionaries, and the names are very long and clunky.  Why do we
have a ctf_arc_open_by_name when it opens a dictionary, not an archive,
and when there is no way to open a dictionary in any other way?  The
answer is purely internal: the function is located in ctf-archive.c,
and everything in there was called ctf_arc_*, and there is another
way to open a dict (by offset in the archive), that is internal to
ctf-archive.c and that nothing else can call.

This is clearly bad naming. The internal organization of the source tree
should not dictate public API names!

So rename things (keeping the old, bad names for compatibility), and
adjust all users.  You now open a dict using ctf_dict_open, and
open it giving ELF sections via ctf_dict_open_sections.

binutils/ChangeLog
2020-11-20  Nick Alcock  <nick.alcock@oracle.com>

	* objdump.c (dump_ctf): Use ctf_dict_open, not
	ctf_arc_open_by_name.
	* readelf.c (dump_section_as_ctf): Likewise.

gdb/ChangeLog
2020-11-20  Nick Alcock  <nick.alcock@oracle.com>

	* ctfread.c (elfctf_build_psymtabs): Use ctf_dict_open, not
	ctf_arc_open_by_name.

include/ChangeLog
2020-11-20  Nick Alcock  <nick.alcock@oracle.com>

	* ctf-api.h (ctf_arc_open_by_name): Rename to...
	(ctf_dict_open): ... this, keeping compatibility function.
	(ctf_arc_open_by_name_sections): Rename to...
	(ctf_dict_open_sections): ... this, keeping compatibility function.

libctf/ChangeLog
2020-11-20  Nick Alcock  <nick.alcock@oracle.com>

	* ctf-archive.c (ctf_arc_open_by_offset): Rename to...
	(ctf_dict_open_by_offset): ... this.  Adjust callers.
	(ctf_arc_open_by_name_internal): Rename to...
	(ctf_dict_open_internal): ... this.  Adjust callers.
	(ctf_arc_open_by_name_sections): Rename to...
	(ctf_dict_open_sections): ... this, keeping compatibility function.
	(ctf_arc_open_by_name): Rename to...
	(ctf_dict_open): ... this, keeping compatibility function.
	* libctf.ver: New functions added.
	* ctf-link.c (ctf_link_one_input_archive): Adjusted accordingly.
	(ctf_link_deduplicating_open_inputs): Likewise.
2020-11-20 13:34:05 +00:00
Nick Alcock
139633c307 libctf, include, binutils, gdb, ld: rename ctf_file_t to ctf_dict_t
The naming of the ctf_file_t type in libctf is a historical curiosity.
Back in the Solaris days, CTF dictionaries were originally generated as
a separate file and then (sometimes) merged into objects: hence the
datatype was named ctf_file_t, and known as a "CTF file".  Nowadays, raw
CTF is essentially never written to a file on its own, and the datatype
changed name to a "CTF dictionary" years ago.  So the term "CTF file"
refers to something that is never a file!  This is at best confusing.

The type has also historically been known as a 'CTF container", which is
even more confusing now that we have CTF archives which are *also* a
sort of container (they contain CTF dictionaries), but which are never
referred to as containers in the source code.

So fix this by completing the renaming, renaming ctf_file_t to
ctf_dict_t throughout, and renaming those few functions that refer to
CTF files by name (keeping compatibility aliases) to refer to dicts
instead.  Old users who still refer to ctf_file_t will see (harmless)
pointer-compatibility warnings at compile time, but the ABI is unchanged
(since C doesn't mangle names, and ctf_file_t was always an opaque type)
and things will still compile fine as long as -Werror is not specified.
All references to CTF containers and CTF files in the source code are
fixed to refer to CTF dicts instead.

Further (smaller) renamings of annoyingly-named functions to come, as
part of the process of souping up queries across whole archives at once
(needed for the function info and data object sections).

binutils/ChangeLog
2020-11-20  Nick Alcock  <nick.alcock@oracle.com>

	* objdump.c (dump_ctf_errs): Rename ctf_file_t to ctf_dict_t.
	(dump_ctf_archive_member): Likewise.
	(dump_ctf): Likewise. Use ctf_dict_close, not ctf_file_close.
	* readelf.c (dump_ctf_errs): Rename ctf_file_t to ctf_dict_t.
	(dump_ctf_archive_member): Likewise.
	(dump_section_as_ctf): Likewise.  Use ctf_dict_close, not
	ctf_file_close.

gdb/ChangeLog
2020-11-20  Nick Alcock  <nick.alcock@oracle.com>

	* ctfread.c: Change uses of ctf_file_t to ctf_dict_t.
	(ctf_fp_info::~ctf_fp_info): Call ctf_dict_close, not ctf_file_close.

include/ChangeLog
2020-11-20  Nick Alcock  <nick.alcock@oracle.com>

	* ctf-api.h (ctf_file_t): Rename to...
	(ctf_dict_t): ... this.  Keep ctf_file_t around for compatibility.
	(struct ctf_file): Likewise rename to...
	(struct ctf_dict): ... this.
	(ctf_file_close): Rename to...
	(ctf_dict_close): ... this, keeping compatibility function.
	(ctf_parent_file): Rename to...
	(ctf_parent_dict): ... this, keeping compatibility function.
	All callers adjusted.
	* ctf.h: Rename references to ctf_file_t to ctf_dict_t.
	(struct ctf_archive) <ctfa_nfiles>: Rename to...
	<ctfa_ndicts>: ... this.

ld/ChangeLog
2020-11-20  Nick Alcock  <nick.alcock@oracle.com>

	* ldlang.c (ctf_output): This is a ctf_dict_t now.
	(lang_ctf_errs_warnings): Rename ctf_file_t to ctf_dict_t.
	(ldlang_open_ctf): Adjust comment.
	(lang_merge_ctf): Use ctf_dict_close, not ctf_file_close.
	* ldelfgen.h (ldelf_examine_strtab_for_ctf): Rename ctf_file_t to
	ctf_dict_t.  Change opaque declaration accordingly.
	* ldelfgen.c (ldelf_examine_strtab_for_ctf): Adjust.
	* ldemul.h (examine_strtab_for_ctf): Likewise.
	(ldemul_examine_strtab_for_ctf): Likewise.
	* ldeuml.c (ldemul_examine_strtab_for_ctf): Likewise.

libctf/ChangeLog
2020-11-20  Nick Alcock  <nick.alcock@oracle.com>

	* ctf-impl.h: Rename ctf_file_t to ctf_dict_t: all declarations
	adjusted.
	(ctf_fileops): Rename to...
	(ctf_dictops): ... this.
	(ctf_dedup_t) <cd_id_to_file_t>: Rename to...
	<cd_id_to_dict_t>: ... this.
	(ctf_file_t): Fix outdated comment.
	<ctf_fileops>: Rename to...
	<ctf_dictops>: ... this.
	(struct ctf_archive_internal) <ctfi_file>: Rename to...
	<ctfi_dict>: ... this.
	* ctf-archive.c: Rename ctf_file_t to ctf_dict_t.
	Rename ctf_archive.ctfa_nfiles to ctfa_ndicts.
	Rename ctf_file_close to ctf_dict_close.  All users adjusted.
	* ctf-create.c: Likewise.  Refer to CTF dicts, not CTF containers.
	(ctf_bundle_t) <ctb_file>: Rename to...
	<ctb_dict): ... this.
	* ctf-decl.c: Rename ctf_file_t to ctf_dict_t.
	* ctf-dedup.c: Likewise.  Rename ctf_file_close to
	ctf_dict_close. Refer to CTF dicts, not CTF containers.
	* ctf-dump.c: Likewise.
	* ctf-error.c: Likewise.
	* ctf-hash.c: Likewise.
	* ctf-inlines.h: Likewise.
	* ctf-labels.c: Likewise.
	* ctf-link.c: Likewise.
	* ctf-lookup.c: Likewise.
	* ctf-open-bfd.c: Likewise.
	* ctf-string.c: Likewise.
	* ctf-subr.c: Likewise.
	* ctf-types.c: Likewise.
	* ctf-util.c: Likewise.
	* ctf-open.c: Likewise.
	(ctf_file_close): Rename to...
	(ctf_dict_close): ...this.
	(ctf_file_close): New trivial wrapper around ctf_dict_close, for
	compatibility.
	(ctf_parent_file): Rename to...
	(ctf_parent_dict): ... this.
	(ctf_parent_file): New trivial wrapper around ctf_parent_dict, for
	compatibility.
	* libctf.ver: Add ctf_dict_close and ctf_parent_dict.
2020-11-20 13:34:04 +00:00
Nick Clifton
e6f6aa8d18 Add option to nm to change the characters displayed for ifunc symbols. Add a configure time option to change the default characters.
PR 22967
	* nm.c (ifunc_type_chars): New variable.
	(long_options): Add --ifunc-chars.
	(print_symbol): Use ifunc_type_chars for ifunc symbols.
	(main): Handle the new option.
	* doc/binutils.texi: Document the new option.
	* configure.ac: Add --enable-f-for-ifunc-symbols option which
	changes the default symbol displayed by nm.
	* NEWS: Mention the new feature.
	* testsuite/binutils-all/nm.exp: Test the new feature.
	* config.in: Regenerate.
	* configure: Regenerate.
2020-11-20 13:04:56 +00:00
Linda Zhang
8881640c80 Add a warning to dllwrap that it is deprecated.
PR 20979
	* dllwrap.c (main): Deprecate and warn the use of dllwrap.
2020-11-20 11:07:26 +00:00
Jozef Lawrynowicz
cc6fd584ed Fix SHF_GNU_RETAIN testsuite fallout
binutils/ChangeLog:

	* testsuite/binutils-all/readelf-maskos-1a.d: Fix test for unrecognized
	bit set in SHF_MASKOS range.
	* testsuite/binutils-all/readelf-maskos-1b.d: Likewise.
	* testsuite/binutils-all/readelf-maskos-unknown.s: New test.

ld/ChangeLog:

	* testsuite/ld-elf/retain3.s: Move symbolic reference into writeable
	.data section from read-only .text section.
	* testsuite/ld-elf/retain5.d: Don't pass --print-gc-sections for test
	that doesn't require it.
	* testsuite/ld-elf/retain6a.d: Adjust test.
	* testsuite/ld-elf/retain6main.s: Move symbolic reference into writeable
	.data section from read-only .text section.
2020-11-20 10:33:28 +00:00
Jozef Lawrynowicz
99fabbc973 Support SHF_GNU_RETAIN ELF section flag
The SHF_GNU_RETAIN section flag is an extension to the GNU ELF OSABI.
It is defined as follows:

=========================================================
Section Attribute Flags
+-------------------------------------+
| Name           | Value              |
+-------------------------------------+
| SHF_GNU_RETAIN | 0x200000 (1 << 21) |
+-------------------------------------+

SHF_GNU_RETAIN
  The link editor should not garbage collect the section.
=========================================================

The .section directive accepts the "R" flag, which indicates
SHF_GNU_RETAIN should be applied to the section.

There is not a direct mapping of SHF_GNU_RETAIN to the BFD
section flag SEC_KEEP. Keeping these flags distinct allows
SHF_GNU_RETAIN sections to be explicitly removed by placing them in
/DISCARD/.

bfd/ChangeLog:

	* elf-bfd.h (enum elf_gnu_osabi): Add elf_gnu_osabi_retain.
	(struct elf_obj_tdata): Increase has_gnu_osabi to 4 bits.
	* elf.c (_bfd_elf_make_section_from_shdr): Set elf_gnu_osabi_retain
	for SHF_GNU_RETAIN.
	(_bfd_elf_final_write_processing): Report if SHF_GNU_RETAIN is
	not supported by the OSABI.
	Adjust error messages.
	* elflink.c (elf_link_input_bfd): Copy enabled has_gnu_osabi bits from
	input BFD to output BFD.
	(bfd_elf_gc_sections): gc_mark the section if SHF_GNU_RETAIN is set.

binutils/ChangeLog:

	* NEWS: Announce SHF_GNU_RETAIN support.
	* readelf.c (get_elf_section_flags): Handle SHF_GNU_RETAIN.
	Recognize SHF_GNU_RETAIN and SHF_GNU_MBIND only for supported OSABIs.
	* testsuite/binutils-all/readelf.exp: Run new tests.
	Don't run run_dump_test when there isn't an assembler available.
	* testsuite/lib/binutils-common.exp (supports_gnu_osabi): Adjust
	comment.
	* testsuite/binutils-all/readelf-maskos-1a.d: New test.
	* testsuite/binutils-all/readelf-maskos-1b.d: New test.
	* testsuite/binutils-all/readelf-maskos.s: New test.
	* testsuite/binutils-all/retain1.s: New test.
	* testsuite/binutils-all/retain1a.d: New test.
	* testsuite/binutils-all/retain1b.d: New test.

gas/ChangeLog:

	* NEWS: Announce SHF_GNU_RETAIN support.
	* config/obj-elf.c (obj_elf_change_section): Merge SHF_GNU_RETAIN bit
	between section declarations.
	(obj_elf_parse_section_letters): Handle 'R' flag.
	Handle numeric flag values within the SHF_MASKOS range.
	(obj_elf_section): Validate SHF_GNU_RETAIN usage.
	* doc/as.texi: Document 'R' flag to .section directive.
	* testsuite/gas/elf/elf.exp: Run new tests.
	* testsuite/gas/elf/section10.d: Unset SHF_GNU_RETAIN bit.
	* testsuite/gas/elf/section10.s: Likewise.
	* testsuite/gas/elf/section22.d: New test.
	* testsuite/gas/elf/section22.s: New test.
	* testsuite/gas/elf/section23.s: New test.
	* testsuite/gas/elf/section23a.d: New test.
	* testsuite/gas/elf/section23b.d: New test.
	* testsuite/gas/elf/section23b.err: New test.
	* testsuite/gas/elf/section24.l: New test.
	* testsuite/gas/elf/section24.s: New test.
	* testsuite/gas/elf/section24a.d: New test.
	* testsuite/gas/elf/section24b.d: New test.

include/ChangeLog:

	* elf/common.h (SHF_GNU_RETAIN): Define.

ld/ChangeLog:

	* NEWS: Announce support for SHF_GNU_RETAIN.
	* ld.texi (garbage collection): Document SHF_GNU_RETAIN.
	(Output Section Discarding): Likewise.
	* testsuite/ld-elf/elf.exp: Run new tests.
	* testsuite/ld-elf/retain1.s: New test.
	* testsuite/ld-elf/retain1a.d: New test.
	* testsuite/ld-elf/retain1b.d: New test.
	* testsuite/ld-elf/retain2.d: New test.
	* testsuite/ld-elf/retain2.ld: New test.
	* testsuite/ld-elf/retain2.map: New test.
	* testsuite/ld-elf/retain3.d: New test.
	* testsuite/ld-elf/retain3.s: New test.
	* testsuite/ld-elf/retain4.d: New test.
	* testsuite/ld-elf/retain4.s: New test.
	* testsuite/ld-elf/retain5.d: New test.
	* testsuite/ld-elf/retain5.map: New test.
	* testsuite/ld-elf/retain5lib.s: New test.
	* testsuite/ld-elf/retain5main.s: New test.
	* testsuite/ld-elf/retain6a.d: New test.
	* testsuite/ld-elf/retain6b.d: New test.
	* testsuite/ld-elf/retain6lib.s: New test.
	* testsuite/ld-elf/retain6main.s: New test.
2020-11-18 11:51:13 +00:00
Howard Chu
0833984dda Place the libdeps record in the second archive slot.
* ar.c (main): Place the libdeps record in the second archive
	slot.
2020-11-17 14:00:08 +00:00
Nick Clifton
50ea087755 Fix readelf's and objdump's dislplay of DWO links when multiple links are present.
PR 26829
 * dwarf.c (struct dwo_info): Add cu_offset field.
 (add_dwo_info): Add cu_offset parameter.  Record in new dwo_info
 struct.
 (add_dwo_name): Add cu_offset field.
 (add_dwo_dir): Add cu_offset field.
 (add_dwo_id): Add cu_offset field.
 (read_and_display_attr_value): Pass cu_offset to dwo recording
 functions.
 (load_separate_debug_files): Accumulate name, dir and id values
 and display once for each CU.
 * testsuite/binutils-all/dwo.sL Use a separate CU for the second
 dwo link.
 * testsuite/binutils-all/readelf.k2: Update expected output.
2020-11-13 16:02:39 +00:00
Bernd Edlinger
4d93271533 readelf: Fix output of rnglists section
* dwarf.c (display_debug_rnglists_list): Only bias the
	DW_RLS_offset_pair with the base address.
2020-11-11 14:31:46 +00:00
Nick Clifton
ed1afd8666 oops - forgot to include the changelog update for the latest binutils/dwarf.c patch 2020-11-10 17:31:14 +00:00
Nick Clifton
1f57314183 Accept the DW_FORM_ref8 type when parsing DWARF types.
* dwarf.c (skip_attr_bytes): Correctly handle DW_FORM_ref8.
	(get_type_abbrev_from_form): Accept DW_FORM_ref8.
2020-11-10 11:55:18 +00:00
Andreas Schwab
a76bf0e55d Fix regexp for development.exp
binutils/:
	* Makefile.am (development.exp): Fix regexp.
	* Makefile.in: Regenerate.
gas/:
	* Makefile.am (development.exp): Fix regexp.
	* Makefile.in: Regenerate.
ld/:
	* Makefile.am (development.exp): Fix regexp.
	* Makefile.in: Regenerate.
2020-11-09 12:05:39 +01:00
Nick Clifton
521d4b194f Extend the DWARF decoder to display FORM names when operating in wide mode.
PR 26847
	* dwarf.c (read_and_display_attr_value): In wide mode, display the
	name of the form.
2020-11-09 10:37:51 +00:00
Alan Modra
a4e91c4630 elfedit false "may be used uninitialised"
elfedit.c:904:15: error: 'osabi' may be used uninitialised in this function [-Werror=maybe-uninitialized]
  904 |       osabi = concat (osabi, "|", osabis[i].name, NULL);
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

	* elfedit (usage): Avoid false positive "may be used uninitialised".
	Don't leak memory.
2020-11-09 14:20:10 +10:30
Howard Chu
c9af384513 Re: dependency list for static libraries
This feature doesn't actually require plugin support, that was a
mistake in the previous patch.  Fixes these fails:

hppa-hp-hpux10  +FAIL: ar adding library dependencies
i386-bsd  +FAIL: ar adding library dependencies
i386-msdos  +FAIL: ar adding library dependencies
ns32k-netbsd  +FAIL: ar adding library dependencies
ns32k-pc532-mach  +FAIL: ar adding library dependencies
pdp11-dec-aout  +FAIL: ar adding library dependencies

	* ar.c (main): Use plugin_target rather than "target" when
	resetting libdeps_bfd target.
2020-11-09 14:07:19 +10:30
H.J. Lu
9c905051aa elfedit: Update help message
Update elfedit message to

$ elfedit --help
Usage: elfedit <option(s)> elffile(s)
 Update the ELF header of ELF files
 The options are:
  --input-mach [none|i386|iamcu|l1om|k1om|x86_64]
                              Set input machine type
  --output-mach [none|i386|iamcu|l1om|k1om|x86_64]
                              Set output machine type
  --input-type [none|rel|exec|dyn]
                              Set input file type
  --output-type [none|rel|exec|dyn]
                              Set output file type
  --input-osabi [none|HPUX|NetBSD|GNU|Linux|Solaris|AIX|Irix|FreeBSD|TRU64|Modesto|OpenBSD|OpenVMS|NSK|AROS|FenixOS]
                              Set input OSABI
  --output-osabi [none|HPUX|NetBSD|GNU|Linux|Solaris|AIX|Irix|FreeBSD|TRU64|Modesto|OpenBSD|OpenVMS|NSK|AROS|FenixOS]
                              Set output OSABI
  --enable-x86-feature [ibt|shstk]
                              Enable x86 feature
  --disable-x86-feature [ibt|shstk]
                              Disable x86 feature
  -h --help                   Display this information
  -v --version                Display the version number of elfedit
Report bugs to <http://www.sourceware.org/bugzilla/>

	* elfedit.c: Include "libiberty.h".
	(usage): Update help message.
2020-11-06 06:04:41 -08:00
Howard Chu
f3016d6ce1 Add an option to the archiver to add a section recording library dependencies.
* ar.c (long_options): Add --record-libdeps.
	(usage): Mention the new option.
	(decode_options): Handle the new option.
	(replace_members): If necessary, create a bfd to hold the libdeps
	description.
	* binemul.c (ar_emul_append_bfd): New function.
	(ar_emul_replace_bfd): New function.
	(ar_emul_default_append): Replace file_name and target arguments
	with new_bfd argument.
	(ar_emul_default_replace): Likewise.
	* binemul.h: Update prototypes.
	(struct bin_emulation_xfer_struct): Update fields.
	* doc/binutils.texi: Document the new option.
	* NEWS: Mention the new feature.
	* emul_aix.c (ar_emul_aix_append): Update.
	(ar_emul_aix_replace): Likewise.
	* testsuite/binutils-all/ar.exp: Add test of new feature.
2020-11-03 15:12:47 +00:00
H.J. Lu
b0ab069373 x86: Support GNU_PROPERTY_X86_ISA_1_BASELINE marker
GCC 11 supports -march=x86-64-v[234] to enable x86 micro-architecture ISA
levels:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97250

X86 ISA markers are updated:

https://gitlab.com/x86-psABIs/x86-64-ABI/-/merge_requests/13

GNU_PROPERTY_X86_ISA_1_BASELINE is added and GNU_PROPERTY_X86_ISA_1_V[234]
are updated:

 #define GNU_PROPERTY_X86_ISA_1_BASELINE (1U << 0)
 #define GNU_PROPERTY_X86_ISA_1_V2       (1U << 1)
 #define GNU_PROPERTY_X86_ISA_1_V3       (1U << 2)
 #define GNU_PROPERTY_X86_ISA_1_V4       (1U << 3)

Add -z x86-64-baseline linker command line option to mark x86-64-baseline
ISA level as needed.

bfd/

	PR gas/26703
	* elfxx-x86.c (_bfd_x86_elf_link_setup_gnu_properties): Generate
	GNU_PROPERTY_X86_ISA_1_BASELINE for -z x86-64-baseline.

binutils/

	PR gas/26703
	* readelf.c (decode_x86_isa): Handle
	* GNU_PROPERTY_X86_ISA_1_BASELINE.
	* testsuite/binutils-all/i386/empty.d: Updated.
	* testsuite/binutils-all/i386/ibt.d: Likewise.
	* testsuite/binutils-all/i386/pr21231a.d: Likewise.
	* testsuite/binutils-all/i386/pr21231b.d: Likewise.
	* testsuite/binutils-all/i386/shstk.d: Likewise.
	* testsuite/binutils-all/x86-64/empty-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/empty.d: Likewise.
	* testsuite/binutils-all/x86-64/ibt-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/ibt.d: Likewise.
	* testsuite/binutils-all/x86-64/pr21231a.d: Likewise.
	* testsuite/binutils-all/x86-64/pr21231b.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494a-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494a.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494c-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494c.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494d-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494d.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494e-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494e.d: Likewise.
	* testsuite/binutils-all/x86-64/shstk-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/shstk.d: Likewise.

gas/

	PR gas/26703
	* config/tc-i386.c (output_insn): Update for
	GNU_PROPERTY_X86_ISA_1_BASELINE.
	* testsuite/gas/i386/property-1.d: Updated.
	* testsuite/gas/i386/property-2.d: Likewise.
	* testsuite/gas/i386/property-3.d: Likewise.
	* testsuite/gas/i386/property-4.d: Likewise.
	* testsuite/gas/i386/property-5.d: Likewise.
	* testsuite/gas/i386/property-6.d: Likewise.
	* testsuite/gas/i386/property-11.d: Likewise.
	* testsuite/gas/i386/property-12.d: Likewise.
	* testsuite/gas/i386/x86-64-property-1.d: Likewise.
	* testsuite/gas/i386/x86-64-property-2.d: Likewise.
	* testsuite/gas/i386/x86-64-property-3.d: Likewise.
	* testsuite/gas/i386/x86-64-property-4.d: Likewise.
	* testsuite/gas/i386/x86-64-property-5.d: Likewise.
	* testsuite/gas/i386/x86-64-property-6.d: Likewise.
	* testsuite/gas/i386/x86-64-property-11.d: Likewise.
	* testsuite/gas/i386/x86-64-property-12.d: Likewise.

include/

	PR gas/26703
	* elf/common.h (GNU_PROPERTY_X86_ISA_1_BASELINE): New.
	(GNU_PROPERTY_X86_ISA_1_V2): Uppdated.
	(GNU_PROPERTY_X86_ISA_1_V3): Likewise.
	(GNU_PROPERTY_X86_ISA_1_V4): Likewise.

ld/

	PR gas/26703
	* NEWS: Mention -z x86-64-baseline.
	* ld.texi: Document -z x86-64-baseline.
	* emulparams/x86-64-level.sh: Handle -z x86-64-baseline.
	* testsuite/ld-elf/x86-feature-1a.rd: Update.
	* testsuite/ld-elf/x86-feature-1b.rd: Likewise.
	* testsuite/ld-elf/x86-feature-1c.rd: Likewise.
	* testsuite/ld-elf/x86-feature-1d.rd: Likewise.
	* testsuite/ld-elf/x86-feature-1e.rd: Likewise.
	* testsuite/ld-i386/pr23372c.d: Likewise.
	* testsuite/ld-i386/pr23486c.d: Likewise.
	* testsuite/ld-i386/pr23486d.d: Likewise.
	* testsuite/ld-i386/pr24322a.d: Likewise.
	* testsuite/ld-i386/pr24322b.d: Likewise.
	* testsuite/ld-i386/property-1a.r: Likewise.
	* testsuite/ld-i386/property-2a.r: Likewise.
	* testsuite/ld-i386/property-3.r: Likewise.
	* testsuite/ld-i386/property-3a.r: Likewise.
	* testsuite/ld-i386/property-4.r: Likewise.
	* testsuite/ld-i386/property-4a.r: Likewise.
	* testsuite/ld-i386/property-5.r: Likewise.
	* testsuite/ld-i386/property-5a.r: Likewise.
	* testsuite/ld-i386/property-7a.r: Likewise.
	* testsuite/ld-i386/property-x86-3.d: Likewise.
	* testsuite/ld-i386/property-x86-4a.d: Likewise.
	* testsuite/ld-i386/property-x86-5.d: Likewise.
	* testsuite/ld-i386/property-x86-cet1.d: Likewise.
	* testsuite/ld-i386/property-x86-cet2a.d: Likewise.
	* testsuite/ld-i386/property-x86-cet5a.d: Likewise.
	* testsuite/ld-i386/property-x86-cet5b.d: Likewise.
	* testsuite/ld-i386/property-x86-ibt1a.d: Likewise.
	* testsuite/ld-i386/property-x86-ibt1b.d: Likewise.
	* testsuite/ld-i386/property-x86-ibt2.d: Likewise.
	* testsuite/ld-i386/property-x86-ibt3a.d: Likewise.
	* testsuite/ld-i386/property-x86-ibt3b.d: Likewise.
	* testsuite/ld-i386/property-x86-ibt4.d: Likewise.
	* testsuite/ld-i386/property-x86-ibt5.d: Likewise.
	* testsuite/ld-i386/property-x86-isa1.d: Likewise.
	* testsuite/ld-i386/property-x86-isa2.d: Likewise.
	* testsuite/ld-i386/property-x86-isa3.d: Likewise.
	* testsuite/ld-i386/property-x86-shstk1a.d: Likewise.
	* testsuite/ld-i386/property-x86-shstk1b.d: Likewise.
	* testsuite/ld-i386/property-x86-shstk2.d: Likewise.
	* testsuite/ld-i386/property-x86-shstk3a.d: Likewise.
	* testsuite/ld-i386/property-x86-shstk3b.d: Likewise.
	* testsuite/ld-i386/property-x86-shstk4.d: Likewise.
	* testsuite/ld-i386/property-x86-shstk5.d: Likewise.
	* testsuite/ld-x86-64/pr23372c-x32.d: Likewise.
	* testsuite/ld-x86-64/pr23372c.d: Likewise.
	* testsuite/ld-x86-64/pr23486c-x32.d: Likewise.
	* testsuite/ld-x86-64/pr23486c.d: Likewise.
	* testsuite/ld-x86-64/pr23486d-x32.d: Likewise.
	* testsuite/ld-x86-64/pr23486d.d: Likewise.
	* testsuite/ld-x86-64/pr24322a-x32.d: Likewise.
	* testsuite/ld-x86-64/pr24322a.d: Likewise.
	* testsuite/ld-x86-64/pr24322b-x32.d: Likewise.
	* testsuite/ld-x86-64/pr24322b.d: Likewise.
	* testsuite/ld-x86-64/pr24458a-x32.d: Likewise.
	* testsuite/ld-x86-64/pr24458a.d: Likewise.
	* testsuite/ld-x86-64/pr24458b-x32.d: Likewise.
	* testsuite/ld-x86-64/pr24458b.d: Likewise.
	* testsuite/ld-x86-64/pr24458c-x32.d: Likewise.
	* testsuite/ld-x86-64/pr24458c.d: Likewise.
	* testsuite/ld-x86-64/property-1a.r: Likewise.
	* testsuite/ld-x86-64/property-2a.r: Likewise.
	* testsuite/ld-x86-64/property-3.r: Likewise.
	* testsuite/ld-x86-64/property-3a.r: Likewise.
	* testsuite/ld-x86-64/property-4.r: Likewise.
	* testsuite/ld-x86-64/property-4a.r: Likewise.
	* testsuite/ld-x86-64/property-5.r: Likewise.
	* testsuite/ld-x86-64/property-5a.r: Likewise.
	* testsuite/ld-x86-64/property-7a.r: Likewise.
	* testsuite/ld-x86-64/property-x86-3-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-3.d: Likewise.
	* testsuite/ld-x86-64/property-x86-4a-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-4a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-5-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-5.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet1-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet1.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet2a-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet2a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet5a-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet5a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet5b-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet5b.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt1a-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt1a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt1b-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt1b.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt2-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt2.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt3a-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt3a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt3b-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt3b.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt4-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt4.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt5-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-isa1-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-isa1.d: Likewise.
	* testsuite/ld-x86-64/property-x86-isa2-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-isa2.d: Likewise.
	* testsuite/ld-x86-64/property-x86-isa3-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-isa3.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt5.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk1a-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk1a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk1b-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk1b.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk2-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk2.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk3a-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk3a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk3b-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk3b.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk4-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk4.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk5-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk5.d: Likewise.
	* testsuite/ld-i386/i386.exp: Run property-x86-isa4.
	* testsuite/ld-i386/property-x86-isa4.d: New file.
	* testsuite/ld-x86-64/property-x86-isa4-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-isa4.d: Likewise.
	* ld/testsuite/ld-x86-64/x86-64.exp: Run property-x86-isa4
	and property-x86-isa4-x32.
2020-10-30 06:50:10 -07:00
H.J. Lu
76868f3606 dwarf: Also match abbrev base when searching abbrev list
A .debug_abbrev section can have multiple CUs.  When caching abbrev list,
we need to check abbrev base to support multiple CUs.

	PR binutils/26808
	* dwarf.c (abbrev_list): Add abbrev_base.
	(new_abbrev_list): Add an abbrev_base argument and record it.
	(find_abbrev_list_by_abbrev_offset): Add an abbrev_base argument
	and match it.
	(process_debug_info): Pass abbrev_base to new_abbrev_list and
	find_abbrev_list_by_abbrev_offset.
	(display_debug_abbrev): Pass 0 abbrev_base to new_abbrev_list
	and find_abbrev_list_by_abbrev_offset.
	* testsuite/binutils-all/x86-64/pr26808.dump: New file.
	* testsuite/binutils-all/x86-64/pr26808.dwp.bz2: Likewise.
	* testsuite/binutils-all/x86-64/x86-64.exp: Run PR binutils/26808
	test.
2020-10-29 09:19:35 -07:00
Nick Clifton
00c19b8e78 Fix a potential illegal memory access by objcopy when extracting dwo sections.
PR 26805
 * objcopy.c (is_dwo_section): Check for missing or short section
 names.
2020-10-29 11:17:39 +00:00
Andreas Rammhold
ce04ca3123 Use sha256 for hashes in the release process
I just came across the GDB 10.1 release notes and saw that md5 is still
being used in those. I thought it would be a good idea to instead have a
more modern, secure and wildly available hash function such as SHA256 as
part of the release process.

The changes have been done rather mechnically via sed but executing the
`src-release.sh -b gdb` did work so I am confident about the result.

While this does not directly address the release mails, I was wasn't
able to find the template/script used for those, this is probably still
an improvement.

ChangeLog:
	* src-release.sh: Use sha256sum instead of md5sum.

binutils/ChangeLog:
	* README-how-to-make-a-release: Use sha256sum instead of md5sum.

Change-Id: I9cf19ea40699137c45463b8514f6e29271af2347
2020-10-28 10:35:28 -04:00
Nick Clifton
ec3f28df02 Fix compile time warning building with gcc 11.
PR 26795
	* elfedit.c (process_archive): Remove spurious call to free().
2020-10-28 10:56:00 +00:00
Nick Clifton
bcd213b2cf Fix the decoding of DW_FORM_ref_addr DWARF attribute.
* dwarf.c (struct abbrev_list): New structure.  Used to collect
	lists of abbreviation sets.
	(struct abbrev_map): New structure.  Used to map CU offsets to
	abbreviation offsets.
	(record_abbrev_list): New function.  A new entry to an
	abbreviation list.
	(free_all_abbrevs): Update to free abbreviation lists.
	(new_abbrev_list): New function.  Start a new abbreviation
	list.
	(find_abbrev_list_by_abbrev_offset): New function.
	(find_abbrev_map_by_offset): New function.
	(add_abbrev): Add abbrev_list parameter.
	(add_abbrev_attr): Likewise.
	(process_abbrev_section): Rename to process_abbrev_set and add
	list parameter.
	(get_type_abbrev_from_form): New function.  Attempts to decode the
	forms used by DW_AT_type attributes.
	(get_type_signedness): Display type names if operating in wide
	mode.  Use get_type_abbrev_from_form.
	(read_and_display_attr_value): Use get_type_abbrev_from_form.
	(process_debug_info): Pre-parse the CU headers to collate all the
	abbrevs before starting the main scan.
	(process_debug_abbrev): Do not free any loaded abbrevs.
	(free_debug_memory): Free the abbrev maps.
2020-10-27 16:17:13 +00:00
H.J. Lu
64ec7c3f80 binutils: Report error message on error
* testsuite/binutils-all/objcopy.exp (objcopy_test): Report
	error message on error.
2020-10-22 04:48:29 -07:00
Dr. David Alan Gilbert
777cd7ab3f Fix printf formatting errors where "0x" is used as a prefix for a decimal number.
bfd	* po/es.po: Fix printf format

binutils * windmc.c: Fix printf format

gas	* config/tc-arc.c: Fix printf format

opcodes	* po/es.po: Fix printf format

sim	* arm/armos.c: Fix printf format
	* ppc/emul_netbsd.c: Fix printf format
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
2020-10-22 12:00:10 +01:00
Nick Clifton
5962451351 Work around problem in DWARF decoding library which can result in attempts to read arbitrary bytes as if they were an LEB128 encoded value.
* dwarf.c (skip_attr_bytes): Accept DWARF versions higher than 4
	when processing the DW_FORM_ref_addr form.
	Skip bytes in DW_FORM_block and DW_FORM_exprloc forms.
	Handle DW_FORM_indirect.
	(get_type_signedness): Allow a limited amount of recursion.
	Do not attempt to decode types that use the DW_FORM_ref_addr form.
	(read_and_display_attr_value): 	Do not attempt to decode types
	that use the DW_FORM_ref_addr form.
2020-10-21 17:42:42 +01:00
Alan Modra
b9e920ecd6 readelf.c display_lto_symtab offset outside bounds of constant string
Using gcc-10 or current mainline gcc, binutils configured with
--disable-nls results in:

readelf.c: In function 'display_lto_symtab':
readelf.c:12283:26: error: offset '17' outside bounds of constant string [-Werror=array-bounds]
12283 |   SECTION_NAME (section) + strlen (".gnu.lto_.symtab.")) > 0
      |                          ^

Which is actually a bogus warning in this case because we've already
checked the name string for validity, so SECTION_NAME won't ever be
"<none>", "<no-strings>" or "<corrupt>".  This patch fixes the problem
by making SECTION_NAME simply return the string from the string table.
Other places also shouldn't be trying to match any of the error
strings against a section name, so fix them too.

	* readelf.c: Delete whitespace at end of line throughout.
	(SECTION_NAME, SECTION_NAME_VALID): New.
	(SECTION_NAME_PRINT): Rename from SECTION_NAME.  Formatting.
	(printable_section_name, dump_relocations): Use SECTION_NAME_PRINT.
	(process_section_headers, process_section_groups): Likewise.
	(shdr_to_ctf_sect): Likewise.
	(find_section, find_section_in_set): Use SECTION_NAME_VALID.
	(ia64_process_unwind, hppa_process_unwind): Likewise.
	(display_debug_section, initialise_dumps_byname): Likewise.
	(process_lto_symbol_tables): Likewise.  Check trailing period of
	lto symbol table names.
	(display_lto_symtab): Use sizeof instead of strlen.
2020-10-20 18:03:19 +10:30
Nelson Chu
ce786647f0 binutils: Add myself as RISC-V co-maintainer.
binutils/
	* MAINTAINERS (RISC-V): Add myself as RISC-V co-maintainer.
2020-10-20 12:34:36 +08:00
Nick Clifton
0f03783c8e Readelf: Add --lto-syms option to display LTO symbol tables.
* readelf.c (do_lto_syms): New local.
	(long_option_values): Add OPTION_LTO_SYMS.
	(options): Add --lto-syms.
	(usage): Mention the new option.
	(parse_args): Parse the new option.
	(get_lto_kind): New function.
	(get_lto_visibility): New function.
	(get_lto_sym_type): New function.
	(display_lto_symtab): New function - displays the contents of an
	LTo symbol table section.
	(process_lto_symbol_tables): New functions.  Calls
	dipslay_lto_symtab on any LTO symbol table section.
	(process_object_file): Call process_lto_symbol_tables.
	* doc/binutils.texi: Document the new option.
	* NEWS: Mention the new feature.
2020-10-19 15:27:58 +01:00
H.J. Lu
32930e4edb x86: Support GNU_PROPERTY_X86_ISA_1_V[234] marker
GCC 11 supports -march=x86-64-v[234] to enable x86 micro-architecture ISA
levels:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97250

Update GNU_PROPERTY_X86_ISA_1_XXX macros:

https://gitlab.com/x86-psABIs/x86-64-ABI/-/merge_requests/13

in x86 ELF binaries to indicate that micro-architecture ISA levels
required to execute the binary:

 #define GNU_PROPERTY_X86_ISA_1_NEEDED (GNU_PROPERTY_X86_UINT32_OR_LO + 2)
 #define GNU_PROPERTY_X86_ISA_1_USED (GNU_PROPERTY_X86_UINT32_OR_AND_LO + 2)
 #define GNU_PROPERTY_X86_ISA_1_V2 (1U << 0)
 #define GNU_PROPERTY_X86_ISA_1_V3 (1U << 1)
 #define GNU_PROPERTY_X86_ISA_1_V4 (1U << 2)

The previous GNU_PROPERTY_X86_ISA_1_XXX  macros are deprecated and renamed
to GNU_PROPERTY_X86_COMPAT_2_ISA_1_XXX.

In addition to EM_X86_64, GNU_PROPERTY_X86_ISA_1_V[234] marker can be used
by ld.so to detect the x86-64-v4 shared library placed in an x86-64-v2
directory by mistake on an x86-64-v2 machine to avoid crashes on x86-64-v4
instructions.

Add -z x86-64-v[234] linker command line option to mark x86-64-v[234]
ISA level as needed.

Also add

 #define GNU_PROPERTY_X86_FEATURE_2_MASK (1U << 11)

for mask registers.

bfd/

	PR gas/26703
	* elf-linker-x86.h (elf_linker_x86_params): Add isa_level.
	* elfxx-x86.c (_bfd_x86_elf_merge_gnu_properties): Merge
	GNU_PROPERTY_X86_ISA_1_V[234].
	(_bfd_x86_elf_link_setup_gnu_properties): Generate
	GNU_PROPERTY_X86_ISA_1_V[234] for -z x86-64-v[234].

binutils/

	PR gas/26703
	* readelf.c (decode_x86_compat_2_isa): New function.
	(decode_x86_isa): Updated for new X86_ISA_1_XXX bits.
	(decode_x86_feature_1): Handle GNU_PROPERTY_X86_FEATURE_2_MASK.
	(print_gnu_property_note): Handle X86_COMPAT_2_ISA_1_USED,
	and X86_COMPAT_2_ISA_1_NEEDED.
	* testsuite/binutils-all/i386/pr21231b.s: Updated to the current
	GNU_PROPERTY_X86_ISA_1_USED and GNU_PROPERTY_X86_ISA_1_NEEDED
	values.
	* testsuite/binutils-all/x86-64/pr21231b.s: Likewise.
	* testsuite/binutils-all/x86-64/pr23494a.s: Likewise.
	* testsuite/binutils-all/x86-64/pr23494b.s: Likewise.
	* testsuite/binutils-all/x86-64/pr23494c.s: Likewise.
	* testsuite/binutils-all/i386/empty.d: Updated.
	* testsuite/binutils-all/i386/ibt.d: Likewise.
	* testsuite/binutils-all/i386/pr21231a.d: Likewise.
	* testsuite/binutils-all/i386/pr21231b.d: Likewise.
	* testsuite/binutils-all/i386/shstk.d: Likewise.
	* testsuite/binutils-all/x86-64/empty-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/empty.d: Likewise.
	* testsuite/binutils-all/x86-64/ibt-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/ibt.d: Likewise.
	* testsuite/binutils-all/x86-64/pr21231a.d: Likewise.
	* testsuite/binutils-all/x86-64/pr21231b.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494a-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494a.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494c-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494c.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494d-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494d.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494e-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494e.d: Likewise.
	* testsuite/binutils-all/x86-64/shstk-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/shstk.d: Likewise.

gas/

	PR gas/26703
	* config/tc-i386.c (xstate): Add xstate_mask.
	(md_assemble): Check i.types[j], instead of i.tm.operand_types[j],
	for xstate.  Set xstate_mask, instead of xstate_zmm, for RegMask.
	(output_insn): Update for GNU_PROPERTY_X86_ISA_1_V[234].  Update
	xstate for mask register and VSIB.
	* testsuite/gas/i386/i386.exp: Run more GNU_PROPERTY tests.
	* testsuite/gas/i386/property-1.s: Updated to the current
	GNU_PROPERTY_X86_ISA_1_USED value.
	* testsuite/gas/i386/property-2.s: Only keep cmove.
	* testsuite/gas/i386/property-3.s: Changed to addsubpd.
	* testsuite/gas/i386/property-1.d: Updated.
	* testsuite/gas/i386/property-2.d: Likewise.
	* testsuite/gas/i386/property-3.d: Likewise.
	* testsuite/gas/i386/property-4.d: Likewise.
	* testsuite/gas/i386/property-5.d: Likewise.
	* testsuite/gas/i386/property-6.d: Likewise.
	* testsuite/gas/i386/x86-64-property-1.d: Likewise.
	* testsuite/gas/i386/x86-64-property-2.d: Likewise.
	* testsuite/gas/i386/x86-64-property-3.d: Likewise.
	* testsuite/gas/i386/x86-64-property-4.d: Likewise.
	* testsuite/gas/i386/x86-64-property-5.d: Likewise.
	* testsuite/gas/i386/x86-64-property-6.d: Likewise.
	* testsuite/gas/i386/x86-64-property-7.d: Likewise.
	* testsuite/gas/i386/x86-64-property-8.d: Likewise.
	* testsuite/gas/i386/x86-64-property-9.d: Likewise.
	* testsuite/gas/i386/property-11.d: New file.
	* testsuite/gas/i386/property-11.s: Likewise.
	* testsuite/gas/i386/property-12.d: Likewise.
	* testsuite/gas/i386/property-12.s: Likewise.
	* testsuite/gas/i386/property-13.d: Likewise.
	* testsuite/gas/i386/property-13.s: Likewise.
	* testsuite/gas/i386/x86-64-property-11.d: Likewise.
	* testsuite/gas/i386/x86-64-property-12.d: Likewise.
	* testsuite/gas/i386/x86-64-property-13.d: Likewise.
	* testsuite/gas/i386/x86-64-property-14.d: Likewise.
	* testsuite/gas/i386/x86-64-property-14.s: Likewise.

include/

	PR gas/26703
	* elf/common.h (GNU_PROPERTY_X86_ISA_1_USED): Renamed to ...
	(GNU_PROPERTY_X86_COMPAT_2_ISA_1_USED): This.
	(GNU_PROPERTY_X86_ISA_1_NEEDED): Renamed to ...
	(GNU_PROPERTY_X86_COMPAT_2_ISA_1_NEEDED): This.
	(GNU_PROPERTY_X86_ISA_1_XXX): Renamed to ...
	(GNU_PROPERTY_X86_COMPAT_2_ISA_1_XXX): This.
	(GNU_PROPERTY_X86_ISA_1_NEEDED): New.
	(GNU_PROPERTY_X86_ISA_1_USED): Likewise.
	(GNU_PROPERTY_X86_ISA_1_V2): Likewise.
	(GNU_PROPERTY_X86_ISA_1_V3): Likewise.
	(GNU_PROPERTY_X86_ISA_1_V4): Likewise.
	(GNU_PROPERTY_X86_FEATURE_2_MASK): Likewise.

ld/

	PR gas/26703
	* NEWS: Mention -z x86-64-v[234].
	* ld.texi: Document -z x86-64-v[234].
	* emulparams/elf32_x86_64.sh: Use x86-64-level.sh.
	* emulparams/elf_i386.sh: Likewise.
	* emulparams/elf_x86_64.sh: Likewise.
	* emulparams/x86-64-level.sh: New file.
	* testsuite/ld-elf/x86-feature-1a.rd: Update.
	* testsuite/ld-elf/x86-feature-1b.rd: Likewise.
	* testsuite/ld-elf/x86-feature-1c.rd: Likewise.
	* testsuite/ld-elf/x86-feature-1d.rd: Likewise.
	* testsuite/ld-elf/x86-feature-1e.rd: Likewise.
	* testsuite/ld-i386/pr23372c.d: Likewise.
	* testsuite/ld-i386/pr23486c.d: Likewise.
	* testsuite/ld-i386/pr23486d.d: Likewise.
	* testsuite/ld-i386/pr24322a.d: Likewise.
	* testsuite/ld-i386/pr24322b.d: Likewise.
	* testsuite/ld-i386/property-1a.r: Likewise.
	* testsuite/ld-i386/property-2a.r: Likewise.
	* testsuite/ld-i386/property-3.r: Likewise.
	* testsuite/ld-i386/property-3a.r: Likewise.
	* testsuite/ld-i386/property-4.r: Likewise.
	* testsuite/ld-i386/property-4a.r: Likewise.
	* testsuite/ld-i386/property-5.r: Likewise.
	* testsuite/ld-i386/property-5a.r: Likewise.
	* testsuite/ld-i386/property-7a.r: Likewise.
	* testsuite/ld-i386/property-x86-3.d: Likewise.
	* testsuite/ld-i386/property-x86-4a.d: Likewise.
	* testsuite/ld-i386/property-x86-5.d: Likewise.
	* testsuite/ld-i386/property-x86-cet1.d: Likewise.
	* testsuite/ld-i386/property-x86-cet2a.d: Likewise.
	* testsuite/ld-i386/property-x86-cet5a.d: Likewise.
	* testsuite/ld-i386/property-x86-cet5b.d: Likewise.
	* testsuite/ld-i386/property-x86-ibt1a.d: Likewise.
	* testsuite/ld-i386/property-x86-ibt1b.d: Likewise.
	* testsuite/ld-i386/property-x86-ibt2.d: Likewise.
	* testsuite/ld-i386/property-x86-ibt3a.d: Likewise.
	* testsuite/ld-i386/property-x86-ibt3b.d: Likewise.
	* testsuite/ld-i386/property-x86-ibt4.d: Likewise.
	* testsuite/ld-i386/property-x86-ibt5.d: Likewise.
	* testsuite/ld-i386/property-x86-shstk1a.d: Likewise.
	* testsuite/ld-i386/property-x86-shstk1b.d: Likewise.
	* testsuite/ld-i386/property-x86-shstk2.d: Likewise.
	* testsuite/ld-i386/property-x86-shstk3a.d: Likewise.
	* testsuite/ld-i386/property-x86-shstk3b.d: Likewise.
	* testsuite/ld-i386/property-x86-shstk4.d: Likewise.
	* testsuite/ld-i386/property-x86-shstk5.d: Likewise.
	* testsuite/ld-x86-64/pr23372c-x32.d: Likewise.
	* testsuite/ld-x86-64/pr23372c.d: Likewise.
	* testsuite/ld-x86-64/pr23486c.d: Likewise.
	* testsuite/ld-x86-64/pr23486d-x32.d: Likewise.
	* testsuite/ld-x86-64/pr23486d.d: Likewise.
	* testsuite/ld-x86-64/pr24322a-x32.d: Likewise.
	* testsuite/ld-x86-64/pr24322a.d: Likewise.
	* testsuite/ld-x86-64/pr24322b-x32.d: Likewise.
	* testsuite/ld-x86-64/pr24322b.d: Likewise.
	* testsuite/ld-x86-64/pr24458a-x32.d: Likewise.
	* testsuite/ld-x86-64/pr24458a.d: Likewise.
	* testsuite/ld-x86-64/pr24458b-x32.d: Likewise.
	* testsuite/ld-x86-64/pr24458b.d: Likewise.
	* testsuite/ld-x86-64/pr24458c-x32.d: Likewise.
	* testsuite/ld-x86-64/pr24458c.d: Likewise.
	* testsuite/ld-x86-64/property-1a.r: Likewise.
	* testsuite/ld-x86-64/property-2a.r: Likewise.
	* testsuite/ld-x86-64/property-3.r: Likewise.
	* testsuite/ld-x86-64/property-3a.r: Likewise.
	* testsuite/ld-x86-64/property-4.r: Likewise.
	* testsuite/ld-x86-64/property-4a.r: Likewise.
	* testsuite/ld-x86-64/property-5.r: Likewise.
	* testsuite/ld-x86-64/property-5a.r: Likewise.
	* testsuite/ld-x86-64/property-7a.r: Likewise.
	* testsuite/ld-x86-64/property-x86-3-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-3.d: Likewise.
	* testsuite/ld-x86-64/property-x86-4a-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-4a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-5-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-5.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet1-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet1.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet2a-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet2a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet5a-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet5a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet5b-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-cet5b.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt1a-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt1a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt1b-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt1b.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt2-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt2.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt3a-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt3a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt3b-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt3b.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt4-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt4.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt5-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt5.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk1a-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk1a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk1b-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk1b.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk2-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk2.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk3a-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk3a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk3b-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk3b.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk4-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk4.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk5-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk5.d: Likewise.
	* testsuite/ld-i386/i386.exp: Run property-x86-6,
	property-x86-isa1, property-x86-isa2 and property-x86-isa3.
	* testsuite/ld-i386/property-x86-1.S: Updated to the current
	GNU_PROPERTY_X86_ISA_1_USED and GNU_PROPERTY_X86_ISA_1_NEEDED
	values.
	* testsuite/ld-i386/property-x86-2.S: Likewise.
	* testsuite/ld-i386/property-x86-3.s: Likewise.
	* testsuite/ld-x86-64/pr23372d.s: Likewise.
	* testsuite/ld-x86-64/pr23372e.s: Likewise.
	* testsuite/ld-x86-64/pr23372f.s: Likewise.
	* testsuite/ld-x86-64/pr23486c.s: Likewise.
	* testsuite/ld-x86-64/pr23486d.s: Likewise.
	* testsuite/ld-x86-64/property-x86-1.S: Likewise.
	* testsuite/ld-x86-64/property-x86-2.S: Likewise.
	* testsuite/ld-x86-64/property-x86-3.s: Likewise.
	* testsuite/ld-x86-64/property-x86-5a.s: Likewise.
	* testsuite/ld-x86-64/property-x86-5b.s: Likewise.
	* testsuite/ld-i386/property-x86-6.d: New file.
	* testsuite/ld-i386/property-x86-isa1.d: Likewise.
	* testsuite/ld-i386/property-x86-isa2.d: Likewise.
	* testsuite/ld-i386/property-x86-isa3.d: Likewise.
	* testsuite/ld-x86-64/property-x86-6-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-6.d: Likewise.
	* testsuite/ld-x86-64/property-x86-6.s: Likewise.
	* testsuite/ld-x86-64/property-x86-isa1-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-isa1.d: Likewise.
	* testsuite/ld-x86-64/property-x86-isa1.s: Likewise.
	* testsuite/ld-x86-64/property-x86-isa2-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-isa2.d: Likewise.
	* testsuite/ld-x86-64/property-x86-isa3-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-isa3.d: Likewise.
	* testsuite/ld-x86-64/simple.s: Likewise.
	* ld/testsuite/ld-x86-64/x86-64.exp: Run property-x86-6,
	property-x86-6-x32, property-x86-isa1, property-x86-isa1-x32,
	property-x86-isa2, property-x86-isa2-x32, property-x86-isa3-x32
	and property-x86-isa3.
2020-10-09 05:13:26 -07:00
Nick Clifton
0ec992e664 Fix a bug in objcopy/strip's ability to merge notes in multiple same-named sections.
* objcopy.c (copy_object): Compare input and output sections by
	pointer rather than name.
2020-10-06 15:49:40 +01:00
Nick Clifton
1f1845d435 Fix compile time error building windmc, detected by gcc 11.
PR 26698
	* windmc.c (mc_unify_path): Fix typo checking character at end of
	pathname.
2020-10-05 16:09:00 +01:00
Samanta Navarro
0cc79db2b6 Fix spelling mistakes 2020-10-05 14:20:15 +01:00
Mark Wielaard
1c9f770d16 binutils: dwarf.c handle DWARF5 DW_LLE_start_end and DW_LLE_start_length.
display_loclists_list only handled DW_LLE_offset_pair as bounded
location description. Also handle DW_LLE_start_end and DW_LLE_start_lenght.
These don't use the base_address.

binutils/ChangeLog:

      * dwarf.c (display_loclists_list): Handle DW_LLE_start_end and
      DW_LLE_start_length. Only add base_address for DW_LLE_offset_pair.
2020-09-29 14:08:51 +02:00
Alan Modra
5a805384b8 asan: readelf buffer overflow and abort
* elfcomm.c (byte_put_little_endian, byte_put_big_endian): Support
	more field sizes.
	* readelf.c (target_specific_reloc_handling <MSP430>): Limit
	allowed reloc_size.  Don't read_leb128 outside of section.
2020-09-25 11:55:01 +09:30
Mark Wielaard
debd1a62c4 readelf: Show Unit Type for DWARF5
binutils/ChangeLog:

	* dwarf.c (process_debug_info): Print Unit Type for DWARF5.
	* testsuite/binutils-all/dw5.W: Adjust expected output.
	* testsuite/binutils-all/dwarf-attributes.W: Likewise.

gas/ChangeLog:

	* testsuite/gas/elf/dwarf-5-cu.d: Adjust expected output.
2020-09-24 23:13:13 +02:00
Mark Wielaard
ec47b32a85 binutils: Handle DWARF5 DW_FORM_ref_addr and DW_UT_partial.
dwz in DWARF5 mode might produce DW_UT_partial unit types, which are
the same as DW_UT_compile unit types (but start with a DW_TAG_partial_unit)
and it might produce DW_FORM_ref_addr to create a reference between
units. Accept both constructs.

binutils/ChangeLog:

	* dwarf.c (read_and_display_attr_value): Handle DW_FORM_ref_addr
	for dwarf_version 5 just as version 3 and 4 (only 2 is different).
	(process_debug_info): Allow DW_UT_partial.
2020-09-24 22:52:57 +02:00
Nick Clifton
a2ab58313a Document that the lower case 'c' character in nm's output is used to signify a small common.
PR 26662
	* doc/binutils.texi (nm): Document that 'c' is used for small
	common symbols.
2020-09-24 14:23:39 +01:00
Ludovic Court?s
427234c78b Update the binutils documentation to make it clear the the --strip-unneeded option of objcopy and strip implies the --strip-debug option.
* doc/binutils.texi (objcopy, strip): Say that
        '--strip-unneeded' implies '--strip-debug'.
2020-09-21 16:08:55 +01:00
Anatoly Parshintsev
0690f59128 bfd: verilog hex dump backend should handle 64-bit addresses
* verilog.c (verilog_write_address): Properly handle 64-bit
	addresses to avoid truncation of the high part.
2020-09-16 13:17:24 +01:00
Alan Modra
c1229f84a4 Tidy elf_symbol_from
bfd/
	* elf-bfd.h (elf_symbol_from): Remove unused ABFD parameter.
	* elf.c (ignore_section_sym, _bfd_elf_copy_private_symbol_data),
	(swap_out_syms): Adjust elf_symbol_from invocation.
binutils/
	* nm.c (print_symbol): Adjust elf_symbol_from invocation.
	* objcopy.c (is_hidden_symbol): Likewise.
gas/
	* config/obj-elf.c (obj_elf_visibility, elf_frob_symbol): Adjust
	elf_symbol_from invocation.
	* config/tc-aarch64.c (s_variant_pcs): Likewise.
	* config/tc-m68hc11.c (s_m68hc11_mark_symbol): Likewise.
	* config/tc-ppc.c (ppc_elf_localentry, ppc_force_relocation),
	(ppc_fix_adjustable): Likewise.
	* config/tc-xgate.c (xgate_frob_symbol): Likewise.
ld/
	* plugin.c (asymbol_from_plugin_symbol): Adjust elf_symbol_from
	invocation.
opcodes/
	* ppc-dis.c (ppc_symbol_is_valid): Adjust elf_symbol_from invocation.
2020-09-16 16:41:33 +09:30
Nick Clifton
5b3eb5eda8 Add note about creating a bugzilla tag for a point release.
* README-how-to-make-a-release (https): Add a reminder to create a
	new Bugzilla tag for the point release, once it has been published.
2020-09-15 11:32:34 +01:00
H.J. Lu
8d58ed37f1 x86: Add NT_X86_CET note
Define NT_X86_CET which is the proposed note for x86 CET state to support
Intel CET in Linux kernel.  Double check it after Intel CET patches have
been merged into Linux kernel.

binutils/

	* readelf.c (get_note_type): Support NT_X86_CET.

include/

	* elf/common.h (NT_X86_CET): New.
2020-09-11 05:52:06 -07:00
Nick Clifton
ce139cd560 Fix the debuglink following code to recursively load links found in the newly loaded debug info.
PR 26595
	* dwarf.c (load_separate_debug_info): Return NULL rather than
	FALSE in error situations.
	(load_separate_debug_file): Move code to load debug links to ...
	(check_for_and_load_links): ... here.  New function.  Load
	separate debug information pointed to by debuglink and
	debugaltlink sections.  Recursively scan newly loaded debug
	information for more links and load them too.
2020-09-11 13:30:56 +01:00
Alan Modra
dfbee68088 PR26578, memory leak in parse_gnu_debugaltlink
The associated check function doesn't do anything with its "data"
param, so nothing to adjust there.

	PR 26578
	* dwarf.c (parse_gnu_debugaltlink): Don't alloc build_id_data.
	(load_separate_debug_files): Use a stack var for build_id_data.
2020-09-09 16:38:36 +09:30
H.J. Lu
790147a9e9 Pass --disable-reloc-section on PE targets for PR 25662 test
Pass --disable-reloc-section on PE targets for PR 25662 test since

commit 514b4e191d

Author: Jeremy Drake <sourceware-bugzilla@jdrake.com>
Date:   Thu Aug 27 12:58:27 2020 +0100

    Change the default characteristics of DLLs built by the linker to more secure settings.

defaulted to --enable-reloc-section.

	PR ld/26587
	* testsuite/binutils-all/objcopy.exp: Pass --disable-reloc-section
	to ld on PE targets for PR 25662 test.
2020-09-08 10:01:45 -07:00
Jozef Lawrynowicz
7d81bc937c MSP430: Support relocations for subtract expressions in .uleb128 directives
Link-time relaxations of branches are common for MSP430, given that GCC
can generate pessimal branch instructions, and the
-mcode-region=either/-mdata-region=either options to shuffle sections
can further change the type of branch instruction required.

These relaxations can result in invalid code when .uleb128
directives, used in the .gcc_except_table section, are used to calculate
the distance between two labels. A value for the .uleb128 directive is
calculated at assembly-time, and can't be updated at link-time, even if
relaxation causes the distance between the labels to change.

This patch adds relocations for subtract expressions in .uleb128
directives, to allow the linker to re-calculate the value of these
expressions after relaxation has been performed.

bfd/ChangeLog:
	* bfd-in2.h (bfd_reloc_code_real): Add
	BFD_RELOC_MSP430_{SET,SUB}_ULEB128.
	* elf32-msp430.c (msp430_elf_ignore_reloc): New.
	(elf_msp430_howto_table): Add R_MSP430{,X}_GNU_{SET,SUB}_ULEB128.
	(msp430_reloc_map): Add R_MSP430_GNU_{SET,SUB}_ULEB128.
	(msp430x_reloc_map): Add R_MSP430X_GNU_{SET,SUB}_ULEB128.
	(write_uleb128): New.
	(msp430_final_link_relocate): Handle R_MSP430{,X}_GNU_{SET,SUB}_ULEB128.
	* libbfd.c (_bfd_write_unsigned_leb128): New.
	* libbfd.h (_bfd_write_unsigned_leb128): New prototype.
	Add BFD_RELOC_MSP430_{SET,SUB}_ULEB128.
	* reloc.c: Document BFD_RELOC_MSP430_{SET,SUB}_ULEB128.

binutils/ChangeLog:
	* readelf.c (target_specific_reloc_handling): Handle
	R_MSP430{,X}_GNU_{SET,SUB}_ULEB128.

gas/ChangeLog:
	* config/tc-msp430.c (msp430_insert_uleb128_fixes): New.
	(msp430_md_end): Call msp430_insert_uleb128_fixes.

include/ChangeLog:
	* elf/msp430.h (elf_msp430_reloc_type): Add
	R_MSP430_GNU_{SET,SUB}_ULEB128.
	(elf_msp430x_reloc_type): Add R_MSP430X_GNU_{SET,SUB}_ULEB128.

ld/ChangeLog:
	* testsuite/ld-msp430-elf/msp430-elf.exp: Run new tests.
	* testsuite/ld-msp430-elf/uleb128.s: New test.
	* testsuite/ld-msp430-elf/uleb128_430.d: New test.
	* testsuite/ld-msp430-elf/uleb128_430x.d: New test.
2020-09-08 16:18:38 +01:00
Alan Modra
839f41a323 ubsan: objdump.c:3009 negation of -2147483648
* objdump.c (disassemble_bytes): Use an unsigned type for "addend".
2020-09-02 16:30:42 +09:30
Alan Modra
54b8331d0b readelf: ubsan: shift exponent 32 is too large
When compiled on a 32-bit host, a temp var is too small for possible
64-bit values to be calculated.

	* readelf.c (print_gnu_build_attribute_name): Make "bytes"
	unsigned long long.
2020-08-30 20:49:32 +09:30
Nick Clifton
08d7da7dc9 Fix a bogus error message from the DWARF LEB129 decoder when trying to read a signed LEB128 value containing the largest possible signed negative integer value.
PR 26548
	* dwarf.c (read_leb128): When checking for overflow of a signed
	read, use a signed shift.
2020-08-28 16:04:49 +01:00
Cooper Qu
0861f561eb CSKY: Support attribute section.
bfd
        * elf32-csky.c (csky_archs): Fix arch names.
        (csky_find_arch_with_name): New.
        (elf32_csky_merge_attributes): New.
        (csky_elf_merge_private_bfd_data): Add process of merge
        attribute section.
        (elf32_csky_obj_attrs_arg_type): New.
        (elf32_csky_obj_attrs_handle_unknown): New.
        (elf_backend_obj_attrs_vendor): Define.
        (elf_backend_obj_attrs_section): Define.
        (elf_backend_obj_attrs_arg_type): Define.
        (elf_backend_obj_attrs_section_type): Define.

binutils/
        * readelf.c (get_csky_section_type_name): New.
        (get_section_type_name): Add handler for CSKY.
        (display_csky_attribute): New.
        (process_arch_specific): Add handler for CSKY.
        * testsuite/binutils-all/strip-3.d: Remove .csky.attributes
        section.

elfcpp/
        * elfcpp.h (enum SHT): New enum SHT_CSKY_ATTRIBUTES.

gas/
        * gas/config/tc-csky.c (md_begin): Set attributes.
        (isa_flag): Change type to unsigned 64 bits.
        (struct csky_cpu_info): Likewise.
        (struct csky_macro_info): Likewise.
        (set_csky_attribute): New.
        * testsuite/gas/csky/802j.d: Ignore .csky.attributes section.
        * testsuite/gas/csky/all.d: Likewise.
        * testsuite/gas/csky/bsr1.d: Likewise.
        * testsuite/gas/csky/csky_vdsp.d: Likewise.
        * testsuite/gas/csky/cskyv2_all.d: Likewise.
        * testsuite/gas/csky/cskyv2_ck803r2.d: Likewise.
        * testsuite/gas/csky/cskyv2_ck860.d: Likewise.
        * testsuite/gas/csky/cskyv2_dsp.d: Likewise.
        * testsuite/gas/csky/cskyv2_elrw.d: Likewise.
        * testsuite/gas/csky/cskyv2_float.d: Likewise.
        * testsuite/gas/csky/enhance_dsp.d: Likewise.
        * testsuite/gas/csky/java.d: Likewise.
        * testsuite/gas/csky/v1_float.d: Likewise.
        * testsuite/gas/csky/v2_float_part1.d: Likewise.
        * testsuite/gas/csky/v2_float_part2.d: Likewise.
        * testsuite/gas/csky/v2_tls_gd.d: Likewise.
        * testsuite/gas/csky/v2_tls_ie.d: Likewise.
        * testsuite/gas/csky/v2_tls_ld.d: Likewise.
        * testsuite/gas/csky/v2_tls_le.d: Likewise.
        * testsuite/gas/elf/elf.exp: Add handler for CSKY.
        * testsuite/gas/elf/section2.e-csky: New.

include/
        * elf/csky.h (SHT_CSKY_ATTRIBUTES): Define.
        (Tag_CSKY_ARCH_NAME): New enum constant.
        (Tag_CSKY_CPU_NAME): Likewise.
        (Tag_CSKY_ISA_FLAGS): Likewise.
        (Tag_CSKY_DSP_VERSION): Likewise.
        (Tag_CSKY_VDSP_VERSION): Likewise.
        (Tag_CSKY_FPU_VERSION): Likewise.
        (Tag_CSKY_FPU_ABI): Likewise.
        (Tag_CSKY_FPU_ROUNDING): Likewise.
        (Tag_CSKY_FPU_DENORMAL): Likewise.
        (Tag_CSKY_FPU_Exception): Likewise.
        (Tag_CSKY_FPU_NUMBER_MODULE): Likewise.
        (Tag_CSKY_FPU_HARDFP): Likewise.
        (Tag_CSKY_MAX): Likewise.
        (VAL_CSKY_DSP_VERSION_EXTENSION): Likewise.
        (VAL_CSKY_DSP_VERSION_2): Likewise.
        (VAL_CSKY_VDSP_VERSION_1): Likewise.
        (VAL_CSKY_VDSP_VERSION_2): Likewise.
        (VAL_CSKY_FPU_ABI_SOFT): Likewise.
        (VAL_CSKY_FPU_ABI_SOFTFP): Likewise.
        (VAL_CSKY_FPU_ABI_HARD): Likewise.
        (VAL_CSKY_FPU_HARDFP_HALF): Likewise.
        (VAL_CSKY_FPU_HARDFP_SINGLE): Likewise.
        (VAL_CSKY_FPU_HARDFP_DOUBLE): Likewise.
        * opcode/csky.h (CSKY_ISA_VDSP_V2): Define.
        CSKYV1_ISA_E1: Change to long constant type.
        CSKYV2_ISA_E1: Likewise.
        CSKYV2_ISA_1E2: Likewise.
        CSKYV2_ISA_2E3: Likewise.
        CSKYV2_ISA_3E7: Likewise.
        CSKYV2_ISA_7E10: Likewise.
        CSKYV2_ISA_3E3R1: Likewise.
        CSKYV2_ISA_3E3R2: Likewise.
        CSKYV2_ISA_10E60: Likewise.
        CSKY_ISA_TRUST: Likewise.
        CSKY_ISA_CACHE: Likewise.
        CSKY_ISA_NVIC: Likewise.
        CSKY_ISA_CP: Likewise.
        CSKY_ISA_MP: Likewise.
        CSKY_ISA_MP_1E2: Likewise.
        CSKY_ISA_JAVA: Likewise.
        CSKY_ISA_MAC: Likewise.
        CSKY_ISA_MAC_DSP: Likewise.
        CSKY_ISA_DSP: Likewise.
        CSKY_ISA_DSP_1E2: Likewise.
        CSKY_ISA_DSP_ENHANCE: Likewise.
        CSKY_ISA_FLOAT_E1: Likewise.
        CSKY_ISA_FLOAT_1E2: Likewise.
        CSKY_ISA_FLOAT_1E3: Likewise.
        CSKY_ISA_FLOAT_3E4: Likewise.
        CSKY_ISA_VDSP: Likewise.

ld/
        * emulparams/cskyelf.sh: Support attribute section.
        * testsuite/ld-csky/tls-le-v1.d: Match .csky.attributes section.
        * ld/testsuite/ld-csky/tls-le.d: Likewise.
        * testsuite/ld-elf/non-contiguous.ld: Ignore .csky.attributes
        section.

opcodes/
        * csky-dis.c (CSKY_DEFAULT_ISA): Define.
        (csky_dis_info): Add member isa.
        (csky_find_inst_info): Skip instructions that do not belong to
        current CPU.
        (csky_get_disassembler): Get infomation from attribute section.
        (print_insn_csky): Set defualt ISA flag.
        * csky.h (CSKY_ISA_VDSP_2): Rename from CSKY_ISA_VDSP_V2.
        * csky-opc.h (struct csky_opcode): Change isa_flag16 and
        isa_flag32'type to unsigned 64 bits.
2020-08-28 17:23:24 +08:00
Jozef Lawrynowicz
b019121604 readelf: MSP430: Fix incorrect usage of "msp430x" in function names
The "X" in "MSP430X" indicates an extension to the original MSP430 ISA, but
these functions are generically used for all MSP430 ISAs, so the names should
not use the "X" suffix.

binutils/ChangeLog:

	* readelf.c (get_msp430x_section_type_name): Rename to ...
	(get_msp430_section_type_name): ... this.
	(get_section_type_name): Use get_msp430_section_type_name.
	(display_msp430x_attribute): Rename to ...
	(display_msp430_attribute): ... this.
	(process_arch_specific): Use display_msp430_attribute.
2020-08-27 20:58:03 +01:00
John David Anglin
9e7ed8b080 Fix PR binutils/26356 on hppa*-*-hpux*.
PR 26356
	* som.c (som_bfd_copy_private_section_data): Issue error when a
	subspace is specified without its containing space.
	* testsuite/binutils-all/objcopy.exp (objcopy --reverse-bytes): Add
	"-j $PRIVATE$" to command on hppa*-*-hpux*.
	* testsuite/lib/utils-lib.exp (default_binutils_run): Remove existing
	dollar-sign quotes before quoting.  Do this prior to generating log
	output.
2020-08-27 15:25:03 +00:00
Ralf Habacker
6b5473c97e Corrects the broken line number incrementation in the Windows resource parser
When the tokens MCLINE, MCENDLINE, and MCCOMMENT were created, the
line number was not increased, which led to an incorrect value in
the error output.

	PR 26088
	* mclex.c (skip_until_eol): if eol was found, increment line number
2020-08-27 15:59:53 +01:00
Nick Alcock
5e9b84f7a2 binutils, ld: dequote libctf error messages
These are not identifiers and should not be quoted.  (Also, quoting them
just looks odd.)

Adjust diagnostics tests accordingly.

binutils/ChangeLog
2020-08-27  Nick Alcock  <nick.alcock@oracle.com>

	* objdump.c (dump_ctf_errs): Unquote CTF error messages.
	* readelf.c (dump_ctf_errs): Likewise.

ld/ChangeLog
2020-08-27  Nick Alcock  <nick.alcock@oracle.com>

	* ldlang.c (dump_ctf_errs): Unquote CTF error messages.
	(ldlang_open_ctf): Likewise.
	(lang_merge_ctf): Likewise.
	(lang_write_ctf): Likewise.
	* testsuite/ld-ctf/diag-ctf-version-f.d: Adjust.
	* testsuite/ld-ctf/diag-cttname-invalid.d: Adjust.
	* testsuite/ld-ctf/diag-decompression-failure.d: Adjust.
	* testsuite/ld-ctf/diag-parname.d: Adjust.
	* testsuite/ld-ctf/diag-unsupported-flag.d: Adjust.
	* testsuite/ld-ctf/diag-wrong-magic-number-mixed.d: Adjust.
	* testsuite/ld-ctf/diag-wrong-magic-number.d: Adjust.
2020-08-27 13:16:39 +01:00
Nick Alcock
926c9e7665 libctf, binutils, include, ld: gettextize and improve error handling
This commit follows on from the earlier commit "libctf, ld, binutils:
add textual error/warning reporting for libctf" and converts every error
in libctf that was reported using ctf_dprintf to use ctf_err_warn
instead, gettextizing them in the process, using N_() where necessary to
avoid doing gettext calls unless an error message is actually generated,
and rephrasing some error messages for ease of translation.

This requires a slight change in the ctf_errwarning_next API: this API
is public but has not been in a release yet, so can still change freely.
The problem is that many errors are emitted at open time (whether
opening of a CTF dict, or opening of a CTF archive): the former of these
throws away its incompletely-initialized ctf_file_t rather than return
it, and the latter has no ctf_file_t at all. So errors and warnings
emitted at open time cannot be stored in the ctf_file_t, and have to go
elsewhere.

We put them in a static local in ctf-subr.c (which is not very
thread-safe: a later commit will improve things here): ctf_err_warn with
a NULL fp adds to this list, and the public interface
ctf_errwarning_next with a NULL fp retrieves from it.

We need a slight exception from the usual iterator rules in this case:
with a NULL fp, there is nowhere to store the ECTF_NEXT_END "error"
which signifies the end of iteration, so we add a new err parameter to
ctf_errwarning_next which is used to report such iteration-related
errors.  (If an fp is provided -- i.e., if not reporting open errors --
this is optional, but even if it's optional it's still an API change.
This is actually useful from a usability POV as well, since
ctf_errwarning_next is usually called when there's been an error, so
overwriting the error code with ECTF_NEXT_END is not very helpful!
So, unusually, ctf_errwarning_next now uses the passed fp for its
error code *only* if no errp pointer is passed in, and leaves it
untouched otherwise.)

ld, objdump and readelf are adapted to call ctf_errwarning_next with a
NULL fp to report open errors where appropriate.

The ctf_err_warn API also has to change, gaining a new error-number
parameter which is used to add the error message corresponding to that
error number into the debug stream when LIBCTF_DEBUG is enabled:
changing this API is easy at this point since we are already touching
all existing calls to gettextize them.  We need this because the debug
stream should contain the errno's message, but the error reported in the
error/warning stream should *not*, because the caller will probably
report it themselves at failure time regardless, and reporting it in
every error message that leads up to it leads to a ridiculous chattering
on failure, which is likely to end up as ridiculous chattering on stderr
(trimmed a bit):

CTF error: `ld/testsuite/ld-ctf/A.c (0): lookup failure for type 3: flags 1: The parent CTF dictionary is unavailable'
CTF error: `ld/testsuite/ld-ctf/A.c (0): struct/union member type hashing error during type hashing for type 80000001, kind 6: The parent CTF dictionary is unavailable'
CTF error: `deduplicating link variable emission failed for ld/testsuite/ld-ctf/A.c: The parent CTF dictionary is unavailable'
ld/.libs/lt-ld-new: warning: CTF linking failed; output will have no CTF section: `The parent CTF dictionary is unavailable'

We only need to be told that the parent CTF dictionary is unavailable
*once*, not over and over again!

errmsgs are still emitted on warning generation, because warnings do not
usually lead to a failure propagated up to the caller and reported
there.

Debug-stream messages are not translated.  If translation is turned on,
there will be a mixture of English and translated messages in the debug
stream, but rather that than burden the translators with debug-only
output.

binutils/ChangeLog
2020-08-27  Nick Alcock  <nick.alcock@oracle.com>

	* objdump.c (dump_ctf_archive_member): Move error-
	reporting...
	(dump_ctf_errs): ... into this separate function.
	(dump_ctf): Call it on open errors.
	* readelf.c (dump_ctf_archive_member): Move error-
	reporting...
	(dump_ctf_errs): ... into this separate function.  Support
	calls with NULL fp. Adjust for new err parameter to
	ctf_errwarning_next.
	(dump_section_as_ctf): Call it on open errors.

include/ChangeLog
2020-08-27  Nick Alcock  <nick.alcock@oracle.com>

	* ctf-api.h (ctf_errwarning_next): New err parameter.

ld/ChangeLog
2020-08-27  Nick Alcock  <nick.alcock@oracle.com>

	* ldlang.c (lang_ctf_errs_warnings): Support calls with NULL fp.
	Adjust for new err parameter to ctf_errwarning_next.  Only
	check for assertion failures when fp is non-NULL.
	(ldlang_open_ctf): Call it on open errors.
	* testsuite/ld-ctf/ctf.exp: Always use the C locale to avoid
	breaking the diags tests.

libctf/ChangeLog
2020-08-27  Nick Alcock  <nick.alcock@oracle.com>

	* ctf-subr.c (open_errors): New list.
	(ctf_err_warn): Calls with NULL fp append to open_errors.  Add err
	parameter, and use it to decorate the debug stream with errmsgs.
	(ctf_err_warn_to_open): Splice errors from a CTF dict into the
	open_errors.
	(ctf_errwarning_next): Calls with NULL fp report from open_errors.
	New err param to report iteration errors (including end-of-iteration)
	when fp is NULL.
	(ctf_assert_fail_internal): Adjust ctf_err_warn call for new err
	parameter: gettextize.
	* ctf-impl.h (ctfo_get_vbytes): Add ctf_file_t parameter.
	(LCTF_VBYTES): Adjust.
	(ctf_err_warn_to_open): New.
	(ctf_err_warn): Adjust.
	(ctf_bundle): Used in only one place: move...
	* ctf-create.c: ... here.
	(enumcmp): Use ctf_err_warn, not ctf_dprintf, passing the err number
	down as needed.  Don't emit the errmsg.  Gettextize.
	(membcmp): Likewise.
	(ctf_add_type_internal): Likewise.
	(ctf_write_mem): Likewise.
	(ctf_compress_write): Likewise.  Report errors writing the header or
	body.
	(ctf_write): Likewise.
	* ctf-archive.c (ctf_arc_write_fd): Use ctf_err_warn, not
	ctf_dprintf, and gettextize, as above.
	(ctf_arc_write): Likewise.
	(ctf_arc_bufopen): Likewise.
	(ctf_arc_open_internal): Likewise.
	* ctf-labels.c (ctf_label_iter): Likewise.
	* ctf-open-bfd.c (ctf_bfdclose): Likewise.
	(ctf_bfdopen): Likewise.
	(ctf_bfdopen_ctfsect): Likewise.
	(ctf_fdopen): Likewise.
	* ctf-string.c (ctf_str_write_strtab): Likewise.
	* ctf-types.c (ctf_type_resolve): Likewise.
	* ctf-open.c (get_vbytes_common): Likewise. Pass down the ctf dict.
	(get_vbytes_v1): Pass down the ctf dict.
	(get_vbytes_v2): Likewise.
	(flip_ctf): Likewise.
	(flip_types): Likewise. Use ctf_err_warn, not ctf_dprintf, and
	gettextize, as above.
	(upgrade_types_v1): Adjust calls.
	(init_types): Use ctf_err_warn, not ctf_dprintf, as above.
	(ctf_bufopen_internal): Likewise. Adjust calls. Transplant errors
	emitted into individual dicts into the open errors if this turns
	out to be a failed open in the end.
	* ctf-dump.c (ctf_dump_format_type): Adjust ctf_err_warn for new err
	argument.  Gettextize.  Don't emit the errmsg.
	(ctf_dump_funcs): Likewise.  Collapse err label into its only case.
	(ctf_dump_type): Likewise.
	* ctf-link.c (ctf_create_per_cu): Adjust ctf_err_warn for new err
	argument.  Gettextize.  Don't emit the errmsg.
	(ctf_link_one_type): Likewise.
	(ctf_link_lazy_open): Likewise.
	(ctf_link_one_input_archive): Likewise.
	(ctf_link_deduplicating_count_inputs): Likewise.
	(ctf_link_deduplicating_open_inputs): Likewise.
	(ctf_link_deduplicating_close_inputs): Likewise.
	(ctf_link_deduplicating): Likewise.
	(ctf_link): Likewise.
	(ctf_link_deduplicating_per_cu): Likewise. Add some missed
	ctf_set_errnos to obscure error cases.
	* ctf-dedup.c (ctf_dedup_rhash_type): Adjust ctf_err_warn for new
	err argument.  Gettextize.  Don't emit the errmsg.
	(ctf_dedup_populate_mappings): Likewise.
	(ctf_dedup_detect_name_ambiguity): Likewise.
	(ctf_dedup_init): Likewise.
	(ctf_dedup_multiple_input_dicts): Likewise.
	(ctf_dedup_conflictify_unshared): Likewise.
	(ctf_dedup): Likewise.
	(ctf_dedup_rwalk_one_output_mapping): Likewise.
	(ctf_dedup_id_to_target): Likewise.
	(ctf_dedup_emit_type): Likewise.
	(ctf_dedup_emit_struct_members): Likewise.
	(ctf_dedup_populate_type_mapping): Likewise.
	(ctf_dedup_populate_type_mappings): Likewise.
	(ctf_dedup_emit): Likewise.
	(ctf_dedup_hash_type): Likewise. Fix a bit of messed-up error
	status setting.
	(ctf_dedup_rwalk_one_output_mapping): Likewise. Don't hide
	unknown-type-kind messages (which signify file corruption).
2020-08-27 13:15:43 +01:00
Nick Alcock
987cf30ad8 libctf, binutils: initial work towards libctf gettextization
We gettextize under our package name, which we change to a more
reasonable 'libctf'.  Our internationalization support is mostly
provided by ctf-intl.h, which is a copy of opcodes/opintl.h with
the non-gettext_noop N_() expansion debracketed to avoid pedantic
compiler warnings.

The libctf error strings returned by ctf_errmsg are marked up for
internationalization.

(We also adjust binutils's Makefile a tiny bit to allow for the
fact that libctf now uses functions from libintl.)

binutils/ChangeLog
2020-08-27  Nick Alcock  <nick.alcock@oracle.com>

	* Makefile.am (readelf_LDADD): Move $(LIBINTL) after $(LIBCTF_NOBFD).
	* Makefile.in: Regenerated.

libctf/ChangeLog
2020-08-27  Nick Alcock  <nick.alcock@oracle.com>

	* configure.ac: Adjust package name to simply 'libctf': arbitrarily
	declare this to be version 1.2.0.
	* Makefile.am (AM_CPPFLAGS): Add @INCINTL@.
	* Makefile.in: Regenerated.
	* configure: Regenerated.
	* ctf-intl.h: New file, lightly modified from opcodes/opintl.h.
	* ctf-impl.h: Include it.
	* ctf-error.r (_ctf_errlist_t): Mark strings as noop-translatable.
	(ctf_errmsg): Actually translate them.
2020-08-27 13:14:10 +01:00
Nick Clifton
3eba3ef344 Add support to readelf for the OpenBSD segment types.
PR 26405
binutils* readelf.c (get_segment_type): Handle OpenBSD segment types.

include	* elf/common.h (PT_OPENBSD_BOOTDATA): Define.
	(PT_OPENBSD_RANDOMIZE): Define.
	(PT_OPENBSD_WXNEEDED): Define.
2020-08-26 15:15:10 +01:00
Alan Modra
a68aba2da7 PR26412 UBSAN: objcopy.c:3026 null pointer fwrite
PR 26412
	* objcopy.c (copy_object): Don't fwrite NULL contents.
2020-08-26 23:23:43 +09:30
Katayama Hirofumi
37f628c34d windres: AUTOCHECKBOX default style must have WS_TABSTOP style
PR 26340
	* rcparse.y (AUTOCHECKBOX): Add WS_TABSTOP to the base style.
2020-08-26 11:57:02 +01:00
Alan Modra
f3da8a96ee gcc-4 -Og false positive "may be used uninitialised"
binutils/
	* readelf.c (dump_section_as_strings) Avoid false positive
	"may be used uninitialised".
gas/
	* config/tc-arm.c (move_or_literal_pool): Avoid false positive
	"may be used uninitialised".
	(opcode_lookup): Likewise.
2020-08-24 13:29:22 +09:30
H.J. Lu
3f2e969923 elf: Keep only one '@' for undefined versioned symbols
The symbol string table in the .symtab section is optional and cosmetic.
Keep only one '@' for undefined versioned symbols, which are defined in
shared objects, in the symbol string table.  Update "nm -D" to display
only one '@' for undefined versioned symbols.

bfd/

	PR ld/26382
	* elflink.c (elf_link_output_symstrtab): Keep only one '@' for
	versioned symbols, which are defined in shared objects, in
	symbol string table.

binutils/

	PR ld/26382
	* nm.c (print_symname): Display only one '@' for undefined
	versioned symbols.
	* doc/binutils.texi: Update nm version information.

ld/

	PR ld/26382
	* testsuite/ld-elf/pr26302.nd: Updated.
	* testsuite/ld-elf/pr26302.rd: New file.
	* testsuite/ld-elf/shared.exp: Add a test for readelf -sW.
2020-08-22 08:32:02 -07:00
Mark Wielaard
02391b8be4 Recognize DW_LANG_C11 in readelf testsuite.
readelf_wi_test checks the DW_AT_LANGUAGE is recognized by matching
against ANSI C. But for the new DWARF5 DW_LANG_C11 readelf simply
prints "C11", not prefixed with ANSI (DW_LANG_C is "non-ANSI C",
DW_LANG_C89 is "ANSI C" and DW_LANG_C99 is "ANSI-C99"). Adjust the
testcase instead of readelf because C11 seems a fine name.

binutils/ChangeLog:

	* testsuite/binutils-all/readelf.exp (readelf_wi_test): Also
	recognize DW_LANG_C11.
2020-08-21 15:16:34 +02:00
Alan Modra
d1ce973eb3 PR26349, FAIL: binutils-all/pr25543 on hpux
The 't' length modifier isn't in SUSv2, unsurprisingly %tx isn't
recognized by older printf implementations.  So even though 't' is
correct for ptrdiff_t we can't use it.  Also, _bfd_int64_high and
_bfd_int64_low disappeared in 2008.

	PR 26349
	* readelf.c (dump_relocations): Use BFD_VMA_FMT to print offset
	and info fields.
	(dump_section_as_strings): Don't use %tx to display offset.
2020-08-19 21:25:47 +09:30
Alan Modra
82fcdb3938 PR26388, objdump debug dump memory leaks
num_debug_info_entries is used not just as a count but also as a flag
(DEBUG_INFO_UNAVAILABLE) after some errors.  That means
num_debug_info_entries can't be used when cleaning up malloc'd info.

	PR 26388
	* dwarf.c (free_debug_memory): Free alloc_num_debug_info_entries
	of debug_information.  Correct test of max_loc_offsets and
	max_range_lists.
	* rddbg.c (read_debugging_info): Free dhandle on error.
2020-08-14 21:31:22 +09:30
Alan Modra
fc0efc4bd7 Readelf demangling test typo
Using floating point data results in cris failing the test.

	* testsuite/binutils-all/mangled.s: Use dc.a rather than dc.d.
2020-08-14 21:29:57 +09:30
Alan Modra
75e100a30d PR26348, Malloc error in write_zeros
This adds a few more sanity checks on ELF objects, and a BFD flag to
disable objcopy and strip when fuzzed input files belong in the "too
hard" basket.

bfd/
	PR 26348
	* bfd.c (struct bfd): Add read_only.
	* elfcode.h (elf_swap_shdr_in): Test both sh_offset and sh_size.
	Set read_only on warning.
	(elf_object_p): Sanity check program header alignment.  Set
	read_only on warning.
	* bfd-in2.h: Regenerate.
binutils/
	PR 26348
	* objcopy.c (copy_object): Report file name with endian error.
	Error and return on abfd->read_only.
2020-08-13 08:09:08 +09:30
Tom Tromey
d3511b24ea Two fixes in dwarf-mode.el
This fixes a couple of small problems in dwarf-mode.el.

First, I noticed that for an attribute like:

 <2><136c>: Abbrev Number: 11 (DW_TAG_member)
    <136d>   DW_AT_name        : t

... the "t" would not be font-locked using the function name face.
The problem here is that the regexp assumed the indirect string
format, like:

    <12ac>   DW_AT_name        : (indirect string, offset: 0x1b40): whatever

Here the fix is to adjust the regexp to match both formats.

Second, when following a DIE reference, point could end up on an
attribute instead.  This happens when there is a zero-length attribute
with the same "offset" as the following DIE, like:

    <12c5>   DW_AT_GNU_all_call_sites: 1
 <2><12c5>: Abbrev Number: 5 (DW_TAG_formal_parameter)

Here the fix is to search for the DIE by looking for the depth ("<2>"
in the example) as well.

I've bumped the internal version number to make it simpler to install
this using the Emacs package facility.

binutils/ChangeLog
2020-08-12  Tom Tromey  <tromey@adacore.com>

	* dwarf-mode.el (Version): Now 1.6.
	(dwarf-die-button-action): Tighten DIE reference regexp.
	(dwarf-font-lock-keywords): Update name regexp.
2020-08-12 08:41:06 -06:00
Nick Clifton
79bc120c7b Add demangling support to readelf.
PR binutils/26331
	* readelf.c (do_demangle): New option flag.
	(print_symbol): If do_demangle is enabled, demangle the symbol.
	(enum long_option_values): New enum to hold long option values.
	(options): Add demangle, no-demangle, recursion-limit and
	no-recursion-limit options.  Alpha sort the table.
	(usage): Describe the new options.
	(parse_args): Handle the new options.
	* NEWS: Mention the new feature.
	* doc/binutils.texi: Document the new feature.
	* testsuite/binutils-all/readelf.exp: Test the new feature.
	* testsuite/binutils-all/mangled.s: New file - assembler source.
	* testsuite/binutils-all/readelf.demangled: New file - expected
	output from readelf.
2020-08-12 13:31:59 +01:00
Nick Clifton
79ddc88496 Updated Serbian and Russian translations for various sub-directories 2020-08-12 11:25:38 +01:00
H.J. Lu
9b0ac51b22 nm: Remove --with-symbol-versions
Since

commit 7e6e972f74
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Tue Mar 24 04:23:11 2020 -0700

    bfd: Display symbol version for nm -D

always displays symbol version for nm, remove --with-symbol-versions and
silently accept it for backward compatibility.

binutils/

	PR binutils/26302
	* nm.c (with_symbol_versions): Removed.
	(long_option_values): Add OPTION_WITH_SYMBOL_VERSIONS.
	(long_options): Update --with-symbol-versions entry.
	(print_symbol): Remove the with_symbol_versions check.
	(main): Add OPTION_WITH_SYMBOL_VERSIONS for backward
	compatibility.
	* doc/binutils.texi: Remove --with-symbol-versions.

ld/

	PR binutils/26302
	* testsuite/ld-elf/pr26302.nd: New file.
	* testsuite/ld-elf/pr26302.ver: Likewise.
	* testsuite/ld-elf/pr26302a.c: Likewise.
	* testsuite/ld-elf/pr26302b.c: Likewise.
	* testsuite/ld-elf/shared.exp: Run binutils/26302 tests.
2020-08-10 05:17:41 -07:00
Alan Modra
787bbc56d8 Revert "PR26337, Malloc size error in objdump"
This reverts commit 0b97e81846.
2020-08-05 17:40:02 +09:30
Alan Modra
0b97e81846 PR26337, Malloc size error in objdump
A malloc failure triggered by a fuzzed object file isn't a real
problem unless objdump doesn't exit cleanly after the failure, which
it does.  However we have bfd_malloc_and_get_section to sanity check
size of uncompressed sections before allocating memory.  Use it.

	PR 26337
	* objdump.c (load_specific_debug_section): Don't malloc space for
	section contents, use bfd_malloc_and_get_section.
2020-08-05 10:34:05 +09:30
Rainer Orth
c8693053f8 Unify Solaris procfs and largefile handling
GDB currently doesn't build on 32-bit Solaris:

* On Solaris 11.4/x86:

In file included from /usr/include/sys/procfs.h:26,
                 from /vol/src/gnu/gdb/hg/master/dist/gdb/i386-sol2-nat.c:24:
/usr/include/sys/old_procfs.h:31:2: error: #error "Cannot use procfs in the large file compilation environment"
 #error "Cannot use procfs in the large file compilation environment"
  ^~~~~

* On Solaris 11.3/x86 there are several more instances of this.

The interaction between procfs and large-file support historically has
been a royal mess on Solaris:

* There are two versions of the procfs interface:

** The old ioctl-based /proc, deprecated and not used any longer in
   either gdb or binutils.

** The `new' (introduced in Solaris 2.6, 1997) structured /proc.

* There are two headers one can possibly include:

** <procfs.h> which only provides the structured /proc, definining
   _STRUCTURED_PROC=1 and then including ...

** <sys/procfs.h> which defaults to _STRUCTURED_PROC=0, the ioctl-based
   /proc, but provides structured /proc if _STRUCTURED_PROC == 1.

* procfs and the large-file environment didn't go well together:

** Until Solaris 11.3, <sys/procfs.h> would always #error in 32-bit
   compilations when the large-file environment was active
   (_FILE_OFFSET_BITS == 64).

** In both Solaris 11.4 and Illumos, this restriction was lifted for
   structured /proc.

So one has to be careful always to define _STRUCTURED_PROC=1 when
testing for or using <sys/procfs.h> on Solaris.  As the errors above
show, this isn't always the case in binutils-gdb right now.

Also one may need to disable large-file support for 32-bit compilations
on Solaris.  config/largefile.m4 meant to do this by wrapping the
AC_SYS_LARGEFILE autoconf macro with appropriate checks, yielding
ACX_LARGEFILE.  Unfortunately the macro doesn't always succeed because
it neglects the _STRUCTURED_PROC part.

To make things even worse, since GCC 9 g++ predefines
_FILE_OFFSET_BITS=64 on Solaris.  So even if largefile.m4 deciced not to
enable large-file support, this has no effect, breaking the gdb build.

This patch addresses all this as follows:

* All tests for the <sys/procfs.h> header are made with
  _STRUCTURED_PROC=1, the definition going into the various config.h
  files instead of having to make them (and sometimes failing) in the
  affected sources.

* To cope with the g++ predefine of _FILE_OFFSET_BITS=64,
  -U_FILE_OFFSET_BITS is added to various *_CPPFLAGS variables.  It had
  been far easier to have just

  #undef _FILE_OFFSET_BITS

  in config.h, but unfortunately such a construct in config.in is
  commented by config.status irrespective of indentation and whitespace
  if large-file support is disabled.  I found no way around this and
  putting the #undef in several global headers for bfd, binutils, ld,
  and gdb seemed way more invasive.

* Last, the applicability check in largefile.m4 was modified only to
  disable largefile support if really needed.  To do so, it checks if
  <sys/procfs.h> compiles with _FILE_OFFSET_BITS=64 defined.  If it
  doesn't, the disabling only happens if gdb exists in-tree and isn't
  disabled, otherwise (building binutils from a tarball), there's no
  conflict.

  What initially confused me was the check for $plugins here, which
  originally caused the disabling not to take place.  Since AC_PLUGINGS
  does enable plugin support if <dlfcn.h> exists (which it does on
  Solaris), the disabling never happened.

  I could find no explanation why the linker plugin needs large-file
  support but thought it would be enough if gld and GCC's lto-plugin
  agreed on the _FILE_OFFSET_BITS value.  Unfortunately, that's not
  enough: lto-plugin uses the simple-object interface from libiberty,
  which includes off_t arguments.  So to fully disable large-file
  support would mean also disabling it in libiberty and its users: gcc
  and libstdc++-v3.  This seems highly undesirable, so I decided to
  disable the linker plugin instead if large-file support won't work.

The patch allows binutils+gdb to build on i386-pc-solaris2.11 (both
Solaris 11.3 and 11.4, using GCC 9.3.0 which is the worst case due to
predefined _FILE_OFFSET_BITS=64).  Also regtested on
amd64-pc-solaris2.11 (again on Solaris 11.3 and 11.4),
x86_64-pc-linux-gnu and i686-pc-linux-gnu.

	config:
	* largefile.m4 (ACX_LARGEFILE) <sparc-*-solaris*|i?86-*-solaris*>:
	Check for <sys/procfs.h> incompatilibity with large-file support
	on Solaris.
	Only disable large-file support and perhaps plugins if needed.
	Set, substitute LARGEFILE_CPPFLAGS if so.

	bfd:
	* bfd.m4 (BFD_SYS_PROCFS_H): New macro.
	(BFD_HAVE_SYS_PROCFS_TYPE): Require BFD_SYS_PROCFS_H.
	Don't define _STRUCTURED_PROC.
	(BFD_HAVE_SYS_PROCFS_TYPE_MEMBER): Likewise.
	* elf.c [HAVE_SYS_PROCFS_H] (_STRUCTURED_PROC): Don't define.
	* configure.ac: Use BFD_SYS_PROCFS_H to check for <sys/procfs.h>.
	* configure, config.in: Regenerate.
	* Makefile.am (AM_CPPFLAGS): Add LARGEFILE_CPPFLAGS.
	* Makefile.in, doc/Makefile.in: Regenerate.

	binutils:
	* Makefile.am (AM_CPPFLAGS): Add LARGEFILE_CPPFLAGS.
	* Makefile.in, doc/Makefile.in: Regenerate.
	* configure: Regenerate.

	gas:
	* Makefile.am (AM_CPPFLAGS): Add LARGEFILE_CPPFLAGS.
	* Makefile.in, doc/Makefile.in: Regenerate.
	* configure: Regenerate.

	gdb:
	* proc-api.c (_STRUCTURED_PROC): Don't define.
	* proc-events.c: Likewise.
	* proc-flags.c: Likewise.
	* proc-why.c: Likewise.
	* procfs.c: Likewise.

	* Makefile.in (INTERNAL_CPPFLAGS): Add LARGEFILE_CPPFLAGS.
	* configure, config.in: Regenerate.

	gdbserver:
	* configure, config.in: Regenerate.

	gdbsupport:
	* Makefile.am (AM_CPPFLAGS): Add LARGEFILE_CPPFLAGS.
	* common.m4 (GDB_AC_COMMON): Use BFD_SYS_PROCFS_H to check for
	<sys/procfs.h>.
	* Makefile.in: Regenerate.
	* configure, config.in: Regenerate.

	gnulib:
	* configure.ac: Run ACX_LARGEFILE before gl_EARLY.
	* configure: Regenerate.

	gprof:
	* Makefile.am (AM_CPPFLAGS): Add LARGEFILE_CPPFLAGS.
	* Makefile.in: Regenerate.
	* configure: Regenerate.

	ld:
	* Makefile.am (AM_CPPFLAGS): Add LARGEFILE_CPPFLAGS.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
2020-07-30 15:41:50 +02:00
H.J. Lu
ac2599c447 x86: Pass --gdwarf-3 to assembler
Pass --gdwarf-3 to assembler for

commit 4d8ee86073
Author: Nick Clifton <nickc@redhat.com>
Date:   Thu Jul 30 08:39:14 2020 +0100

    Prevent the generation of DWARF level 0 line number tables...

binutils/

	* testsuite/binutils-all/i386/compressed-1a.d: Pass --gdwarf-3
	to assembler.
	* testsuite/binutils-all/i386/compressed-1b.d: Likewise.
	* testsuite/binutils-all/i386/compressed-1c.d: Likewise.
	* testsuite/binutils-all/x86-64/compressed-1a.d: Likewise.
	* testsuite/binutils-all/x86-64/compressed-1b.d: Likewise.
	* testsuite/binutils-all/x86-64/compressed-1c.d: Likewise.

gas/

	* testsuite/gas/elf/dwarf2-3.d:Pass --gdwarf-3 to assembler.
	* testsuite/gas/elf/dwarf2-5.d: Likewise.
	* testsuite/gas/i386/dw2-compress-3a.d: Likewise.
	* testsuite/gas/i386/dw2-compress-3b.d: Likewise.
	* testsuite/gas/i386/dw2-compressed-3a.d: Likewise.
	* testsuite/gas/i386/dw2-compressed-3b.d: Likewise.
2020-07-30 04:56:46 -07:00
Maciej W. Rozycki
c77cb2a09c MIPS: Make the IRIX naming of local section symbols consistent
Make the MIPS/IRIX naming of local section symbols consistent between
files produced by generic ELF code and ELF linker code, complementing
commit 174fd7f955 ("New bfd elf hook: force naming of local section
symbols"), <https://sourceware.org/ml/binutils/2004-02/msg00072.html>.

Local section symbols have no names in the standard ELF gABI, however
the lack of a name causes problems with IRIX's MIPSpro linker.  To work
around the issue we give them names, however we do that in generic ELF
code only, based on what the `elf_backend_name_local_section_symbols'
hook returns if present.  That makes objects created by GAS or `objdump'
work correctly, however not ones created by `ld -r'.  That would not
normally cause issues with IRIX systems using GAS and `objdump' only
with the MIPSpro linker, however if GNU LD was used for whatever reason
in producing objects later fed to IRIX's MIPSpro linker, then things
would break.

Modify ELF linker code accordingly then, using the same hook.  Adjust
the `ld-elf/64ksec-r' test accordingly so that it also accepts a section
symbol with a name.

Also modify the hook itself so that only actual ET_REL objects have
names assigned to local section symbols.  Other kinds of ELF files are
not ever supposed to be relocated with the MIPSpro linker, so we can
afford producing more standard output.

Add suitable GAS, LD and `objcopy' test cases to the relevant testsuites
to keep these tools consistently verified.  This change also fixes:

FAIL: objcopy executable (pr25662)

across MIPS targets using the IRIX compatibility mode.

	bfd/
	* elflink.c (bfd_elf_final_link): Give local symbols a name if
	so requested.
	* elfxx-mips.c (_bfd_mips_elf_name_local_section_symbols): Only
	return TRUE if making ET_REL output.

	binutils/
	* testsuite/binutils-all/mips/global-local-symtab-sort-o32.d:
	New test.
	* testsuite/binutils-all/mips/global-local-symtab-sort-o32t.d:
	New test.
	* testsuite/binutils-all/mips/global-local-symtab-sort-n32.d:
	New test.
	* testsuite/binutils-all/mips/global-local-symtab-sort-n32t.d:
	New test.
	* testsuite/binutils-all/mips/global-local-symtab-sort-n64.d:
	New test.
	* testsuite/binutils-all/mips/global-local-symtab-sort-n64t.d:
	New test.
	* testsuite/binutils-all/mips/global-local-symtab-final-o32.d:
	New test.
	* testsuite/binutils-all/mips/global-local-symtab-final-n32.d:
	New test.
	* testsuite/binutils-all/mips/global-local-symtab-final-n64.d:
	New test.
	* testsuite/binutils-all/mips/mips.exp: Run the new tests.

	gas/
	* testsuite/gas/mips/global-local-symtab-sort-o32.d: New test.
	* testsuite/gas/mips/global-local-symtab-sort-o32t.d: New test.
	* testsuite/gas/mips/global-local-symtab-sort-n32.d: New test.
	* testsuite/gas/mips/global-local-symtab-sort-n32t.d: New test.
	* testsuite/gas/mips/global-local-symtab-sort-n64.d: New test.
	* testsuite/gas/mips/global-local-symtab-sort-n64t.d: New test.
	* testsuite/gas/mips/mips.exp: Run the new tests.

	ld/
	* testsuite/ld-elf/sec64k.exp: Also accept a section symbol with
	a name.
	* testsuite/ld-mips-elf/global-local-symtab-sort-o32.d: New
	test.
	* testsuite/ld-mips-elf/global-local-symtab-sort-o32t.d: New
	test.
	* testsuite/ld-mips-elf/global-local-symtab-sort-n32.d: New
	test.
	* testsuite/ld-mips-elf/global-local-symtab-sort-n32t.d: New
	test.
	* testsuite/ld-mips-elf/global-local-symtab-sort-n64.d: New
	test.
	* testsuite/ld-mips-elf/global-local-symtab-sort-n64t.d: New
	test.
	* testsuite/ld-mips-elf/global-local-symtab-final-o32.d: New
	test.
	* testsuite/ld-mips-elf/global-local-symtab-final-n32.d: New
	test.
	* testsuite/ld-mips-elf/global-local-symtab-final-n64.d: New
	test.
	* testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.
2020-07-29 20:56:41 +01:00
Maciej W. Rozycki
3f1b17bbf0 MIPS/LD: Set symtab's `sh_info' correctly for IRIX emulations
Correct ELF linker code so as to set the `sh_info' value of the static
symbol table section according to the section symbols vs other symbols
split where required by the selection of the IRIX compatibility mode for
MIPS target.  Add a `elf_backend_elfsym_local_is_section' hook for that
purpose, returning TRUE if it is only STB_LOCAL/STT_SECTION symbols that
are to be considered local for the purpose of this split rather than all
STB_LOCAL symbols.

We do it already in generic ELF code, and have done it since 1993, with
the `elf_backend_sym_is_global' hook, affecting GAS and `objcopy', so
these tools produce correct ELF output in the IRIX compatibility mode,
however if such output is fed as input to `ld -r', then the linker's
output is no longer valid for that mode.  The relevant changes to
generic ELF code are:

commit 062189c6ea
Author: Ian Lance Taylor <ian@airs.com>
Date:   Thu Nov 18 17:12:47 1993 +0000

and:

commit 6e07e54f1b
Author: Ian Lance Taylor <ian@airs.com>
Date:   Thu Jan 6 20:01:42 1994 +0000

(split across two GIT commits likely due to repository conversion
peculiarities).

The `elf_backend_sym_is_global' hook however operates on BFD rather than
ELF symbols, making it unsuitable for the ELF linker as the linker does
not convert any symbol tables processed into the BFD format.  Converting
the hook to operate on ELF symbols would in principle be possible, but
it would still require a considerable rewrite of `bfd_elf_final_link' to
adapt to the interface.

Therefore, especially given that no new use for the IRIX compatibility
mode is expected, minimize changes made to the ELF linker code and just
add an entirely new hook, and wire it in the o32 and n32 MIPS backends
accordingly; the n64 backend never uses the IRIX compatibility mode.

Since we have no coverage here at all add suitable GAS, LD and `objcopy'
test cases to the relevant testsuites to keep these tools consistently
verified.

	bfd/
	* elf-bfd.h (elf_backend_data): Add
	`elf_backend_elfsym_local_is_section' member.
	* elfxx-target.h (elf_backend_elfsym_local_is_section): New
	macro.
	(elfNN_bed): Add `elf_backend_elfsym_local_is_section' member.
	* elflink.c (bfd_elf_final_link): Use it to determine whether
	set the `.symtab' section's `sh_info' value to the index of the
	first non-local or non-section symbol.
	* elf32-mips.c (mips_elf32_elfsym_local_is_section): New
	function.
	(elf_backend_elfsym_local_is_section): New macro.
	* elfn32-mips.c (mips_elf_n32_elfsym_local_is_section): New
	function.
	(elf_backend_elfsym_local_is_section): New macro.

	binutils/
	* testsuite/binutils-all/mips/global-local-symtab-o32.d: New
	test.
	* testsuite/binutils-all/mips/global-local-symtab-o32t.d: New
	test.
	* testsuite/binutils-all/mips/global-local-symtab-n32.d: New
	test.
	* testsuite/binutils-all/mips/global-local-symtab-n32t.d: New
	test.
	* testsuite/binutils-all/mips/global-local-symtab-n64.d: New
	test.
	* testsuite/binutils-all/mips/mips.exp: Run the new tests.

	gas/
	* testsuite/gas/mips/global-local-symtab-o32.d: New test.
	* testsuite/gas/mips/global-local-symtab-o32t.d: New test.
	* testsuite/gas/mips/global-local-symtab-n32.d: New test.
	* testsuite/gas/mips/global-local-symtab-n32t.d: New test.
	* testsuite/gas/mips/global-local-symtab-n64.d: New test.
	* testsuite/gas/mips/global-local-symtab.s: New test source.
	* testsuite/gas/mips/mips.exp: Run the new tests.

	ld/
	* testsuite/ld-mips-elf/global-local-symtab-o32.d: New test.
	* testsuite/ld-mips-elf/global-local-symtab-o32t.d: New test.
	* testsuite/ld-mips-elf/global-local-symtab-n32.d: New test.
	* testsuite/ld-mips-elf/global-local-symtab-n32t.d: New test.
	* testsuite/ld-mips-elf/global-local-symtab-n64.d: New test.
	* testsuite/ld-mips-elf/global-local-symtab.ld: New test linker
	script.
	* testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.
2020-07-29 20:56:41 +01:00
H.J. Lu
377170fa31 PKG_CHECK_MODULES: Properly check if $pkg_cv_[]$1[]_LIBS works
There is no need to check $pkg_cv_[]$1[]_LIBS works if package check
failed.

config/

	PR binutils/26301
	* pkg.m4 (PKG_CHECK_MODULES): Use AC_TRY_LINK only if
	$pkg_failed = no.

binutils/

	PR binutils/26301
	* configure: Regenerated.

gdb/

	PR binutils/26301
	* configure: Regenerated.
2020-07-28 06:59:30 -07:00
H.J. Lu
d70f978b44 PKG_CHECK_MODULES: Check if $pkg_cv_[]$1[]_LIBS works
It is quite normal to have headers without library on multilib OSes.
Add AC_TRY_LINK to PKG_CHECK_MODULES to check if $pkg_cv_[]$1[]_LIBS
works.

config/

	PR binutils/26301
	* pkg.m4 (PKG_CHECK_MODULES): Add AC_TRY_LINK to check if
	$pkg_cv_[]$1[]_LIBS works.

binutils/

	PR binutils/26301
	* configure: Regenerated.

gdb/

	PR binutils/26301
	* configure: Regenerated.
2020-07-28 03:56:34 -07:00
Alan Modra
8fab9282e5 Prevent strange "section mentioned in a -j option but not found"
"objdump -s -j .bss" results in a message that indicates objdump
couldn't find a .bss section when present.  Fix that.

	* objdump.c (dump_section): Don't return without calling
	process_section_p.
2020-07-27 22:31:37 +09:30
H.J. Lu
608d61c202 doc: Replace preceeded with preceded
binutils/

	* doc/binutils.texi: Replace preceeded with preceded.

gas/

	* doc/as.texi: Replace preceeded with preceded.
2020-07-27 05:52:14 -07:00
Maciej W. Rozycki
3abf975826 MIPS/binutils/testsuite: Correct mips.exp test ABI/emul/endian arrangement
The binutils testsuite supports involving LD in processing test cases
and with the MIPS target that has the same issues the LD testsuite does.

So to support LD in the MIPS part of the binutils testsuite similarly
to commit 86b24e15c4 ("MIPS/LD/testsuite: Correct comm-data.exp test
ABI/emul/endian arrangement") update the mips.exp test script to:

- correctly select emulations for targets using non-traditional MIPS
  emulations,

- correctly select ABIs for targets that do not support all of them,

- use the default endianness selection where possible to benefit targets
  that support only one,

- simplify test invocation by providing ABI-specific `run_dump_test'
  wrappers, specifically `run_dump_test_o32', `run_dump_test_n32' and
  `run_dump_test_n64', which remove the need to use conditionals across
  the Expect script or to repeat ABI-specific GAS and LD flags with each
  invocation,

borrowing changes from commit 78da84f994 ("MIPS/LD/testsuite: Correct
mips-elf.exp test ABI/emul/endian arrangement").

As a side effect this disables o32 ABI testing for targets that are not
supposed to support them and do not with LD, but still have such support
with BFD and GAS due to our inflexibility in configuration.  Ultimately
we ought to support having o32 completely disabled.

	binutils/
	* testsuite/binutils-all/mips/mips.exp (run_dump_test_abi)
	(run_dump_test_o32, run_dump_test_n32, run_dump_test_n64): New
	procedures.
	(has_newabi): Remove variable.
	(has_abi, abi_asflags, abi_ldflags): New associative array
	variables.
	(irixemul): New variable.
	Replace `run_dump_test' calls where applicable throughout with
	`run_dump_test_o32', `run_dump_test_n32' and `run_dump_test_n64'
	as appropriate.  Use `noarch' for tests that require their own
	architecture setting.
	* testsuite/binutils-all/mips/mips-ase-1.d: Remove GAS flags.
	* testsuite/binutils-all/mips/mips-ase-2.d: Likewise.
	* testsuite/binutils-all/mips/mips-ase-3.d: Likewise.
	* testsuite/binutils-all/mips/mips-note-2-n32.d: Likewise.
	* testsuite/binutils-all/mips/mips-note-2-n64.d: Likewise.
	* testsuite/binutils-all/mips/mips-note-2.d: Likewise.
	* testsuite/binutils-all/mips/mips-note-2r-n32.d: Likewise.
	* testsuite/binutils-all/mips/mips-note-2r-n64.d: Likewise.
	* testsuite/binutils-all/mips/mips-note-2r.d: Likewise.
	* testsuite/binutils-all/mips/mips-reginfo-n32.d: Likewise.
	* testsuite/binutils-all/mips/mips-reginfo.d: Likewise.
	* testsuite/binutils-all/mips/mips16-extend-noinsn.d: Likewise.
	* testsuite/binutils-all/mips/mips16-pcrel.d: Likewise.
	* testsuite/binutils-all/mips/mips16-alias.d: Remove `-32' from
	GAS flags.
	* testsuite/binutils-all/mips/mips16-extend-insn.d: Likewise.
	* testsuite/binutils-all/mips/mips16-noalias.d: Likewise.
	* testsuite/binutils-all/mips/mips16-undecoded.d: Likewise.
	* testsuite/binutils-all/mips/mips16e2-extend-insn.d: Likewise.
	* testsuite/binutils-all/mips/mips16e2-undecoded.d: Likewise.
	* testsuite/binutils-all/mips/mixed-micromips.d: Likewise.
	* testsuite/binutils-all/mips/mixed-mips16.d: Likewise.
2020-07-26 14:43:21 +01:00
Aaron Merey
f6720b1cfe config/debuginfod.m4: Use PKG_CHECK_MODULES
Use PKG_CHECK_MODULES to set debuginfod autoconf vars. Also add
pkg.m4 to config/.

ChangeLog:

	* config/debuginfod.m4: use PKG_CHECK_MODULES.
	* config/pkg.m4: New file.
	* configure: Rebuild.
	* configure.ac: Remove AC_DEBUGINFOD.

ChangeLog/binutils:

	* Makefile.am: Replace LIBDEBUGINFOD with DEBUGINFOD_LIBS.
	* Makefile.in: Rebuild.
	* configure: Rebuild.
	* doc/Makefile.in: Rebuild.

ChangeLog/gdb:

	* Makefile.in: Replace LIBDEBUGINFOD with DEBUGINFOD_LIBS.
	* configure: Rebuild.
2020-07-24 15:16:20 -04:00
Nick Clifton
bf772a1ecd Update documentation on how to make a release 2020-07-24 12:07:41 +01:00
Nick Alcock
0b88415108 binutils, testsuite: allow compilation before doing run_dump_test
The CTF assembler emitted by GCC has architecture-dependent pseudos in
it, and is (obviously) tightly tied to a particular set of C source
files with specific types in them.  The CTF tests do run_dump_test on
some candidate input, link it using the run_dump_test ld machinery, and
compare objdump --ctf output.  To avoid skew, we'd like to be able
to easily regenerate the .s being scanned so that the .c doesn't get
out of sync with it, but since GCC emits arch-dependent pseudos, we
are forced to hand-hack the output every time (quite severely on some
arches, like x86-32 and -64, where every single pseudo used is not only
arch-dependent but undocumented).

To avoid this, teach run_dump_test how to optionally compile things
given new, optional additional flags passed in in the cc option.
Only sources with the .c suffix are compiled, so there is no effect on
any existing tests.  The .s files go into the tmpdir, from which
existing run_dump_test code picks them up as usual.

binutils/
	* testsuite/lib/binutils-common.exp (run_dump_test): Add 'cc'
	option.
2020-07-22 18:03:57 +01:00
Nick Alcock
3dd6b890b4 binutils: objdump: ctf: drop incorrect linefeeds
The CTF objdumping code is adding linefeeds in calls to non_fatal, which
is wrong and looks ugly.

binutils/
	* objdump.c (dump_ctf_archive_member): Remove linefeeds.
	(dump_ctf): Likewise.
2020-07-22 18:02:19 +01:00
Nick Alcock
8b37e7b63e libctf, ld, binutils: add textual error/warning reporting for libctf
This commit adds a long-missing piece of infrastructure to libctf: the
ability to report errors and warnings using all the power of printf,
rather than being restricted to one errno value.  Internally, libctf
calls ctf_err_warn() to add errors and warnings to a list: a new
iterator ctf_errwarning_next() then consumes this list one by one and
hands it to the caller, which can free it.  New errors and warnings are
added until the list is consumed by the caller or the ctf_file_t is
closed, so you can dump them at intervals.  The caller can of course
choose to print only those warnings it wants.  (I am not sure whether we
want objdump, readelf or ld to print warnings or not: right now I'm
printing them, but maybe we only want to print errors?  This entirely
depends on whether warnings are voluminous things describing e.g. the
inability to emit single types because of name clashes or something.
There are no users of this infrastructure yet, so it's hard to say.)

There is no internationalization here yet, but this at least adds a
place where internationalization can be added, to one of
ctf_errwarning_next or ctf_err_warn.

We also provide a new ctf_assert() function which uses this
infrastructure to provide non-fatal assertion failures while emitting an
assert-like string to the caller: to save space and avoid needlessly
duplicating unchanging strings, the assertion test is inlined but the
print-things-out failure case is not.  All assertions in libctf will be
converted to use this machinery in future commits and propagate
assertion-failure errors up, so that the linker in particular cannot be
killed by libctf assertion failures when it could perfectly well just
print warnings and drop the CTF section.

include/
	* ctf-api.h (ECTF_INTERNAL): Adjust error text.
	(ctf_errwarning_next): New.
libctf/
	* ctf-impl.h (ctf_assert): New.
	(ctf_err_warning_t): Likewise.
	(ctf_file_t) <ctf_errs_warnings>: Likewise.
	(ctf_err_warn): New prototype.
	(ctf_assert_fail_internal): Likewise.
	* ctf-inlines.h (ctf_assert_internal): Likewise.
	* ctf-open.c (ctf_file_close): Free ctf_errs_warnings.
	* ctf-create.c (ctf_serialize): Copy it on serialization.
	* ctf-subr.c (ctf_err_warn): New, add an error/warning.
	(ctf_errwarning_next): New iterator, free and pass back
	errors/warnings in succession.
	* libctf.ver (ctf_errwarning_next): Add.
ld/
	* ldlang.c (lang_ctf_errs_warnings): New, print CTF errors
	and warnings.  Assert when libctf asserts.
	(lang_merge_ctf): Call it.
	(land_write_ctf): Likewise.
binutils/
	* objdump.c (ctf_archive_member): Print CTF errors and warnings.
	* readelf.c (dump_ctf_archive_member): Likewise.
2020-07-22 18:02:17 +01:00
Nick Clifton
df16e041de Fix problems in CTF handling code exposed by the Coverity static analysis tool.
readelf	* readelf.c (parse_args): Silence potential warnings about a
	memory resource leak when allocating space for ctf option values.
	(dump_section_as_ctf): Fix typo checking dump_ctf_strtab_name
	variable.

libctf	* ctf-archive.c (ctf_arc_write): Avoid calling close twice on the
	same file descriptor.
2020-07-22 16:07:48 +01:00
Nick Clifton
84dc5f0b5c Updated Swedish translation for the binutils sub-directory 2020-07-21 11:22:36 +01:00
Claudiu Zissulescu
570b0ed6d5 arc: Detect usage of illegal double register pairs
ARC can use odd-even double register pairs in some selected
instructions. Although the GNU assembler doesn't allow even-odd
registers to be used, there may be cases when the disassembler is
presented with such situation.  This patch add a test and detects such
cases.

opcodes/
2020-07-14  Claudiu Zissulescu  <claziss@gmail.com>

	* arc-dis.c (print_insn_arc): Detect and emit a warning when a
	faulty double register pair is detected.

binutils/
2020-07-14  Claudiu Zissulescu  <claziss@gmail.com>

	* testsuite/binutils-all/arc/double_regs.s: New test.
	* testsuite/binutils-all/arc/objdump.exp: Add the above test.

Signed-off-by: Claudiu Zissulescu <claziss@gmail.com>
2020-07-14 14:51:15 +03:00
Nick Clifton
0a5c31d1ac Updated French translation for the gas/ and binutils/ sub-directories 2020-07-13 14:49:58 +01:00
Alan Modra
7a34d0ea4d x86_64-cygwin tests
Tests just having "xfail: x86_64-*-cygwin" aren't good, since
presumably if a test fails on x86_64-cygwin then it also fails on
x86_64-*-pe* and x86_64-*-mingw*.

binutils/
	* testsuite/lib/binutils-common.exp (is_pecoff_format): Accept
	optional machine-os arg.
ld/
	* testsuite/ld-scripts/default-script1.d: Don't skip, xfail
	using is_pecoff_format.
	* testsuite/ld-scripts/default-script2.d: Likewise.
	* testsuite/ld-scripts/default-script3.d: Likewise.
	* testsuite/ld-scripts/default-script4.d: Likewise.
	* testsuite/ld-scripts/pr20302.d: Remove x86_64-*-cygwin from notarget.
	* testsuite/ld-scripts/provide-6.d: Remove x86_64-*-cygwin from xfail.
	* testsuite/ld-scripts/provide-8.d: Likewise.
2020-07-13 22:03:59 +09:30
H.J. Lu
a308b89de7 x86: Support GNU_PROPERTY_X86_FEATURE_2_TMM
Support GNU_PROPERTY_X86_FEATURE_2_TMM in

https://gitlab.com/x86-psABIs/x86-64-ABI/-/merge_requests/1

 #define GNU_PROPERTY_X86_FEATURE_2_TMM      (1U << 10)

binutils/

	* readelf.c (decode_x86_feature_2): Handle
	GNU_PROPERTY_X86_FEATURE_2_TMM.

gas/

	* config/tc-i386.c (output_insn): Check i.xstate to set
	GNU_PROPERTY_X86_FEATURE_2_TMM.
	* testsuite/gas/i386/i386.exp: Run x86-64-property-7,
	x86-64-property-8 and x86-64-property-9.
	* testsuite/gas/i386/x86-64-property-7.d: New file.
	* testsuite/gas/i386/x86-64-property-7.s: Likewise.
	* testsuite/gas/i386/x86-64-property-8.d: Likewise.
	* testsuite/gas/i386/x86-64-property-8.s: Likewise.
	* testsuite/gas/i386/x86-64-property-9.d: Likewise.
	* testsuite/gas/i386/x86-64-property-9.s: Likewise.

include/

	* elf/common.h (GNU_PROPERTY_X86_FEATURE_2_TMM): New.
2020-07-11 04:04:20 -07:00
Tom de Vries
af2b318648 [readelf] Fix end_seq entry in -wL. Specifically stop the display of a line number and is_statement/has-view fields for the End of Sequence operator, as these have no meaning.
binutils* dwarf.c (display_debug_lines_decoded): Don't emit meaningless
	information in the end_sequence row.
	* testsuite/binutils-all/dw5.W: Update.
	* testsuite/binutils-all/objdump.WL: Update.

gas	* testsuite/gas/elf/dwarf2-11.d: Update expected output from
	readelf's line table decoding.
	* testsuite/gas/elf/dwarf2-12.d: Likewise.
	* testsuite/gas/elf/dwarf2-13.d: Likewise.
	* testsuite/gas/elf/dwarf2-14.d: Likewise.
	* testsuite/gas/elf/dwarf2-15.d: Likewise.
	* testsuite/gas/elf/dwarf2-16.d: Likewise.
	* testsuite/gas/elf/dwarf2-17.d: Likewise.
	* testsuite/gas/elf/dwarf2-18.d: Likewise.
	* testsuite/gas/elf/dwarf2-19.d: Likewise.
	* testsuite/gas/elf/dwarf2-5.d: Likewise.
	* testsuite/gas/elf/dwarf2-6.d: Likewise.
	* testsuite/gas/elf/dwarf2-7.d: Likewise.
2020-07-10 11:25:44 +01:00
Alan Modra
fe49679d51 Remove powerpc PE support
Plus some leftover powerpc lynxos support.

bfd/
	* coff-ppc.c: Delete.
	* pe-ppc.c: Delete.
	* pei-ppc.c: Delete.
	* Makefile.am (BFD32_BACKENDS, BFD32_BACKENDS_CFILES): Remove PE PPC.
	* coffcode.h (coff_set_arch_mach_hook, coff_set_flags): Remove
	PPCMAGIC code.
	(coff_write_object_contents): Remove PPC_PE code.
	* config.bfd: Move powerpcle-pe to removed targets.
	* configure.ac: Remove powerpc PE entries.
	* libcoff-in.h (ppc_allocate_toc_section): Delete.
	(ppc_process_before_allocation): Delete.
	* peXXigen.c: Remove POWERPC_LE_PE code and comments.
	* targets.c: Remove powerpc PE vectors.
	* po/SRC-POTFILES.in: Regenerate.
	* libcoff.h: Regenerate.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
binutils/
	* dlltool.c: Remove powerpc PE support and comments.
	* configure.ac: Remove powerpc PE dlltool config.
	* configure: Regenerate.
gas/
	* config/obj-coff.h: Remove TE_PE support.
	* config/tc-ppc.c: Likewise.
	* config/tc-ppc.h: Likewise.
	* configure.tgt: Remove powerpc PE and powerpc lynxos.
	* testsuite/gas/cfi/cfi.exp (cfi-common-6): Remove powerpc PE
	condition.
	* testsuite/gas/macros/macros.exp: Don't xfail powerpc PE.
include/
	* coff/powerpc.h: Delete.
ld/
	* emulparams/ppcpe.sh: Delete.
	* scripttempl/ppcpe.sc: Delete.
	* emulparams/ppclynx.sh: Delete.
	* Makefile.am (ALL_EMULATION_SOURCES): Remove ppc PE and lynxos.
	* configure.tgt: Likewise.
	* emultempl/beos.em: Remove powerpc PE support.
	* emultempl/pe.em: Likewise.
	* po/BLD-POTFILES.in: Regenerate.
	* Makefile.in: Regenerate.
2020-07-09 22:58:16 +09:30
Nick Clifton
d90171dec1 Update the Windows Resource compiler (windres) to support the OWNERDRAW and BITMAP menuitem flags.
binutils* rclex.c: Add OWNERDRAW keyword.
	* rcparse.y: Add OWNERDRAW token.
	(menuitem_flag) Add BITMAP and OWNERDRAW entries.
	* resrc.c (write_rc_menuitems): Add support for OWNERDRAW and
	BITMAP flags.
	* windres.c (extended_menuitems): Likewise.
	* testsuite/binutils-all/windres/menuitem_flags.rc: New test.
2020-07-09 13:45:01 +01:00
Alan Modra
e3fdc001d3 asan: readelf: heap buffer overflow in slurp_hppa_unwind_table
This one isn't just a weird corner case requiring multiple
.PARISC.unwind sections in an object file to trigger the buffer
overflow, it's also a simple bug that would prevent relocations being
applied in the normal case of a single .PARISC.unwind section.

	* readelf (slurp_hppa_unwind_table): Set table_len before use
	in relocation sanity checks.
2020-07-09 13:50:27 +09:30
Alan Modra
5a2296ac1b Use is_xcoff_format in binutils testsuite
and restrict some other tests using is_*_format.

	* testsuite/binutils-all/ar.exp: Use is_xcoff_format.
	* testsuite/binutils-all/nm.exp: Likewise.
	* testsuite/binutils-all/copy-2.d: Run only for elf and pe targets.
	* testsuite/binutils-all/copy-3.d: Run only for elf targets.
	* testsuite/binutils-all/set-section-alignment.d: Likewise.
	* testsuite/binutils-all/copy-4.d: Don't run for xcoff.
2020-07-07 18:26:33 +09:30
Alan Modra
efd0ed580e XCOFF binutils testsuite fix
Avoid an UNRESOLVED test due to "Error: the XCOFF file format does not
support arbitrary sections".

	* testsuite/lib/binutils-common.exp (is_xcoff_format): New.
	* testsuite/binutils-all/objcopy.exp (pr25662): Exclude xcoff.
2020-07-07 18:26:33 +09:30
Nick Clifton
17550be7dd Updated translations for various binutils sub-directories 2020-07-06 10:43:35 +01:00
Alan Modra
ddb43bab17 asan: readelf: stack buffer overflow
* readelf.c (print_dynamic_symbol): Don't sprintf to buffer to
	find string length.
2020-07-06 11:30:06 +09:30
Nick Clifton
2f4172d6cb Tweak version numbers in release-howto 2020-07-04 11:23:17 +01:00
Nick Clifton
b19d852dcf Update version to 2.35.50 and regenerate files 2020-07-04 10:34:23 +01:00
Nick Clifton
b115b9fd3c Add markers for binutils 2.35 branch 2020-07-04 10:16:22 +01:00
Nick Clifton
0942c7ab94 Change readelf's display of symbol names (when not in --wide mode) so that if they are going to be truncated then "[...]" is displayed at the end. Add a comment line option to disable this enhancement and restore the old behaviour.
PR 26028
binutils* readelf.c (print_symbol): Handle truncation of symbol names.
	(options): Add -T/--silent-truncation option.
	(parse_args): Handle the option.
	(print_dynamic_symbol): Correct calculation of width available to
	display symbol name.
	* doc/binutils.texi: Document the -T option to readelf.
	* NEWS: Mention the new feature.

gas	* testsuite/gas/ia64/group-2.d: Add -T option to readelf
	command line.
	* testsuite/gas/ia64/unwind.d: Likewise.
	* testsuite/gas/mmix/bspec-1.d: Likewise.
	* testsuite/gas/mmix/bspec-2.d: Likewise.
	* testsuite/gas/mmix/comment-1.d: Likewise.
	* testsuite/gas/tic6x/scomm-directive-4.d: Likewise.

ld	* testsuite/ld-powerpc/powerpc.exp: Add -T option to readelf
	command line when running some tests.
	* testsuite/ld-arm/arm-elf.exp: Likewise.
	* testsuite/ld-mips-elf/mips-elf.exp: Likewise.
	* testsuite/ld-mmix/local1.d: Likewise.
	* testsuite/ld-mmix/local3.d: Likewise.
	* testsuite/ld-mmix/local5.d: Likewise.
	* testsuite/ld-mmix/local7.d: Likewise.
	* testsuite/ld-powerpc/powerpc.exp: Likewise.
2020-07-02 11:30:52 +01:00
H.J. Lu
bbd19b19e4 Remove x86 NaCl target support
NaCl has been deprecated:

https://developer.chrome.com/native-client/migration

and NaCl will completely disappear in 2021:

https://lists.llvm.org/pipermail/llvm-dev/2020-April/141107.html

Remove x86 NaCl target support from bfd, binutils, gas and ld.

bfd/

	* archures.c (bfd_mach_i386_nacl): Removed.
	(bfd_mach_i386_i386_nacl): Likewise.
	(bfd_mach_x86_64_nacl): Likewise.
	(bfd_mach_x64_32_nacl): Likewise.
	* config.bfd: Remove *-*-nacl* targets.
	* configure.ac: Remove x86 NaCl target vectors.
	* cpu-i386.c (bfd_arch_i386_onebyte_nop_fill): Removed.
	(bfd_x64_32_nacl_arch): Likewise.
	(bfd_x86_64_nacl_arch): Likewise.
	(bfd_i386_nacl_arch): Likewise.
	(bfd_x64_32_arch_intel_syntax): Updated.
	* elf32-i386.c: Don't include "elf-nacl.h".
	(elf_i386_nacl_plt): Removed.
	(elf_i386_nacl_plt0_entry): Likewise.
	(elf_i386_nacl_plt_entry): Likewise.
	(elf_i386_nacl_pic_plt0_entry): Likewise.
	(elf_i386_nacl_pic_plt_entry): Likewise.
	(elf_i386_nacl_eh_frame_plt): Likewise.
	(elf_i386_nacl_plt): Likewise.
	(elf32_i386_nacl_elf_object_p): Likewise.
	(elf_i386_get_synthetic_symtab): Updated.
	(elf_i386_link_setup_gnu_properties): Likewise.
	* elf64-x86-64.c: Don't include "elf-nacl.h".
	(elf_x86_64_nacl_plt): Removed.
	(elf64_x86_64_nacl_elf_object_p): Likewise.
	(elf_x86_64_nacl_plt0_entry): Likewise.
	(elf_x86_64_nacl_plt_entry): Likewise.
	(elf_x86_64_nacl_eh_frame_plt): Likewise.
	(elf_x86_64_nacl_plt): Likewise.
	(elf32_x86_64_nacl_elf_object_p): Likewise.
	(elf_x86_64_get_synthetic_symtab): Updated.
	(elf_x86_64_link_setup_gnu_properties): Likewise.
	* elfxx-x86.c (_bfd_x86_elf_link_setup_gnu_properties): Likewise.
	* targets.c: Remove x86 NaCl target vectors.
	* bfd-in2.h: Regenerated.
	* configure: Likewise.

binutils/

	* NEWS: Mention x86 NaCl target support removal.
	* dwarf.c (init_dwarf_regnames_by_bfd_arch_and_mach): Remove
	x86 NaCl target support.
	* testsuite/binutils-all/elfedit-1.d: Likewise.
	* testsuite/binutils-all/i386/i386.exp: Likewise.
	* testsuite/binutils-all/x86-64/objects.exp: Likewise.
	* testsuite/binutils-all/x86-64/pr23494a-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494a.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494b-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494b.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494c-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494c.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494d-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494d.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494e-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494e.d: Likewise.
	* testsuite/binutils-all/x86-64/x86-64.exp: Likewise.

gas/

	* NEWS: Mention x86 NaCl target support removal.
	* config/tc-i386.c: Remove x86 NaCl target support.
	* config/tc-i386.h: Likewise.
	* configure.tgt: Likewise.
	* testsuite/gas/i386/i386.exp: Likewise.
	* testsuite/gas/i386/iamcu-1.d: Likewise.
	* testsuite/gas/i386/iamcu-2.d: Likewise.
	* testsuite/gas/i386/iamcu-3.d: Likewise.
	* testsuite/gas/i386/iamcu-4.d: Likewise.
	* testsuite/gas/i386/iamcu-5.d: Likewise.
	* testsuite/gas/i386/k1om.d: Likewise.
	* testsuite/gas/i386/l1om.d: Likewise.

ld/

	* Makefile.am (ALL_EMULATION_SOURCES): Remove eelf_i386_nacl.c,
	eelf32_x86_64_nacl.c, eelf_x86_64_nacl.c.
	Remove x86 NaCl dep files.
	* NEWS: Mention x86 NaCl target support removal.
	* configure.tgt: Remove x86 NaCl target support.
	* testsuite/ld-elf/binutils.exp: Likewise.
	* testsuite/ld-elf/elf.exp: Likewise.
	* testsuite/ld-elfvers/vers.exp: Likewise.
	* testsuite/ld-i386/align-branch-1.d: Likewise.
	* testsuite/ld-i386/export-class.exp: Likewise.
	* testsuite/ld-i386/i386.exp: Likewise.
	* testsuite/ld-i386/load1.d: Likewise.
	* testsuite/ld-i386/pie1.d: Likewise.
	* testsuite/ld-i386/pr12570a.d: Likewise.
	* testsuite/ld-i386/pr12570b.d: Likewise.
	* testsuite/ld-i386/pr19636-1d.d: Likewise.
	* testsuite/ld-i386/pr19636-1l.d: Likewise.
	* testsuite/ld-i386/pr19636-2c.d: Likewise.
	* testsuite/ld-i386/pr19636-2d.d: Likewise.
	* testsuite/ld-i386/pr19636-2e.d: Likewise.
	* testsuite/ld-i386/pr20244-1a.d: Likewise.
	* testsuite/ld-i386/pr20244-1b.d: Likewise.
	* testsuite/ld-i386/pr20244-2a.d: Likewise.
	* testsuite/ld-i386/pr20244-2b.d: Likewise.
	* testsuite/ld-i386/pr20244-2c.d: Likewise.
	* testsuite/ld-i386/pr20244-4a.d: Likewise.
	* testsuite/ld-i386/pr20244-4b.d: Likewise.
	* testsuite/ld-i386/pr21884.d: Likewise.
	* testsuite/ld-ifunc/binutils.exp: Likewise.
	* testsuite/ld-ifunc/ifunc-10-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-10-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-11-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-11-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-12-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-12-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-13-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-13-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-14a-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-14a-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-14b-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-14b-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-14c-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-14c-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-14d-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-14d-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-14e-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-14e-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-14f-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-14f-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-15-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-15-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-16-i386-now.d: Likewise.
	* testsuite/ld-ifunc/ifunc-16-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-16-x86-64-now.d: Likewise.
	* testsuite/ld-ifunc/ifunc-16-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-17a-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-17a-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-17b-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-17b-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-18a-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-18a-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-18b-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-18b-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-19a-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-19a-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-19b-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-19b-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-2-i386-now.d: Likewise.
	* testsuite/ld-ifunc/ifunc-2-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-2-local-i386-now.d: Likewise.
	* testsuite/ld-ifunc/ifunc-2-local-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-2-local-x86-64-now.d: Likewise.
	* testsuite/ld-ifunc/ifunc-2-local-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-2-x86-64-now.d: Likewise.
	* testsuite/ld-ifunc/ifunc-2-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-20-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-20-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-21-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-21-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-22-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-22-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-5a-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-5a-local-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-5a-local-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-5a-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-5b-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-5b-local-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-5b-local-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-5b-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-5r-local-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-5r-local-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-6a-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-6a-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-6b-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-6b-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-7a-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-7a-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-7b-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-7b-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-8-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-8-x86-64.d: Likewise.
	* testsuite/ld-ifunc/ifunc-9-i386.d: Likewise.
	* testsuite/ld-ifunc/ifunc-9-x86-64.d: Likewise.
	* testsuite/ld-ifunc/pr17154-i386-now.d: Likewise.
	* testsuite/ld-ifunc/pr17154-i386.d: Likewise.
	* testsuite/ld-ifunc/pr17154-x86-64-now.d: Likewise.
	* testsuite/ld-ifunc/pr17154-x86-64.d: Likewise.
	* testsuite/ld-plugin/lto.exp: Likewise.
	* testsuite/ld-x86-64/align-branch-1.d: Likewise.
	* testsuite/ld-x86-64/dwarfreloc.exp: Likewise.
	* testsuite/ld-x86-64/line.exp: Likewise.
	* testsuite/ld-x86-64/load1a.d: Likewise.
	* testsuite/ld-x86-64/load1b.d: Likewise.
	* testsuite/ld-x86-64/load1c.d: Likewise.
	* testsuite/ld-x86-64/load1d.d: Likewise.
	* testsuite/ld-x86-64/pie3.d: Likewise.
	* testsuite/ld-x86-64/pr18160.d: Likewise.
	* testsuite/ld-x86-64/pr19013-x32.d: Likewise.
	* testsuite/ld-x86-64/pr19013.d: Likewise.
	* testsuite/ld-x86-64/pr19636-2d.d: Likewise.
	* testsuite/ld-x86-64/pr19636-2l.d: Likewise.
	* testsuite/ld-x86-64/pr20253-1b.d: Likewise.
	* testsuite/ld-x86-64/pr20253-1d.d: Likewise.
	* testsuite/ld-x86-64/pr20253-1f.d: Likewise.
	* testsuite/ld-x86-64/pr20253-1h.d: Likewise.
	* testsuite/ld-x86-64/pr20253-1j.d: Likewise.
	* testsuite/ld-x86-64/pr20253-1l.d: Likewise.
	* testsuite/ld-x86-64/pr21884.d: Likewise.
	* testsuite/ld-x86-64/pr22393-3a.rd: Likewise.
	* testsuite/ld-x86-64/pr22393-3b.rd: Likewise.
	* testsuite/ld-x86-64/tlsgd10.dd: Likewise.
	* testsuite/ld-x86-64/tlsgd5.dd: Likewise.
	* testsuite/ld-x86-64/tlsgd8.dd: Likewise.
	* testsuite/ld-x86-64/x86-64.exp: Likewise.
	* emulparams/elf32_x86_64_nacl.sh: Removed.
	* emulparams/elf_i386_nacl.sh: Likewise.
	* emulparams/elf_x86_64_nacl.sh: Likewise.
	* testsuite/ld-i386/emit-relocs-nacl.rd: Likewise.
	* testsuite/ld-i386/load1-nacl.d: Likewise.
	* testsuite/ld-i386/pie1-nacl.d: Likewise.
	* testsuite/ld-i386/plt-nacl.pd: Likewise.
	* testsuite/ld-i386/plt-pic-nacl.pd: Likewise.
	* testsuite/ld-i386/pr17709-nacl.rd: Likewise.
	* testsuite/ld-i386/pr19636-1d-nacl.d: Likewise.
	* testsuite/ld-i386/pr19636-2c-nacl.d: Likewise.
	* testsuite/ld-i386/pr19636-2d-nacl.d: Likewise.
	* testsuite/ld-i386/pr19636-2e-nacl.d: Likewise.
	* testsuite/ld-i386/pr19827-nacl.rd: Likewise.
	* testsuite/ld-i386/pr21884-nacl.d: Likewise.
	* testsuite/ld-i386/pr21884-nacl.t: Likewise.
	* testsuite/ld-i386/tlsbin-nacl.rd: Likewise.
	* testsuite/ld-i386/tlsbin2-nacl.rd: Likewise.
	* testsuite/ld-i386/tlsbindesc-nacl.rd: Likewise.
	* testsuite/ld-i386/tlsdesc-nacl.rd: Likewise.
	* testsuite/ld-i386/tlsgdesc-nacl.rd: Likewise.
	* testsuite/ld-i386/tlsnopic-nacl.rd: Likewise.
	* testsuite/ld-i386/tlspic-nacl.rd: Likewise.
	* testsuite/ld-i386/tlspic2-nacl.rd: Likewise.
	* testsuite/ld-x86-64/ilp32-4-nacl.d: Likewise.
	* testsuite/ld-x86-64/load1a-nacl.d: Likewise.
	* testsuite/ld-x86-64/load1b-nacl.d: Likewise.
	* testsuite/ld-x86-64/load1c-nacl.d: Likewise.
	* testsuite/ld-x86-64/load1d-nacl.d: Likewise.
	* testsuite/ld-x86-64/pie3-nacl.d: Likewise.
	* testsuite/ld-x86-64/plt-nacl.pd: Likewise.
	* testsuite/ld-x86-64/pr17709-nacl.rd: Likewise.
	* testsuite/ld-x86-64/pr19013-nacl.d: Likewise.
	* testsuite/ld-x86-64/pr19636-2d-nacl.d: Likewise.
	* testsuite/ld-x86-64/pr19827-nacl.rd: Likewise.
	* testsuite/ld-x86-64/pr21884-nacl.d: Likewise.
	* testsuite/ld-x86-64/pr21884-nacl.t: Likewise.
	* testsuite/ld-x86-64/split-by-file-nacl.rd: Likewise.
	* testsuite/ld-x86-64/tlsbin-nacl.rd: Likewise.
	* testsuite/ld-x86-64/tlsbin2-nacl.rd: Likewise.
	* testsuite/ld-x86-64/tlsbindesc-nacl.rd: Likewise.
	* testsuite/ld-x86-64/tlsdesc-nacl.pd: Likewise.
	* testsuite/ld-x86-64/tlsdesc-nacl.rd: Likewise.
	* testsuite/ld-x86-64/tlsgdesc-nacl.rd: Likewise.
	* testsuite/ld-x86-64/tlspic-nacl.rd: Likewise.
	* testsuite/ld-x86-64/tlspic2-nacl.rd: Likewise.
	* Makefile.in: Regenerated.
	* po/BLD-POTFILES.in: Likewise.
2020-06-30 08:56:14 -07:00
Nick Clifton
5568cc9ee8 Add support for attributes using DW_FORM_GNU_strp_alt
* dwarf.c (read_and_display_attr_value): Support
	DW_FORM_GNU_strp_alt when used with DW_AT_dwo_name and
	DW_AT_comp_dir.
2020-06-30 13:05:18 +01:00
Alan Modra
d74b88ed7f Fix nds32*-elf XPASS readelf -wiaoRlL dw5
The underlying fail was probably fixed with git commit fbaf61ad5.

	* testsuite/binutils-all/readelf.exp (readelf_dump_test): Remove
	xfail for nds32.
2020-06-30 13:32:04 +09:30
Hans-Peter Nilsson
9f27c36482 binutils/dwarf.c: Correct an `index' global shadowing error for pre-4.8 GCC
In older gcc, shadowing a function name with a local variable name is
flagged as an error, certainly a bug but which is usually worked
around in binutils:

gcc -DHAVE_CONFIG_H -I. -I$SRC/binutils  -I. -I$SRC/binutils -I../bfd -I$SRC/binutils/../bfd -I$SRC/binutils/../include -DLOCALEDIR="\"/usr/local/share/locale\"" -Dbin_dummy_emulation=bin_vanilla_emulation  -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Werror -I$SRC/binutils/../zlib -g -O2 -MT dwarf.o -MD -MP -MF $depbase.Tpo -c -o dwarf.o $SRC/binutils/dwarf.c &&\
	mv -f $depbase.Tpo $depbase.Po
cc1: warnings being treated as errors
$SRC/binutils/dwarf.c: In function 'display_debug_str_offsets':
$SRC/binutils/dwarf.c:6913: error: declaration of 'index' shadows a global declaration
/usr/include/string.h:309: error: shadowed declaration is here
make[4]: *** [dwarf.o] Error 1

See also GCC PR c/53066.  This is just another one that crept in since
I and others last had to use an old version.  The name "idx" was used
in the preceding function, display_debug_addr.  Also, it was declared
c99 style (after a statement in the block).  Committed as obvious.

binutils:
	* dwarf.c (display_debug_str_offsets): Rename local variable
	index to idx.  Move to top of function.
2020-06-29 03:50:45 +02:00
Alan Modra
279edac53d C++ comments
binutils isn't c99 (yet).  This replaces or removes some C++ style
comments.

bfd/
	* arc-got.h: Use C style comments.
	* coff-z80.c: Likewise.
	* elf32-csky.c: Likewise.
	* peXXigen.c: Likewise.
	* elf32-m32c.c (m32c_elf_relax_delete_bytes): Remove commented out
	code.
binutils/
	* dwarf.c: Use C style comments.
	* resrc.c: Likewise.
gas/
	* config/tc-s12z.c: Use C style comments.
	* config/tc-z80.c: Likewise.
	* config/tc-xtensa.c (emit_ld_r_n): Remove commented out code.
include/
	* coff/internal.h: Use C style comments.
	* coff/pe.h: Likewise.
	* elf/ppc64.h: Likewise.
opcodes/
	* arm-dis.c: Use C style comments.
	* cr16-opc.c: Likewise.
	* ft32-dis.c: Likewise.
	* moxie-opc.c: Likewise.
	* tic54x-dis.c: Likewise.
	* s12z-opc.c: Remove useless comment.
	* xgate-dis.c: Likewise.
2020-06-29 10:07:56 +09:30
Alan Modra
cfc16775b7 asan: readelf: use after free in process_archive
This tidies up in cases where fuzzed thin archives hit the error return
path in setup_nested_archive.

	* elfcomm.c (setup_nested_archive): Set nested_arch->file to NULL
	after freeing.
	(release_archive): Set fields of arch to NULL after freeing.
2020-06-27 12:55:35 +09:30
Nick Alcock
2f6ecaed66 libctf, binutils: support CTF archives like objdump
objdump and readelf have one major CTF-related behavioural difference:
objdump can read .ctf sections that contain CTF archives and extract and
dump their members, while readelf cannot.  Since the linker often emits
CTF archives, this means that readelf intermittently and (from the
user's perspective) randomly fails to read CTF in files that ld emits,
with a confusing error message wrongly claiming that the CTF content is
corrupt.  This is purely because the archive-opening code in libctf was
needlessly tangled up with the BFD code, so readelf couldn't use it.

Here, we disentangle it, moving ctf_new_archive_internal from
ctf-open-bfd.c into ctf-archive.c and merging it with the helper
function in ctf-archive.c it was already using.  We add a new public API
function ctf_arc_bufopen, that looks very like ctf_bufopen but returns
an archive given suitable section data rather than a ctf_file_t: the
archive is a ctf_archive_t, so it can be called on raw CTF dictionaries
(with no archive present) and will return a single-member synthetic
"archive".

There is a tiny lifetime tweak here: before now, the archive code could
assume that the symbol section in the ctf_archive_internal wrapper
structure was always owned by BFD if it was present and should always be
freed: now, the caller can pass one in via ctf_arc_bufopen, wihch has
the usual lifetime rules for such sections (caller frees): so we add an
extra field to track whether this is an internal call from ctf-open-bfd,
in which case we still free the symbol section.

include/
	* ctf-api.h (ctf_arc_bufopen): New.
libctf/
	* ctf-impl.h (ctf_new_archive_internal): Declare.
	(ctf_arc_bufopen): Remove.
	(ctf_archive_internal) <ctfi_free_symsect>: New.
	* ctf-archive.c (ctf_arc_close): Use it.
	(ctf_arc_bufopen): Fuse into...
	(ctf_new_archive_internal): ... this, moved across from...
	* ctf-open-bfd.c: ... here.
	(ctf_bfdopen_ctfsect): Use ctf_arc_bufopen.
	* libctf.ver: Add it.
binutils/
	* readelf.c (dump_section_as_ctf): Support .ctf archives using
	ctf_arc_bufopen.  Automatically load the .ctf member of such
	archives as the parent of all other members, unless specifically
	overridden via --ctf-parent.  Split out dumping code into...
	(dump_ctf_archive_member): ... here, as in objdump, and call
	it once per archive member.
	(dump_ctf_indent_lines): Code style fix.
2020-06-26 15:56:39 +01:00
Nick Alcock
094e34f221 binutils, ld: work with --disable-libctf
This unfortunately means conditionalizing out all the libctf code, but
the result is not too unbearably ugly, if a bit repetitive.  I have
stubbed out code in the !ENABLE_LIBCTF path to avoid extra redundant
ifdefs where it seems that might be helpful.  (The stubs are not too
disruptive, but I've tried to keep them on one line where possible to
avoid filling up the screen with stubs that nobody would care about.
If this is too much of a coding style violation I can change it.)

Changes since v2: use GCC_ENABLE rather than repeating all the
                  AC_ARG_ENABLE stuff over and over again.

ld/
	* configure.ac [--enable-libctf]: New, default yes.
	Set ENABLE_LIBCTF accordingly.
	* Makefile.am [!ENABLE_LIBCTF]: Empty LIBCTF.
	* configure: Regenerate.
	* config.in: Regenerate.
	* Makefile.in: Regenerate.
	* aclocal.m4: Regenerate.
	* ldlang.c (ctf_output): Conditionalize on ENABLE_LIBCTF.
	(ldlang_open_ctf): Likewise.
	(lang_merge_ctf): Likewise.
	(ldlang_ctf_apply_strsym): Likewise.
	(lang_write_ctf): Likewise.
	(ldlang_write_ctf_late): Likewise.
	(ldlang_open_ctf) [!ENABLE_LIBCTF]: Warn about the presence of CTF
	sections.
	(lang_merge_ctf) [!ENABLE_LIBCTF]: New stub.
	(ldlang_ctf_apply_strsym) [!ENABLE_LIBCTF]: Likewise.
	(lang_write_ctf) [!ENABLE_LIBCTF]: Likewise.
	(ldlang_write_ctf_late) [!ENABLE_LIBCTF]: Likewise.
	* ldelfgen.c (ldelf_emit_ctf_early): Conditionalize on
	ENABLE_LIBCTF.
	(struct ctf_strsym_iter_cb_arg): Likewise.
	(ldelf_ctf_strtab_iter_cb): Likewise.
	(ldelf_ctf_symbols_iter_cb): Likewise.
	(ldelf_examine_strtab_for_ctf): Likewise.
	(ldelf_emit_ctf_early) [!ENABLE_LIBCTF]: New stub.
	(ldelf_examine_strtab_for_ctf) [!ENABLE_LIBCTF]: New stub.

binutils/
	* configure.ac [--enable-libctf]: New, default yes.
	Set ENABLE_LIBCTF accordingly.
	* Makefile.am [!ENABLE_LIBCTF]: Empty LIBCTF and LIBCTF_NOBFD.
	* configure: Regenerate.
	* config.in: Regenerate.
	* Makefile.in: Regenerate.
	* aclocal.m4: Regenerate.
	* objdump.c (usage): Conditionalize portions on ENABLE_LIBCTF.
	(option_values): Likewise.
	(long_options): Likewise.
	(main): Likewise.
	(dump_ctf_indent_lines): Conditionalize out when !ENABLE_LIBCTF.
	(make_ctfsect): Likewise.
	(dump_ctf_archive_member): Likewise.
	(dump_ctf) [ENABLE_LIBCTF]: Likewise.
	(dump_ctf) [!ENABLE_LIBCTF]: New empty stub.
	* readelf.c (options): Conditionalize portions on ENABLE_LIBCTF.
	(usage): Likewise.
	(process_section_contents): Likewise.
	(shdr_to_ctf_sect): Conditionalize out when !ENABLE_LIBCTF.
	(dump_ctf_indent_lines): Likewise.
	(dump_section_as_ctf) [ENABLE_LIBCTF]: Likewise.
2020-06-26 15:56:39 +01:00
Jan Beulich
2a1bb84c67 x86: fix processing of -M disassembler option
Multiple -M options can be specified in any order. Therefore stright
assignment to fields affected needs to be avoided, such that earlier
options' effects won't be discarded. This was in particular a problem
for -Msuffix followed by certain of the other sub-options.

While updating documentation, take the liberty and also drop the
redundant mentioning of being able to comma-separate multiple options.
2020-06-26 16:42:55 +02:00
Pat Bernardi
85f7484a3a m68k: tag floating-point ABI used
This patch adds GNU attribute support to m68k and utilises it to tag the
floating-point calling convention used (hard-float or soft-float). It enables
the linker to ensure linked objects use a consistent floating-point ABI and
allows tools like GDB to infer the ABI used from the ELF file. It is based on
similar work done for PowerPC.

bfd/
	* elf32-m68k.c (m68k_elf_merge_obj_attributes): New function.
	(elf32_m68k_merge_private_bfd_data): Merge GNU attributes.
binutils/
	* readelf.c (display_m68k_gnu_attribute): New function.
	(process_arch_specific): Call display_m68k_gnu_attribute for EM_68K.
gas/
	* config/tc-m68k.c (m68k_elf_gnu_attribute): New function.
	(md_pseudo_table): Handle "gnu_attribute".
	* doc/as.texi: Document GNU attribute for M68K.
include/
	* elf/m68k.h: Add enum for GNU object attribute with floating point
	tag name and values.
ld/
	* testsuite/ld-m68k/attr-gnu-4-0.s: New file.
	* testsuite/ld-m68k/attr-gnu-4-1.s: Likewise.
	* testsuite/ld-m68k/attr-gnu-4-2.s: Likewise.
	* testsuite/ld-m68k/attr-gnu-4-00.d: Likewise.
	* testsuite/ld-m68k/attr-gnu-4-01.d: Likewise.
	* testsuite/ld-m68k/attr-gnu-4-02.d: Likewise.
	* testsuite/ld-m68k/attr-gnu-4-10.d: Likewise.
	* testsuite/ld-m68k/attr-gnu-4-11.d: Likewise.
	* testsuite/ld-m68k/attr-gnu-4-12.d: Likewise.
	* testsuite/ld-m68k/attr-gnu-4-20.d: Likewise.
	* testsuite/ld-m68k/attr-gnu-4-21.d: Likewise.
	* testsuite/ld-m68k/attr-gnu-4-22.d: Likewise.
	* testsuite/ld-m68k/m68k.exp: Run the new tests.
2020-06-26 14:42:19 +09:30
H.J. Lu
d0dded5bc2 Add a testcase for PR binutils/26160
PR binutils/26160
	* testsuite/binutils-all/pr26160.dwp.bz2: New file.
	* testsuite/binutils-all/pr26160.r: Likewise.
	* testsuite/binutils-all/readelf.exp: Run PR binutils/26160 test.
2020-06-23 09:20:28 -07:00
Nick Clifton
39f381cb80 Fix decoding of indexed DWARF strings using pre-DWARF-5 string offset sections. Fix display of .debug_str_offsets.dwo sections.
PR 26160
	* dwarf.c (fetch_indexed_string): Detect and handle old style
	.debug_str_offset tables.
	(display_debug_str_offsets): Likewise.  Also add support for
	.debug_str_offsets.dwo sections.
2020-06-23 16:06:38 +01:00
H.J. Lu
80fda85ca1 Add a testcase for PR binutils/26112
PR binutils/26112
	* testsuite/binutils-all/pr26112.o.bz2: New file.
	* testsuite/binutils-all/pr26112.r: Likewise.
	* testsuite/binutils-all/readelf.exp: Run PR binutils/26112 test.
2020-06-23 06:52:41 -07:00
Alan Modra
d081ffffa0 binutils objdump.exp remote_file typo
* testsuite/binutils-all/objdump.exp (bintest.a): Correct
	remote_file delete command.
2020-06-23 11:02:56 +09:30
Nick Clifton
e4b7104b1e Add support for decoding the DW_MACRO_define_strx and DW_MACRO_undef_strx operands found in DWARF-5 .debug_macro sections.
PR 26112
	* dwarf.c (display_debug_str_offsets): Add code to display the
	contents of the .debug_str_offsets section.
	(display_debug_macro): Add support for DW_MACRO_define_strx and
	DW_MACRO_undef_strx.
2020-06-22 17:44:56 +01:00
Saagar Jha
d768f160a9 Recognize some new Mach-O load commands
bfd
	* mach-o.c: Support the new load commands by reading a linkedit data
	command for them.
binutils
	* od-macho.c: Dump linkedit data for new load commands.
include
	* mach-o/loader.h: Add declarations of two new Mach-O load
	commands.
2020-06-22 14:29:20 +01:00
Alan Modra
5fd104addf Emit a warning when -z relro is unsupported
ld silently accepts -z relro and -z norelro for targets that lack the
necessary GNU_RELRO support.  This patch makes those targets emit a
warning instead, and adds testsuite infrastructure to detect when
relro is unsupported.

binutils/
	* testsuite/config/default.exp (ld_elf_shared_opt): Don't set.
	* testsuite/lib/binutils-common.exp (check_relro_support): New proc.
	(run_dump_test): Use check_relro_support to decide whether to pass
	extra ld option "-z norelro".
ld/
	* emultempl/elf.em (gld${EMULATION_NAME}_handle_option): Omit
	-z relro and -z norelro when target support for GNU_RELRO is lacking.
	(gld${EMULATION_NAME}_before_parse): Ignore RELRO default too.
	* emultempl/aarch64elf.em (gld${EMULATION_NAME}_before_parse): Ignore
	RELRO default when target support for GNU_RELRO is lacking.
	* emultempl/armelf.em (gld${EMULATION_NAME}_before_parse): Likewise.
	* emultempl/linux.em (gld${EMULATION_NAME}_before_parse): Likewise.
	* emultempl/scoreelf.em (gld${EMULATION_NAME}_before_parse): Likewise.
	* testsuite/config/default.exp (ld_elf_shared_opt): Don't set.
	* testsuite/ld-elf/pr16322.d: xfail when no relro support.
	* testsuite/ld-elf/pr22393-1a.d: Likewise.
	* testsuite/ld-elf/pr22393-1b.d: Likewise.
	* testsuite/ld-elf/shared.exp (pr20995-2.so, pr20995-2): Likewise.
	* testsuite/lib/ld-lib.exp (run_ld_link_tests): Use check_relro_support
	to decide whether to pass extra ld option "-z norelro".
2020-06-19 09:50:20 +09:30
Alan Modra
fd17d1e695 Re: asan: readelf: process_mips_specific buffer overflow
Let's do without that unnecessary internal option buffer.  This also
fixes another bug in that the REGINFO data was being taken from the
calloc'd internal option buffer, so was all zeros.

	* readelf.c (process_mips_specific): Don't alloc memory for
	Elf_Internal_Options.
2020-06-11 14:50:48 +09:30
Alan Modra
d0c4e7802d asan: readelf: process_mips_specific buffer overflow
DT_MIPS_OPTIONS is not a regular array as assumed by readelf.  This
patch corrects that assumption, and to do so easily, makes various
internal (host byte order) structs the same size as external (target
byte order) structs.

include/
	* elf/mips.h (Elf32_RegInfo): Use fixed width integer types.
	(Elf64_Internal_RegInfo, Elf_Internal_Options): Likewise.
binutils/
	* readelf.c (process_mips_specific): Assert size of internal
	types match size of external types, and simplify allocation of
	internal buffer.  Catch possible integer overflow when sanity
	checking option size.  Don't assume options are a regular array.
	Sanity check reginfo option against option size.  Use PRI macros
	when printing.
2020-06-11 13:54:46 +09:30
Ralf Habacker
25065fcd19 Fix the windmc program to conform to the behaviour of mc.exe by rejecting lines that reach end-of-file without a terminating newline character.
PR 26082
	* mclex.c (yylex): Reject lines that reach end-of-file without a
	terminating newline character.
2020-06-10 10:07:26 +01:00
Nick Clifton
b37a771440 Fix a typo in the description of the strings program.
PR 26093
	* doc/binutils.texi (strings): Fix typo.
2020-06-08 11:32:15 +01:00
Nick Clifton
c4b2f181c3 Fix an illegal memory access when parsing corrupt DWARF debug information.
PR 26086
	* dwarf.c (process_debug_info): Check that there is space in the
	debug_information array before filling in an entry.
2020-06-08 11:24:06 +01:00
Alan Modra
1424c35d07 Power10 tidies
binutils/
	* doc/binutils.texi (PowerPC -M option): Mention power10 and pwr10.
gas/
	* config/tc-ppc.c (md_show_usage): Mention -mpower10 and -mpwr10.
	* doc/c-ppc.texi: Likewise.
opcodes/
	* ppc-dis.c (ppc_opts): Accept -mpwr10/-Mpwr10.
2020-06-06 14:44:32 +09:30
Joel Anderson
8affa48ac7 Fix a potential infinite loop in the Windows resource parser.
PR 26082
	* mclex.c (yylex): Add test for an empty input stream.
2020-06-05 11:11:03 +01:00
Stephen Casner
8eca5c7d9f Fix unresolved test in binutils for pdp11.
* binutils/testsuite/binutils-all/pr25662-pdp11.s: Alternate source file
for test using section pseudo-ops compatible with pdp11.
* binutils/testsuite/binutils-all/objcopy.exp: Select alternate source.
2020-06-04 23:41:57 -07:00
Jose E. Marchesi
b3db6d07be opcodes: support insn endianness in cgen_cpu_open
This patch adds support for a new CGEN_OPEN_INSN_ENDIAN argument
for @arch@_cgen_cpu_open.  This is useful for architectures in
which the endianness of the instruction words is not the same
than the endianness used for data.

An accompanying patch has been sent to the CGEN mailing list that
adds support for this argument on the CGEN side [1].  Its been
already pre-approved [2], and will be applied simultaneously with
this binutils series.

[1] https://sourceware.org/pipermail/cgen/2020q2/002733.html
[2] https://sourceware.org/pipermail/cgen/2020q2/002737.html

include/ChangeLog:

2020-06-04  Jose E. Marchesi  <jemarch@gnu.org>

	* opcode/cgen.h (enum cgen_cpu_open_arg): New value
	CGEN_CPU_OPEN_INSN_ENDIAN.

opcodes/ChangeLog:

2020-06-04  Jose E. Marchesi  <jemarch@gnu.org>

	* cgen-dis.in (cpu_desc_list): New field `insn_endian'.
	(print_insn_): Handle instruction endian.
	* bpf-dis.c: Regenerate.
	* bpf-desc.c: Regenerate.
	* epiphany-dis.c: Likewise.
	* epiphany-desc.c: Likewise.
	* fr30-dis.c: Likewise.
	* fr30-desc.c: Likewise.
	* frv-dis.c: Likewise.
	* frv-desc.c: Likewise.
	* ip2k-dis.c: Likewise.
	* ip2k-desc.c: Likewise.
	* iq2000-dis.c: Likewise.
	* iq2000-desc.c: Likewise.
	* lm32-dis.c: Likewise.
	* lm32-desc.c: Likewise.
	* m32c-dis.c: Likewise.
	* m32c-desc.c: Likewise.
	* m32r-dis.c: Likewise.
	* m32r-desc.c: Likewise.
	* mep-dis.c: Likewise.
	* mep-desc.c: Likewise.
	* mt-dis.c: Likewise.
	* mt-desc.c: Likewise.
	* or1k-dis.c: Likewise.
	* or1k-desc.c: Likewise.
	* xc16x-dis.c: Likewise.
	* xc16x-desc.c: Likewise.
	* xstormy16-dis.c: Likewise.
	* xstormy16-desc.c: Likewise.

binutils/ChangeLog:

2020-06-04  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* objdump.c (disassemble_data): Set disasm_info.endian_code to
        disasm_info.endian after the latter is initialized to the
        endianness reported by BFD.
2020-06-04 16:17:42 +02:00
Alan Modra
0a4f37af5c tcl global directive outside proc body does nothing (binutils)
* testsuite/binutils-all/i386/i386.exp
	* testsuite/binutils-all/x86-64/objects.exp
	* testsuite/binutils-all/x86-64/x86-64.exp
2020-06-04 16:11:23 +09:30
Joel Anderson
913e0fd473 [PATCH] fix windmc typedef bug
While a typedef can be specified in message files for the messages following
with the `MessageIdTypedef` directive, only the last typedef was honored by
windmc. This corrects this behavior, matching mc.exe functionality.

	* windmc.h (struct mc_node): Add id_typecast field.
	* mcparse.y (message): Initialise the id_typecast field.
	* windmc.c (write_dbg): Use the id_typecast field as a parameter
	when calling write_dbg_define.
	(write_header): Likewise.
2020-06-03 16:44:37 +01:00
Alan Modra
4a32244804 PR26069, strip/objcopy memory leaks
PR 26069
	* objcopy.c (copy_relocations_in_section): Free relpp on error.
	Don't accidentally free isection->orelocation.
2020-06-03 17:59:44 +09:30
Alan Modra
0bee4d1c08 binutils archive tests
There are a number of targets that don't support thin archives (*),
and vms doesn't even support file name extensions other than .obj for
archives containing object files.  This patch adjusts the testsuite
to cater for the vms restriction, and reenables testing for non-ELF
alpha targets.  That adds a few alpha-dec-vms fails and one
alpha-linuxecoff fail but testsuite fails on those targets are nothing
new.

(*) It might seem like they do if binutils is built with
--enable-plugins but the plugin archive support is broken, causing the
wrong type of archives to be created by ar for those targets.

	* testsuite/binutils-all/ar.exp (obj): Set up object file name
	extension.  Use throughout.  Don't completely exclude non-ELF
	alpha targets.  Run long_filenames test for tic30.  Exclude thin
	archive tests for aix, ecoff and vms.
	* estsuite/binutils-all/objdump.exp (obj): Set up object file name
	extension.  Use throughout.  Don't exclude non-ELF alpha targets
	from "bintest.a".
2020-06-02 15:00:14 +09:30
Max Filippov
ab7ad28739 binutils: Add myself as Xtensa maintainer
2020-05-28  Max Filippov  <jcmvbkbc@gmail.com>
binutils/
	* MAINTAINERS (Xtensa): Add myself as maintainer.
2020-05-28 21:06:51 -07:00
Alan Modra
3f3c36087e ar many_files test
This tests for the issue fixed with git commit 0490dd41ae.

	* testsuite/binutils-all/ar.exp (many_files): New test.
2020-05-23 14:56:07 +09:30
Alan Modra
9db70fc365 Replace "if (x) free (x)" with "free (x)", binutils
* addr2line.c: Replace "if (x) free (x)" with "free (x)" throughout.
	* dlltool.c: Likewise.
	* elfcomm.c: Likewise.
	* rddbg.c: Likewise.
	* readelf.c: Likewise.
	* stabs.c: Likewise.
	* windmc.c: Likewise.
	* windres.c: Likewise.
	* wrstabs.c: Likewise.
2020-05-21 10:45:33 +09:30
Alan Modra
c31ab5a001 asan: readelf: wild read in get_num_dynamic_syms
* readelf.c (get_num_dynamic_syms): Bounds check mipsxlat array
	access.
2020-05-21 10:11:57 +09:30
Nelson Chu
8f595e9b4f [PATCH v2 0/9] RISC-V: Support version controling for ISA standard extensions and CSR
1. Remove the -mriscv-isa-version and --with-riscv-isa-version options.
We can still use -march to choose the version for each extensions, so there is
no need to add these.

2. Change the arguments of options from [1p9|1p9p1|...] to [1.9|1.9.1|...].
Unlike the architecture string has specified by spec, ther is no need to do
the same thing for options.

3. Spilt the patches to reduce the burdens of review.

[PATCH 3/7] RISC-V: Support new GAS options and configure options to set ISA versions
to
[PATCH v2 3/9] RISC-V: Support GAS option -misa-spec to set ISA versions
[PATCH v2 4/9] RISC-V: Support configure options to set ISA versions by default.

[PATCH 4/7] RISC-V: Support version checking for CSR according to privilege version.
to
[PATCH v2 5/9] RISC-V: Support version checking for CSR according to privilege spec version.
[PATCH v2 6/9] RISC-V: Support configure option to choose the privilege spec version.

4. Use enum class rather than string to compare the choosen ISA spec in opcodes/riscv-opc.c.
The behavior is same as comparing the choosen privilege spec.

include	* opcode/riscv.h: Include "bfd.h" to support bfd_boolean.
	(enum riscv_isa_spec_class): New enum class.  All supported ISA spec
	belong to one of the class
	(struct riscv_ext_version): New structure holds version information
	for the specific ISA.
	* opcode/riscv-opc.h (DECLARE_CSR): There are two version information,
	define_version and abort_version.  The define_version means which
	privilege spec is started to define the CSR, and the abort_version
	means which privilege spec is started to abort the CSR.  If the CSR is
	valid for the newest spec, then the abort_version should be
	PRIV_SPEC_CLASS_DRAFT.
	(DECLARE_CSR_ALIAS): Same as DECLARE_CSR, but only for the obselete CSR.
	* opcode/riscv.h (enum riscv_priv_spec_class): New enum class.  Define
	the current supported privilege spec versions.
	(struct riscv_csr_extra): Add new fields to store more information
	about the CSR.  We use these information to find the suitable CSR
	address when user choosing a specific privilege spec.

binutils * dwarf.c: Updated since DECLARE_CSR is changed.

opcodes	* riscv-opc.c (riscv_ext_version_table): The table used to store
	all information about the supported spec and the corresponding ISA
	versions.  Currently, only Zicsr is supported to verify the
	correctness of Z sub extension settings.  Others will be supported
	in the future patches.
	(struct isa_spec_t, isa_specs): List for all supported ISA spec
	classes and the corresponding strings.
	(riscv_get_isa_spec_class): New function.  Get the corresponding ISA
	spec class by giving a ISA spec string.
	* riscv-opc.c (struct priv_spec_t): New structure.
	(struct priv_spec_t priv_specs): List for all supported privilege spec
	classes and the corresponding strings.
	(riscv_get_priv_spec_class): New function.  Get the corresponding
	privilege spec class by giving a spec string.
	(riscv_get_priv_spec_name): New function.  Get the corresponding
	privilege spec string by giving a CSR version class.
	* riscv-dis.c: Updated since DECLARE_CSR is changed.
	* riscv-dis.c: Add new disassembler option -Mpriv-spec to dump the CSR
	according to the chosen version.  Build a hash table riscv_csr_hash to
	store the valid CSR for the chosen pirv verison.  Dump the direct
	CSR address rather than it's name if it is invalid.
	(parse_riscv_dis_option_without_args): New function.  Parse the options
	without arguments.
	(parse_riscv_dis_option): Call parse_riscv_dis_option_without_args to
	parse the options without arguments first, and then handle the options
	with arguments.  Add the new option -Mpriv-spec, which has argument.
	* riscv-dis.c (print_riscv_disassembler_options): Add description
	about the new OBJDUMP option.

ld	* testsuite/ld-riscv-elf/attr-merge-arch-01.d: Updated
        priv attributes according to the -mpriv-spec option.
	* testsuite/ld-riscv-elf/attr-merge-arch-02.d: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-arch-03.d: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-priv-spec-a.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-priv-spec-b.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-priv-spec.d: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-stack-align.d: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-strict-align-01.d: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-strict-align-02.d: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-strict-align-03.d: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-strict-align-04.d: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-strict-align-05.d: Likewise.

bfd 	* elfxx-riscv.h (riscv_parse_subset_t): Add new callback function
	get_default_version.  It is used to find the default version for
	the specific extension.
	* elfxx-riscv.c (riscv_parsing_subset_version): Remove the parameters
	default_major_version and default_minor_version.  Add new bfd_boolean
	parameter *use_default_version.  Set it to TRUE if we need to call
	the callback rps->get_default_version to find the default version.
	(riscv_parse_std_ext): Call rps->get_default_version if we fail to find
	the default version in riscv_parsing_subset_version, and then call
	riscv_add_subset to add the subset into subset list.
	(riscv_parse_prefixed_ext): Likewise.
	(riscv_std_z_ext_strtab): Support Zicsr extensions.
	* elfnn-riscv.c (riscv_merge_std_ext): Use strcasecmp to compare the
	strings rather than characters.
	riscv_merge_arch_attr_info): The callback function get_default_version
	is only needed for assembler, so set it to NULL int the linker.
	* elfxx-riscv.c (riscv_estimate_digit): Remove the static.
	* elfxx-riscv.h: Updated.

gas	* testsuite/gas/riscv/priv-reg-fail-read-only-01.s: Updated.
	* config/tc-riscv.c (default_arch_with_ext, default_isa_spec):
	Static variables which are used to set the ISA extensions. You can
	use -march (or ELF build attributes) and -misa-spec to set them,
	respectively.
	(ext_version_hash): The hash table used to handle the extensions
	with versions.
	(init_ext_version_hash): Initialize the ext_version_hash according
	to riscv_ext_version_table.
	(riscv_get_default_ext_version): The callback function of
	riscv_parse_subset_t.  According to the choosed ISA spec,
	get the default version for the specific extension.
	(riscv_set_arch): Set the callback function.
	(enum options, struct option md_longopts): Add new option -misa-spec.
	(md_parse_option): Do not call riscv_set_arch for -march.  We will
	call it later in riscv_after_parse_args.  Call riscv_get_isa_spec_class
	to set default_isa_spec class.
	(riscv_after_parse_args): Call init_ext_version_hash to initialize the
	ext_version_hash, and then call riscv_set_arch to set the architecture
	with versions according to default_arch_with_ext.
	* testsuite/gas/riscv/attribute-02.d: Set 0p0 as default version for
	x extensions.
	* testsuite/gas/riscv/attribute-03.d: Likewise.
	* testsuite/gas/riscv/attribute-09.d: New testcase.  For i-ext, we
	already set it's version to 2p1 by march, so no need to use the default
	2p2 version.  For m-ext, we do not set the version by -march and ELF arch
	attribute, so set the default 2p0 to it.  For zicsr, it is not defined in
	ISA spec 2p2, so set 0p0 to it.
	* testsuite/gas/riscv/attribute-10.d: New testcase.  The version of
	zicsr is 2p0 according to ISA spec 20191213.
	* config/tc-riscv.c (DEFAULT_RISCV_ARCH_WITH_EXT)
	(DEFAULT_RISCV_ISA_SPEC): Default configure option settings.
	You can set them by configure options --with-arch and
	--with-isa-spec, respectively.
	(riscv_set_default_isa_spec): New function used to set the
	default ISA spec.
	(md_parse_option): Call riscv_set_default_isa_spec rather than
	call riscv_get_isa_spec_class directly.
	(riscv_after_parse_args): If the -isa-spec is not set, then we
	set the default ISA spec according to DEFAULT_RISCV_ISA_SPEC by
	calling riscv_set_default_isa_spec.
	* testsuite/gas/riscv/attribute-01.d: Add -misa-spec=2.2, since
	the --with-isa-spec may be set to different ISA spec.
	* testsuite/gas/riscv/attribute-02.d: Likewise.
	* testsuite/gas/riscv/attribute-03.d: Likewise.
	* testsuite/gas/riscv/attribute-04.d: Likewise.
	* testsuite/gas/riscv/attribute-05.d: Likewise.
	* testsuite/gas/riscv/attribute-06.d: Likewise.
	* testsuite/gas/riscv/attribute-07.d: Likewise.
	* configure.ac: Add configure options, --with-arch and
	--with-isa-spec.
	* configure: Regenerated.
	* config.in: Regenerated.
	* config/tc-riscv.c (default_priv_spec): Static variable which is
	used to check if the CSR is valid for the chosen privilege spec. You
	can use -mpriv-spec to set it.
	(enum reg_class): We now get the CSR address from csr_extra_hash rather
	than reg_names_hash.  Therefore, move RCLASS_CSR behind RCLASS_MAX.
	(riscv_init_csr_hashes): Only need to initialize one hash table
	csr_extra_hash.
	(riscv_csr_class_check): Change the return type to void.  Don't check
	the ISA dependency if -mcsr-check isn't set.
	(riscv_csr_version_check): New function.  Check and find the CSR address
	from csr_extra_hash, according to default_priv_spec.  Report warning
	for the invalid CSR if -mcsr-check is set.
	(reg_csr_lookup_internal): Updated.
	(reg_lookup_internal): Likewise.
	(md_begin): Updated since DECLARE_CSR and DECLARE_CSR_ALIAS are changed.
	(enum options, struct option md_longopts): Add new GAS option -mpriv-spec.
	(md_parse_option): Call riscv_set_default_priv_version to set
	default_priv_spec.
	(riscv_after_parse_args): If -mpriv-spec isn't set, then set the default
	privilege spec to the newest one.
	(enum riscv_csr_class, struct riscv_csr_extra): Move them to
	include/opcode/riscv.h.
	* testsuite/gas/riscv/priv-reg-fail-fext.d: This test case just want
	to check the ISA dependency for CSR, so fix the spec version by adding
	-mpriv-spec=1.11.
	* testsuite/gas/riscv/priv-reg-fail-fext.l: Likewise.  There are some
	version warnings for the test case.
	* gas/testsuite/gas/riscv/priv-reg-fail-read-only-01.d: Likewise.
	* gas/testsuite/gas/riscv/priv-reg-fail-read-only-01.l: Likewise.
	* gas/testsuite/gas/riscv/priv-reg-fail-read-only-02.d: Likewise.
	* gas/testsuite/gas/riscv/priv-reg-fail-rv32-only.d: Likewise.
	* gas/testsuite/gas/riscv/priv-reg-fail-rv32-only.l: Likewise.
	* gas/testsuite/gas/riscv/priv-reg-fail-version-1p9.d: New test case.
	Check whether the CSR is valid when privilege version 1.9 is choosed.
	* gas/testsuite/gas/riscv/priv-reg-fail-version-1p9.l: Likewise.
	* gas/testsuite/gas/riscv/priv-reg-fail-version-1p9p1.d: New test case.
	Check whether the CSR is valid when privilege version 1.9.1 is choosed.
	* gas/testsuite/gas/riscv/priv-reg-fail-version-1p9p1.l: Likewise.
	* gas/testsuite/gas/riscv/priv-reg-fail-version-1p10.d: New test case.
	Check whether the CSR is valid when privilege version 1.10 is choosed.
	* gas/testsuite/gas/riscv/priv-reg-fail-version-1p10.l: Likewise.
	* gas/testsuite/gas/riscv/priv-reg-fail-version-1p11.d: New test case.
	Check whether the CSR is valid when privilege version 1.11 is choosed.
	* gas/testsuite/gas/riscv/priv-reg-fail-version-1p11.l: Likewise.
	* config/tc-riscv.c (DEFAULT_RISCV_ISA_SPEC): Default configure option
	setting.  You can set it by configure option --with-priv-spec.
	(riscv_set_default_priv_spec): New function used to set the default
	privilege spec.
	(md_parse_option): Call riscv_set_default_priv_spec rather than
	call riscv_get_priv_spec_class directly.
	(riscv_after_parse_args): If -mpriv-spec isn't set, then we set the
	default privilege spec according to DEFAULT_RISCV_PRIV_SPEC by
	calling riscv_set_default_priv_spec.
	* testsuite/gas/riscv/csr-dw-regnums.d: Add -mpriv-spec=1.11, since
	the --with-priv-spec may be set to different privilege spec.
	* testsuite/gas/riscv/priv-reg.d: Likewise.
	* configure.ac: Add configure option --with-priv-spec.
	* configure: Regenerated.
	* config.in: Regenerated.
	* config/tc-riscv.c (explicit_attr): Rename explicit_arch_attr to
	explicit_attr.  Set it to TRUE if any ELF attribute is found.
	(riscv_set_default_priv_spec): Try to set the default_priv_spec if
	the priv attributes are set.
	(md_assemble): Set the default_priv_spec according to the priv
	attributes when we start to assemble instruction.
	(riscv_write_out_attrs): Rename riscv_write_out_arch_attr to
	riscv_write_out_attrs.  Update the arch and priv attributes.  If we
	don't set the corresponding ELF attributes, then try to output the
	default ones.
	(riscv_set_public_attributes): If any ELF attribute or -march-attr
	options is set (explicit_attr is TRUE), then call riscv_write_out_attrs
	to update the arch and priv attributes.
	(s_riscv_attribute): Make sure all arch and priv attributes are set
	before any instruction.
	* testsuite/gas/riscv/attribute-01.d: Update the priv attributes if any
	ELF attribute or -march-attr is set.  If the priv attributes are not
	set, then try to update them by the default setting (-mpriv-spec or
	--with-priv-spec).
	* testsuite/gas/riscv/attribute-02.d: Likewise.
	* testsuite/gas/riscv/attribute-03.d: Likewise.
	* testsuite/gas/riscv/attribute-04.d: Likewise.
	* testsuite/gas/riscv/attribute-06.d: Likewise.
	* testsuite/gas/riscv/attribute-07.d: Likewise.
	* testsuite/gas/riscv/attribute-08.d: Likewise.
	* testsuite/gas/riscv/attribute-09.d: Likewise.
	* testsuite/gas/riscv/attribute-10.d: Likewise.
	* testsuite/gas/riscv/attribute-unknown.d: Likewise.
	* testsuite/gas/riscv/attribute-05.d: Likewise.  Also, the priv spec
	set by priv attributes must be supported.
	* testsuite/gas/riscv/attribute-05.s: Likewise.
	* testsuite/gas/riscv/priv-reg-fail-version-1p9.d: Likewise.  Updated
	priv attributes according to the -mpriv-spec option.
	* testsuite/gas/riscv/priv-reg-fail-version-1p9p1.d: Likewise.
	* testsuite/gas/riscv/priv-reg-fail-version-1p10.d: Likewise.
	* testsuite/gas/riscv/priv-reg-fail-version-1p11.d: Likewise.
	* testsuite/gas/riscv/priv-reg.d: Removed.
	* testsuite/gas/riscv/priv-reg-version-1p9.d: New test case.  Dump the
	CSR according to the priv spec 1.9.
	* testsuite/gas/riscv/priv-reg-version-1p9p1.d: New test case.  Dump the
	CSR according to the priv spec 1.9.1.
	* testsuite/gas/riscv/priv-reg-version-1p10.d: New test case.  Dump the
	CSR according to the priv spec 1.10.
	* testsuite/gas/riscv/priv-reg-version-1p11.d: New test case.  Dump the
	CSR according to the priv spec 1.11.
	* config/tc-riscv.c (md_show_usage): Add descriptions about
	the new GAS options.
	* doc/c-riscv.texi: Likewise.
2020-05-20 17:22:48 +01:00
H.J. Lu
8ac10c5bfc Allow readelf to issue warnings if checking is enabled and there are discrepancies between the dynamic tags and the dynamic sections.
PR binutils/25809
	* readelf.c (process_program_headers): Warn if the PT_DYNAMIC
	segment doesn't match the .dynamic section and checks are
	enabled.
	(struct filedata): Add dynamic_symtab_section and
	dynamic_strtab_section fields.
	(process_section_headers): Set dynamic_symtab_section to the
	.dynsym section.  Set dynamic_strtab_section to the .dynstr
	section.
	(process_dynamic_section): Warn if the .dynsym section doesn't
	match DT_SYMTAB and DT_SYMENT or the .dynstr section doesn't
	DT_STRTAB and DT_STRSZ.  But only if checks are enabled.
2020-05-19 16:47:12 +01:00
Alan Modra
c177f3771c Use bfd_get_filename throughout binutils
* ar.c (map_over_members, get_pos_bfd, delete_members, move_members),
	(replace_members): Use bfd_get_filename rather than accessing
	bfd->filename directly.
	* arsup.c (map_over_list, ar_delete, ar_replace, ar_extract): Likewise.
	* binemul.c (do_ar_emul_append): Likewise.
	* coffgrok.c (coff_grok): Likewise.
2020-05-19 12:35:56 +09:30
Stafford Horne
83d27139ca binutils: Add myself as maintainer for OpenRISC
binutils/ChangeLog:

yyyy-mm-dd  Stafford Horne  <shorne@gmail.com>

	* MAINTAINERS (OR1K): Add myself as maintainer.
2020-05-18 05:27:13 +09:00
Andrew Burgess
d11a9fabab objcopy: Mention 'entry address' in description
The ELF header contains a start address, which is also sometimes
called the entry address.  The 'objdump -x' output calls this field
the 'start address', while readelf calls it 'entry point address'.
The linker talks about setting the 'entry' point in its manual.

I've always thought of this field as the 'entry address', and so when
I recently wanted to know if objcopy could adjust this field I opened
up the manual and searched for 'entry', which found no hits.

I thought it would be useful (for people like me) if the description
of 'set-start' and 'adjust-start' in the objcopy manual mentioned the
word 'entry' to make it easier to find.

binutils/ChangeLog:

	* doc/binutils.texi: Mention 'entry address' in the set-start and
	adjust-start options descriptions.
2020-05-07 11:39:39 +01:00
Nick Clifton
546cb2d85e Restore readelf's warnings that describe real problems with the file being examined. Fix bug displaying empty file name tables.
binutils* dwarf.c (do_checks): New global variable.
	(display_formatted_table): Warn about an unexpected number of
	columns in the table, if checks are enabled.  Do not complain
	about the lack of data following the number of entries in the
	table if the table is empty.
	(display_debug_lines_decoded): Only warn about an unexpected
	number of columns in a table if checks are enabled.
	* dwarf.h (do_checks): Add a prototype.
	* elfcomm.c (error): Remove weak attribute.
	(warn): Likewise.
	* readelf.c (do_checks): Delete.
	(warn): Delete.
	(process_section_headers): Only warn about empty sections if
	checks are enabled.

gas	* dwarf2dbg.c (out_dir_and_file_list): Add comments describing the
	construction of a DWARF-5 directory name table.
	* testsuite/gas/elf/pr25917.d: Update expected output.
2020-05-05 16:16:03 +01:00
Fangrui Song
e052e2ba29 [PATCH] objcopy: Allow --dump-section to dump an empty SEC_HAS_CONTENTS section
* objcopy.c (copy_object): Allow empty section.
	* testsuite/binutils-all/update-section.exp: Add test.
2020-05-04 17:04:25 +01:00
Nick Clifton
070b775f03 GAS: Do not create an entry for the default directory if the directory table is empty. Improve readelf's decoding of empty directory and file name tables.
PR 25917
	* dwarf.c (display_debug_lines_decoded): Warn if encountering a
	supicious number of entries for DWARF-5 format directory and file
	name tables.  Do not display file name table header if the table
	is empty.  Do not allocate space for empty tables.
2020-05-04 13:50:05 +01:00
Alan Modra
9c7b8e9b92 readelf: nds32 specific decoding
* readelf.c (process_nds32_specific): Check size of .nds32_e_flags
	section.  Don't assume endian of host matches nds32 target.  Free
	buffer.
2020-05-04 11:28:40 +09:30
Alan Modra
6083233224 objdump: long run time when using -D -z
The zero scan is silly when the result isn't used.

	* objdump.c (disassemble_bytes): Don't scan for zeros when
	disassembling zeros.  Translate "resuming at file offset" message.
	Formatting.  Replace some signed variables with unsigned.
2020-05-01 15:32:36 +09:30
Alex Coplan
09c1e68a16 AArch64: add GAS support for UDF instruction
binutils * testsuite/binutils-all/aarch64/in-order-all.d: Update to use new
          disassembly.
        * testsuite/binutils-all/aarch64/out-of-order-all.d: Likewise.

ld/     * testsuite/ld-aarch64/erratum843419_tls_ie.d: Use udf in disassembly.
        * testsuite/ld-aarch64/farcall-b-section.d: Likewise.
        * testsuite/ld-aarch64/farcall-back.d: Likewise.
        * testsuite/ld-aarch64/farcall-bl-section.d: Likewise.

gas/   * config/tc-aarch64.c (fix_insn): Implement for AARCH64_OPND_UNDEFINED.
          (parse_operands): Implement for AARCH64_OPND_UNDEFINED.
        * testsuite/gas/aarch64/udf.s: New.
        * testsuite/gas/aarch64/udf.d: New.
        * testsuite/gas/aarch64/udf-invalid.s: New.
        * testsuite/gas/aarch64/udf-invalid.l: New.
        * testsuite/gas/aarch64/udf-invalid.d: New.

include * opcode/aarch64.h (enum aarch64_opnd): Add AARCH64_OPND_UNDEFINED.

opcodes * aarch64-opc.h (enum aarch64_field_kind): Add FLD_imm16_2.
        * aarch64-opc.c (fields): Add entry for FLD_imm16_2.
          (operand_general_constraint_met_p): validate AARCH64_OPND_UNDEFINED.
        * aarch64-tbl.h (aarch64_opcode_table): Add udf instruction, entry for
          FLD_imm16_2.
        * aarch64-asm-2.c: Regenerated.
        * aarch64-dis-2.c: Regenerated.
        * aarch64-opc-2.c: Regenerated.
2020-04-30 15:47:30 +01:00
Nick Clifton
8a8a117123 Add generic tests for linker support of the -shared or -pie options to tests which use them.
binutils* testsuite/lib/binutils-common.exp (check_pie_support): New
	proc.

ld	* testsuite/ld-elf/compress1c.d: XFAIL if thet target linker does
	not support the -shared command line option.
	* /ld-elf/compressed1c.d: Likewise.
	* /ld-elf/compressed1e.d: Likewise.
	* /ld-elf/dynamic1.d: Likewise.
	* /ld-elf/dynsym1.d: Likewise.
	* /ld-elf/ehdr_start-shared.d: Likewise.
	* /ld-elf/exclude3b.d: Likewise.
	* /ld-elf/global1.d: Likewise.
	* /ld-elf/hash.d: Likewise.
	* /ld-elf/local1.d: Likewise.
	* /ld-elf/mbind1b.d: Likewise.
	* /ld-elf/now-1.d: Likewise.
	* /ld-elf/now-2.d: Likewise.
	* /ld-elf/now-3.d: Likewise.
	* /ld-elf/now-4.d: Likewise.
	* /ld-elf/pr12975.d: Likewise.
	* /ld-elf/pr13177.d: Likewise.
	* /ld-elf/pr13195.d: Likewise.
	* /ld-elf/pr16322.d: Likewise.
	* /ld-elf/pr16498a.d: Likewise.
	* /ld-elf/pr16498b.d: Likewise.
	* /ld-elf/pr17615.d: Likewise.
	* /ld-elf/pr19162.d: Likewise.
	* /ld-elf/pr19698.d: Likewise.
	* /ld-elf/pr20513c.d: Likewise.
	* /ld-elf/pr20513d.d: Likewise.
	* /ld-elf/pr21389a.d: Likewise.
	* /ld-elf/pr21389b.d: Likewise.
	* /ld-elf/pr21389c.d: Likewise.
	* /ld-elf/pr21562a.d: Likewise.
	* /ld-elf/pr21562b.d: Likewise.
	* /ld-elf/pr21562c.d: Likewise.
	* /ld-elf/pr21562d.d: Likewise.
	* /ld-elf/pr21562e.d: Likewise.
	* /ld-elf/pr21562f.d: Likewise.
	* /ld-elf/pr21562g.d: Likewise.
	* /ld-elf/pr21562h.d: Likewise.
	* /ld-elf/pr21562i.d: Likewise.
	* /ld-elf/pr21562j.d: Likewise.
	* /ld-elf/pr21562k.d: Likewise.
	* /ld-elf/pr21562l.d: Likewise.
	* /ld-elf/pr21562m.d: Likewise.
	* /ld-elf/pr21562n.d: Likewise.
	* /ld-elf/pr21903a.d: Likewise.
	* /ld-elf/pr21903b.d: Likewise.
	* /ld-elf/pr22269b.d: Likewise.
	* /ld-elf/pr22393-1a.d: Likewise.
	* /ld-elf/pr22393-1b.d: Likewise.
	* /ld-elf/pr23658-1c.d: Likewise.
	* /ld-elf/pr25708.d: Likewise.
	* /ld-elf/rpath-1.d: Likewise.
	* /ld-elf/rpath-2.d: Likewise.
	* /ld-elf/runpath-1.d: Likewise.
	* /ld-elf/runpath-2.d: Likewise.
	* /ld-elf/sizeofb.d: Likewise.
	* /ld-elf/startofb.d: Likewise.
	* /ld-elf/strtab.d: Likewise.
	* /ld-elf/textaddr2.d: Likewise.
	* /ld-elf/textaddr5.d: Likewise.
	* /ld-elf/textaddr6.d: Likewise.
	* /ld-elf/unknown2.d: Likewise.
	* /ld-undefined/entry-3.d: Likewise.
	* /ld-undefined/entry-4.d: Likewise.
	* /ld-elf/mbind1c.d: XFAIL if the target linker does not support
	the -pie option.
	* /ld-elf/pie.d: Likewise.
	* /ld-elf/pr19539.d: Likewise.
	* /ld-elf/pr21903d.d: Likewise.
	* /ld-elf/pr22269a.d: Likewise.
	* /ld-elf/pr22393-1c.d: Likewise.
	* /ld-elf/pr22393-1d.d: Likewise.
	* /ld-elf/pr22423.d: Likewise.
	* /ld-elf/loadaddr1.d: Expect to fail on the rx-linux target.
	* /ld-elf/loadaddr2.d: Likewise.
	* /ld-elf/pr22393-1e.d: Likewise.
	* /ld-elf/pr22393-1f.d: Likewise.
	* /ld-elf/textaddr1.d: Likewise.
	* /ld-elf/textaddr4.d: Likewise.
2020-04-30 13:49:30 +01:00
Andrew Burgess
cb4c35cfbe When displaying ranges, ignore duplicate offsets.
* dwarf.c (display_debug_ranges): Ignore duplicate entries in
	range_entries for the same offset.
2020-04-29 17:21:10 +01:00
Nick Clifton
1b51340159 Add a warning if an emtpty SHT_REL, SHT_RELA or SHT_PROGBITS section is detected. Disable all warnings unless the (new) lint mode is enabled.
* readelf.c (warn): New function - like elfcomm.c version but only
	produces output if warnings are enabled.
	(struct options): Add --lint and --enable-checks.
	(usage): Add entry for --lint.
	(parse_args): Handle -L.  If checks are enabled but no dumps have
	been selected then enable all dumps.
	(process_section_headers): Replace long if-then-else sequence with
	a switch.  Add warning messages for empty SHT_REL, SHT_RELA and
	SHT_PROGBITS sections.
	(process_file): Do not complain if the file is an archive and lint
	mode has been enabled.
	* elfcomm.c (error): Make the function weak.
	(warn): Likewise.
	* NEWS: Mention the new feature.
	* doc/binutils.texi: Document the new feature.
	* dwarf.h (report_leb_status): Add file name and line number
	parameters.  Include them in the diagnostic output.
	(READ_ULEB): Pass file and line number to report_leb_status.
	(READ_SLEB): Likewise.
	* dwarf.c (read_and_print_leb128): Pass file and line number to
	report_leb_status.
	* testsuite/binutils-all/readelf.exp: Add test of new feature.
	* testsuite/binutils-all/zero-sec.s: New test source file.
	* testsuite/binutils-all/zero-sec.r: Expected output from new
	test.
2020-04-29 16:01:40 +01:00
Nick Clifton
c2e71e57a0 Updated Serbian translation for the binutils sub-directory, and Swedish translation for the opcodes sub-directory. 2020-04-29 13:23:32 +01:00
Alan Modra
90837ea721 readelf: NULL dereference
This fixes another missing error check.

	* readelf.c (get_num_dynamic_syms): Check DT_MIPS_XHASH was
	read before dereferencing, and gracefully return.  Remove
	gnu_hash_error variable.  Free gnu hash arrays if number of
	syms found is zero.
2020-04-26 23:50:18 +09:30
Alan Modra
2482f30615 readelf: memory leaks in process_dynamic_section
This fixes some code that assumed only one PT_LOAD would contain
DT_SYMTAB.  Which is normally the case, but fuzzers thoroughly mess
with object files.

	* readelf.c (get_num_dynamic_syms): Check for nbuckets and nchains
	non-zero.
	(process_dynamic_section): Call get_num_dynamic_syms once rather
	than in segment loop.  Break out of segment loop on a successful
	load of dynamic symbols.  Formatting.
	(process_object): Return error status from process_dynamic_section.
2020-04-24 10:52:26 +09:30
Anton Kolesov
2745674244 arc: Add support for ARC HS extra registers in core files
When a coredump is generated, there are a few registers in
ARC HS that are put under a special section, namely ".reg-v2".
It is for backward compatibility reasons with older tools that
we have decided not to extend the generic ".reg" section.

This patch makes it possible to display the information better
regarding that section.  Compare the output of "readelf" without
and with these changes:

$ readelf -n core     # without the patch
  ...
  LINUX    0x0000000c  Unknown note type: (0x00000600)
   description data: 78 08 00 00 2f 6c 64 2d 75 43 6c 69

$ readelf -n core     # with the patch
  ...
  LINUX    0x0000000c  NT_ARC_V2 (ARC HS accumulator/extra registers)
   description data: 78 08 00 00 2f 6c 64 2d 75 43 6c 69

In another commit (soon to be submitted), GDB will makes use of these
changes to parse the extra section and its registers.

bfd/ChangeLog
2020-03-26  Anton Kolesov  <anton.kolesov@synopsys.com>

	* elf-bfd.h (elfcore_write_arc_v2): Add prototype.
	* elf.c (elfcore_grok_arc_v2): New function.
	(elfcore_grok_note): Call the new function to handle the corresponding
	note.
	(elfcore_write_arc_v2): New function.
	(elfcore_write_register_note): Call the new function to handle the
	corresponding pseudo-sections.

binutils/ChangeLog
2020-03-26  Anton Kolesov  <anton.kolesov@synopsys.com>

	* readelf.c (get_note_type): Handle NT_ARC_V2.

include/elf/ChangeLog
2020-03-26  Anton Kolesov  <anton.kolesov@synopsys.com>

	* common.h (NT_ARC_V2): New macro definitions.
2020-04-23 11:09:09 +03:00
Max Filippov
30ce8e47fa xtensa: fix PR ld/25861
Introduce new relaxations XTENSA_PDIFF{8,16,32} for positive differences
(subtracted symbol precedes diminished symbol) and XTENSA_NDIFF{8,16,32}
for negative differences (subtracted symbol follows diminished symbol).
Don't generate XTENSA_DIFF relocations in the assembler, generate
XTENSA_PDIFF or XTENSA_NDIFF based on relative symbol position.

Handle XTENSA_DIFF in BFD for compatibility with old object files.
Handle XTENSA_PDIFF and XTENSA_NDIFF in BFD, treating difference value
as unsigned.

2020-04-22  Max Filippov  <jcmvbkbc@gmail.com>
bfd/
	* bfd-in2.h: Regenerated.
	* elf32-xtensa.c (elf_howto_table): New entries for
	R_XTENSA_PDIFF{8,16,32} and R_XTENSA_NDIFF{8,16,32}.
	(elf_xtensa_reloc_type_lookup, elf_xtensa_do_reloc)
	(relax_section): Add cases for R_XTENSA_PDIFF{8,16,32} and
	R_XTENSA_NDIFF{8,16,32}.
	* libbfd.h (bfd_reloc_code_real_names): Add names for
	BFD_RELOC_XTENSA_PDIFF{8,16,32} and
	BFD_RELOC_XTENSA_NDIFF{8,16,32}.
	* reloc.c: Add documentation for BFD_RELOC_XTENSA_PDIFF{8,16,32}
	and BFD_RELOC_XTENSA_NDIFF{8,16,32}.

binutils/
	* readelf.c (is_none_reloc): Recognize
	BFD_RELOC_XTENSA_PDIFF{8,16,32} and
	BFD_RELOC_XTENSA_NDIFF{8,16,32}.

gas/
	* config/tc-xtensa.c (md_apply_fix): Replace
	BFD_RELOC_XTENSA_DIFF{8,16,32} generation with
	BFD_RELOC_XTENSA_PDIFF{8,16,32} and
	BFD_RELOC_XTENSA_NDIFF{8,16,32} generation.
	* testsuite/gas/xtensa/loc.d: Replace BFD_RELOC_XTENSA_DIFF16
	with BFD_RELOC_XTENSA_PDIFF16 in the expected output.

include/
	* elf/xtensa.h (elf_xtensa_reloc_type): New entries for
	R_XTENSA_PDIFF{8,16,32} and R_XTENSA_NDIFF{8,16,32}.

ld/
	* testsuite/ld-xtensa/relax-loc.d: New test definition.
	* testsuite/ld-xtensa/relax-loc.s: New test source.
	* testsuite/ld-xtensa/xtensa.exp (relax-loc): New test.
2020-04-22 18:46:45 -07:00
Stephen Casner
d4f707c3b2 Add myself as maintainer for PDP11. 2020-04-22 13:30:36 -07:00
Nick Clifton
33b5a83027 Remove Chris Faylor as the ix86 PE maintainer.
* MAINTAINERS: Remove Chris Faylor as the ix86 PE maintainer.
2020-04-22 16:47:34 +01:00
Alan Modra
978c445051 readelf: move file related static vars to filedata
The idea here is to get rid of a lot of file related static vars used
to pass data around, in order to not have stale data about one object
file persisting to the next one.

	* readelf.c (archive_file_offset, archive_file_size, dynamic_addr),
	(dynamic_size, dynamic_nent, dynamic_strings, dynamic_strings_length),
	(num_dynamic_syms, nbuckets, nchains, buckets, chains),
	(ngnubuckets, gnubuckets, gnuchains, mipsxlat, ngnuchains),
	(gnusymidx, dynamic_symbols, dynamic_syminfo, dynamic_syminfo_offset),
	(dynamic_syminfo_nent, program_interpreter, dynamic_info),
	(dynamic_info_DT_GNU_HASH, dynamic_info_DT_MIPS_XHASH, version_info),
	(dynamic_section, symtab_shndx_list, group_count, section_groups),
	(section_headers_groups): Move to struct filedata.  Update use
	throughout file.
2020-04-22 21:02:50 +09:30
Alan Modra
6431e40968 readelf: cmdline data
Don't use a struct filedata for cmdline, which only needs two of the
filedata fields.

	* readelf.c (struct dump_data): New, used..
	(cmdline): ..here, and..
	(struct filedata): ..here.  Adjust all uses.
	(request_dump_bynumber, request_dump, parse_args): Pass in a
	struct dump_data* rather than Filedata*.  Adjust callers.
	(main): Don't set cmdline.file_name.
2020-04-22 21:02:50 +09:30
Alan Modra
3052c068aa fix typo last commit 2020-04-20 12:01:47 +09:30
Alan Modra
a5e0be5cb2 readelf: segfault at readelf.c:12227
This is another one where not cleaning up sufficiently after
processing one file can lead to errors when processing the next file.
We have ngnuchains non-zero but gnuchains NULL in the following:
  off < ngnuchains && (gnuchains[off] & 1) == 0

	* readelf.c (process_symbol_table): Clear ngnuchains, ngnubuckets
	and nbuckets.
2020-04-20 11:09:58 +09:30
Alan Modra
8ff66993e0 readelf: segfaults fuzzing multiple object files
This patch is aimed at fixing a number of oss-fuzz segfaults that
don't reproduce reliably with their current infrastructure, the
problem being that one invocation of readelf is effectively being run
on multiple object files.  I believe that these segfaults could be
reliably reproduced with just two fuzzed objects being presented to
readelf, but those inputs are currently not identified by oss-fuzz.
So there is some guesswork involved in this patch.  The idea here is
to clear stashed data such as symtab_shndx_list that is processed
using section header info, at the same time that header info is
cleared.

	* readelf.c (process_section_headers): Free dynamic symbols etc.
	earlier.
2020-04-20 11:09:43 +09:30
Alan Modra
ceb9bf11b9 readelf memory leaks
This fixes two leaks found in the new code supporting display of
dynamic symbols retrieved via dynamic tags.

	* readelf.c (get_num_dynamic_syms): Formatting.  Don't return
	on error without freeing.
	(process_dynamic_section): Don't recreate dynamic symbols from
	dynamic tag info when the dynamic symbols have already been
	read via section headers.
2020-04-20 08:15:05 +09:30
Fredrik Strupe
e409955ddc [PATCH v2] binutils: arm: Fix disassembly of conditional VDUPs.
VDUP (neon) instructions can be conditional, but this is not taken into
account in the current master. This commit fixes that by i) fixing the
VDUP instruction masks and ii) adding logic for disassembling
conditional neon instructions.

opcodes	* arm-dis.c (neon_opcodes): Fix VDUP instruction masks.
	(print_insn_neon): Support disassembly of conditional
	instructions.

binutils* testsuite/binutils-all/arm/vdup-cond.d: New test for testing that
	conditional VDUP instructions are disassembled correctly.
	* testsuite/binutils-all/arm/vdup-cond.s: New file used by
	vdup-cond.d.
	* testsuite/binutils-all/arm/vdup-thumb.d: New test for testing
	that VDUP instructions (which are conditional in A32) can be
	disassembled in thumb mode.
	* testsuite/binutils-all/arm/vdup-cond.s: New file used by
	vdup-thumb.d.
2020-04-17 17:25:19 +01:00
Alan Modra
ca3f923f82 PR25840, Null pointer dereference in objdump
PR 25840
	* debug.c (debug_class_type_samep): Don't segfault on NULL type.
2020-04-17 10:56:01 +09:30
Alan Modra
937f661468 Extend objdump --no-addresses info
* doc/binutils.texi: Mention --no-show-raw-insn in objdump
	--no-addresses description.
2020-04-16 12:53:55 +09:30
Alan Modra
b1bc1394df objdump --no-addresses
I find this useful when needing to compare compiler output, where the
address of the instruction and the value of symbols results in
unwanted differences.

	* objdump.c (no_addresses): New static var.
	(usage): Print help for --no-addresses.
	(long_options): Add --no-addresses entry.
	(objdump_print_addr_with_sym, objdump_print_addr): Omit symbol address.
	(disassemble_bytes): Don't print current line address, or reloc
	address.
	* doc/binutils.texi: Document objdump --no-addresses.
2020-04-15 19:26:55 +09:30
Alan Modra
001890e1f9 PR25822, Invalid read in process_symbol_table
PR 25822
	* readelf.c (get_num_dynamic_syms): Don't set num_of_syms when
	reading buckets or chains fails.
2020-04-15 17:03:22 +09:30
Alan Modra
b71d4fa7c3 readelf: zero static vars after freeing
When readelf is processing more than one file, static bss vars won't
start out as zero for the second file unless they are cleared.

	* readelf.c (process_symbol_table): Zero gnubuckets, gnuchains
	etc. after freeing.
2020-04-15 17:03:22 +09:30
Alan Modra
89246a0e79 readelf: increase size of static buffers
Translated strings might be larger than the original.

	* readelf.c (get_group_flags): Translate text.
	(get_file_type, get_symbol_binding, get_symbol_type),
	(get_ppc64_symbol_other, get_symbol_other): Increase size of buffer.
2020-04-15 17:03:17 +09:30
Alan Modra
c98a4545dc Re: readelf: Consolidate --syms --use-dynamic with --dyn-syms
PR 25821
	* readelf.c (get_num_dynamic_syms): Typo fix.
2020-04-15 12:45:41 +09:30
Alan Modra
645f43a80c readelf memory leaks processing mips
* readelf.c (process_mips_specific): Free eopt and iopt.  Avoid
	possibility of overflow when checking number of conflicts.
2020-04-14 23:39:05 +09:30
H.J. Lu
10ca4b042d readelf: Consolidate --syms --use-dynamic with --dyn-syms
When reconstructing dynamic symbol table from the PT_DYNAMIC segment,
compute dynamic symbol table size from hash table.  For DT_HASH, the
number of dynamic symbol table entries equals the number of chains.
For DT_GNU_HASH/DT_MIPS_XHASH, only defined symbols with non-STB_LOCAL
indings are in hash table.  Since DT_GNU_HASH/DT_MIPS_XHASH place all
symbols with STB_LOCAL binding before symbols with other bindings and
all undefined symbols defined ones in dynamic symbol table, the highest
symbol index in DT_GNU_HASH/DT_MIPS_XHASH is the highest dynamic symbol
table index.

Rewrite print_dynamic_symbol to dump dynamic symbol table for --dyn-syms
and --syms --use-dynamic.

binutils/

	PR binutils/25707
	* readelf.c (nbuckets): New.
	(nchains): Likewise.
	(buckets): Likewise.
	(chains): Likewise.
	(ngnubuckets): Likewise.
	(gnubuckets): Likewise.
	(gnuchains): Likewise.
	(mipsxlat): Likewise.
	(ngnuchains): Likewise.
	(gnusymidx): Likewise.
	(VALID_SYMBOL_NAME): Likewise.
	(VALID_DYNAMIC_NAME): Use it.
	(get_dynamic_data): Moved before process_dynamic_section.
	(get_num_dynamic_syms): New function.
	(process_dynamic_section): Use DT_SYMTAB, DT_SYMENT, DT_HASH,
	DT_GNU_HASH and DT_MIPS_XHASH to reconstruct dynamic symbol
	table.  Use DT_STRTAB and DT_STRSZ to reconstruct dynamic string
	table.
	(get_symbol_index_type): Don't print "bad section index" when
	there is no section header.
	(print_dynamic_symbol): Rewrite.
	(process_symbol_table): Call print_dynamic_symbol to dump dynamic
	symbol table.

ld/

	PR binutils/25707
	* testsuite/ld-arm/armthumb-lib.sym: Updated.
	* testsuite/ld-arm/farcall-mixed-app.sym: Likewise.
	* testsuite/ld-arm/farcall-mixed-app2.sym: Likewise.
	* testsuite/ld-arm/fdpic-main-m.sym: Likewise.
	* testsuite/ld-arm/fdpic-main.sym: Likewise.
	* testsuite/ld-arm/fdpic-shared-m.sym: Likewise.
	* testsuite/ld-arm/fdpic-shared.sym: Likewise.
	* testsuite/ld-arm/mixed-app.sym: Likewise.
	* testsuite/ld-arm/mixed-lib.sym: Likewise.
	* testsuite/ld-arm/preempt-app.sym: Likewise.
	* testsuite/ld-elf/hash.d: Likewise.
	* testsuite/ld-elf/pr13195.d: Likewise.
	* testsuite/ld-elfvsb/hidden2.d: Likewise.
	* testsuite/ld-mips-elf/hash2.d: Likewise.
2020-04-14 05:00:34 -07:00
Rainer Orth
bb89747721 ld: Disable ifunc tests on Solaris
A couple of ld ifunc tests currently FAIL on 64-bit Solaris/x86:

FAIL: ld-ifunc/ifunc-10-x86-64
FAIL: ld-ifunc/ifunc-11-x86-64
FAIL: ld-ifunc/ifunc-12-x86-64
FAIL: ld-ifunc/ifunc-13-x86-64
FAIL: ld-ifunc/ifunc-14a-x86-64
FAIL: ld-ifunc/ifunc-14b-x86-64
FAIL: ld-ifunc/ifunc-14c-x86-64
FAIL: ld-ifunc/ifunc-14d-x86-64
FAIL: ld-ifunc/ifunc-14e-x86-64
FAIL: ld-ifunc/ifunc-14f-x86-64
FAIL: ld-ifunc/ifunc-15-x86-64
FAIL: ld-ifunc/ifunc-17a-x86-64
FAIL: ld-ifunc/ifunc-17b-x86-64
FAIL: ld-ifunc/ifunc-2-local-x86-64-now
FAIL: ld-ifunc/ifunc-2-local-x86-64
FAIL: ld-ifunc/ifunc-2-x86-64-now
FAIL: ld-ifunc/ifunc-2-x86-64
FAIL: ld-ifunc/ifunc-20-x86-64
FAIL: ld-ifunc/pr17154-x86-64-now
FAIL: ld-ifunc/pr17154-x86-64

For one, the actual error is weird:

./ld-new: target elf64-x86-64 not found
failed with: <./ld-new: target elf64-x86-64 not found>, no expected output
FAIL: ld-ifunc/ifunc-10-x86-64

although ld -V does report the elf_x86_64 emulation as supported:

$ ./ld/ld-new -V
GNU ld (GNU Binutils) 2.34.50.20200328
  Supported emulations:
   elf_x86_64_sol2
   elf_x86_64
[...]

When using ld -m elf_x86_64_sol2 instead, one of the testcases links
successfully.

However, there's no point in pursuing this: Solaris does not support
ifunc, as can be seen in <sys/elf.h>:

/*
 * GNU/Linux specific symbol type not used by Solaris
 */
#define STT_GNU_IFUNC   10

and never will, given that it has symbol capabilities as solution to
effectively the same problem:

http://www.linker-aliens.org/blogs/rie/entry/symbol_capabilitie/

Therefore this patch disables ifunc testing on Solaris completely by
removing Solaris from binutils/testsuite/lib/binutils-common.exp
(supports_gnu_osabi).  The ifunc part is justified above.  SHF_GNU_MBIND is
in the OS-specific range and conflicts with

#define SHF_SUNW_REALLOC        0x01000000      /* internal: krtld realloc */

While the comment suggests this might be relocatable without too much
problems, the description of mbind (no formal spec AFAICS, just the
comment in the binutils patch submission) strongly suggests that this
isn't relevant to Solaris at all.

Indirectly, clearing supports_gnu_osabi on Solaris disables
supports_gnu_unique.  Again, Solaris <sys/elf.h> has

/*
 * GNU/Linux specific binding not used by Solaris
 */
#define STB_GNU_UNIQUE  10

so this seems the right thing to do.

Afterwards, one can remove the explicit mentions of *-*-solaris2* in
quite a number of (but not all) the ld-ifunc dump file notarget lists.

There's one fallout, though: two gas tests now XPASS because they are
xfail'ed for !supports_gnu_osabi:

XPASS: mbind sections 12
XPASS: mbind section contents 16
XPASS: mbind sections 16
XPASS: mbind section contents 16

To fix that, I've changed

#xfail: ![supports_gnu_osabi]

to notarget.

Tested on x86_64-pc-solaris2.11, i386-pc-solaris2.11,
x86_64-pc-linux-gnu, and i686-pc-linux-gnu.

	ld:
	* testsuite/ld-ifunc/ifunc-10-i386.d: Remove *-*-solaris2* from
	notarget.
	* ifunc-11-i386.d: Likewise.
	* ifunc-12-i386.d: Likewise.
	* ifunc-13-i386.d: Likewise.
	* ifunc-14a-i386.d: Likewise.
	* ifunc-14b-i386.d: Likewise.
	* ifunc-14c-i386.d: Likewise.
	* ifunc-14d-i386.d: Likewise.
	* ifunc-14e-i386.d: Likewise.
	* ifunc-14f-i386.d: Likewise.
	* ifunc-15-i386.d: Likewise.
	* ifunc-16-i386-now.d: Likewise.
	* ifunc-16-i386.d: Likewise.
	* ifunc-17a-i386.d: Likewise.
	* ifunc-17b-i386.d: Likewise.
	* ifunc-18a-i386.d: Likewise.
	* ifunc-18b-i386.d: Likewise.
	* ifunc-19a-i386.d: Likewise.
	* ifunc-19b-i386.d: Likewise.
	* ifunc-2-i386-now.d: Likewise.
	* ifunc-2-i386.d: Likewise.
	* ifunc-2-local-i386-now.d: Likewise.
	* ifunc-2-local-i386.d: Likewise.
	* ifunc-20-i386.d: Likewise.
	* ifunc-21-i386.d: Likewise.
	* ifunc-22-i386.d: Likewise.
	* ifunc-5a-i386.d: Likewise.
	* ifunc-5a-local-i386.d: Likewise.
	* ifunc-5b-i386.d: Likewise.
	* ifunc-5b-local-i386.d: Likewise.
	* ifunc-5r-local-i386.d: Likewise.
	* ifunc-6a-i386.d: Likewise.
	* ifunc-6b-i386.d: Likewise.
	* ifunc-7a-i386.d: Likewise.
	* ifunc-7b-i386.d: Likewise.
	* ifunc-8-i386.d: Likewise.
	* ifunc-9-i386.d: Likewise.
	* pr17154-i386-now.d: Likewise.
	* pr17154-i386.d: Likewise.

	* ifunc-23a-x86.d: Remove notarget.
	* ifunc-24a-x86.d: Likewise.
	* ifunc-25a-x86.d: Likewise.

	gas:
	* testsuite/gas/elf/section12a.d: Use notarget instead of xfail.
	* testsuite/gas/elf/section12b.d: Likewise.
	* testsuite/gas/elf/section16a.d: Likewise.
	* testsuite/gas/elf/section16b.d: Likewise.

	binutils:
	* testsuite/lib/binutils-common.exp (supports_gnu_osabi): Don't
	enable on *-*-solaris*.
2020-04-02 10:52:57 +02:00
Nick Clifton
00386881a3 Fix objcopy's --preserve-dates command line option so that it will work with PE format files.
PR binutils/pr25662
bfd	* libcoff-in.h (struct pe_tdata): Rename the insert_timestamp
	field to timestamp and make it an integer.
	* libcoff.h: Regenerate.
	* peXXigen.c (_bfd_XXi_only_swap_filehdr_out): Test the timestamp
	field in the pe_data structure rather than the insert_timestamp
	field.

binutils* objcopy.c (copy_object): When copying PE format files set the
	timestamp field in the pe_data structure if the preserve_dates
	flag is set.
	* testsuite/binutils-all/objcopy.exp (objcopy_test) Use
	--preserve-dates in place of the -p option, in order to make its
	effect more obvious.

ld	* emultempl/pe.em (after_open): Replace initialisation of the
	insert_timestamp field in the pe_data structure with an
	initialisation of the timestamp field.
	* emultemp/pep.em: Likewise.
	* pe-dll.c (fill_edata): Use the timestamp field in the pe_data
	structure instead of the insert_timestamp field.
2020-03-30 16:30:02 +01:00
Alan Modra
0a6a8b596b Re: Adjust objcopy_test
Last patch didn't manage to xfail spu due to clear_xfail *-*-*elf*.
Clearing *-*-*elf* dates back to a time when we had rather a lot more
setup_xfail patterns, so limiting it to hppa*-*-*elf*.  Also,
mips-*-irix ought to have been mips-*-irix* and I'm having second
thoughts about xfailing mips and hiding what looks like a problem: If
the mips target is supposed to emit names for local section symbols
and does so for objcopy, why isn't it doing the same for ld?  Also,
lots more mips targets would be subject to this test failing.  So I'm
backing out those xfails and leaving it to someone more knowledgeable
about mips.

	* testsuite/binutils-all/objcopy.exp (objcopy_test): Only
	clear_xfail hppa*-*-*elf*.  Revert mips xfails.
2020-03-28 14:40:58 +10:30
Alan Modra
6a81c59be7 Adjust objcopy_test
xfails spu due to a note section getting a different vma, and some
mips targets that give section symbols a name string.  I added -p
for the executable test in an attempt to fix all the pe target fails,
but that doesn't preserve the date/time for some reason.

	* testsuite/binutils-all/objcopy.exp (objcopy_test): Move xfails
	from here to calls.  Remove "m8*-*-*" entry.  Don't xfail tic54x
	but do xfail spu, mipstx39 and mips-sgi-irix for the executable
	test.  Pass "-p" to objcopy for the executable test.
2020-03-28 11:23:45 +10:30
Jozef Lawrynowicz
1fafefd594 Add testcase for PR 25662 invalid sh_offset for section
binutils/ChangeLog:

2020-03-27  Jozef Lawrynowicz  <jozef.l@mittosystems.com>

	PR binutils/25662
	* testsuite/binutils-all/objcopy.exp (objcopy_test): Add argument to
	specify whether an object file or executable should be built and tested.
	Change test names to report whether an object file or executable is
	being tested.
	* testsuite/binutils-all/pr25662.ld: New test.
	* testsuite/binutils-all/pr25662.s: New test.
2020-03-27 10:54:26 +00:00
Alan Modra
80e2a3b66e Re: readelf looping in process_archive
This patch fixes a leak of qualified_name caused by 4c83662712 and a
double free introduced by fd486f32d1.  Not breaking out of the loop
results in an error: "failed to seek to next archive header".  That's
slightly better than silently preventing the possibility of endless
loops.

	* readelf.c (process_archive): Don't double free qualified_name.
	Don't break out of loop with "negative" archive_file_size, just
	set file offset to max.
2020-03-27 10:37:18 +10:30
Alan Modra
4c83662712 readelf looping in process_archive
With a crafted "negative" ar_hdr.ar_size it is possible to make
readelf loop.  This patch catches the overflow in a file offset
calculation.

	* readelf.c (process_archive): Prevent endless loop.
2020-03-25 22:31:07 +10:30
H.J. Lu
1081065c51 bfd: Add a bfd_boolean argument to bfd_get_symbol_version_string
We can't call _bfd_elf_get_symbol_version_name from nm.c since it isn't
available for all target configurations.  This patch add a bfd_boolean
argument to bfd_get_symbol_version_string instead.

bfd/

	PR binutils/25708
	* elf-bfd.h (_bfd_elf_get_symbol_version_name): Renamed to ...
	(_bfd_elf_get_symbol_version_string): This.
	* elf.c (_bfd_elf_get_symbol_version_name): Renamed to ...
	(_bfd_elf_get_symbol_version_string): This.
	(bfd_elf_print_symbol): Pass TRUE to
	_bfd_elf_get_symbol_version_string.
	* libbfd-in.h (_bfd_nosymbols_get_symbol_version_string): Add a
	bfd_boolean argument.
	* syms.c (_bfd_nosymbols_get_symbol_version_string): Likewise.
	* targets.c  (_bfd_get_symbol_version_string): Likewise.
	(bfd_get_symbol_version_string): Likewise.
	* bfd-in2.h: Regenerated.

binutils/

	PR binutils/25708
	* nm.c (print_symname): Replace _bfd_elf_get_symbol_version_name
	with bfd_get_symbol_version_string.
	(print_symbo): Pass TRUE to bfd_get_symbol_version_string.
	* objdump.c (objdump_print_symname): Likewise.
2020-03-24 15:37:26 -07:00
H.J. Lu
7e6e972f74 bfd: Display symbol version for nm -D
Extend _bfd_elf_get_symbol_version_string for nm -D to display symbol
version.  _bfd_elf_get_symbol_version_name is added to avoid updating
all XXX_get_symbol_version_string functions.

bfd/

	PR binutils/25708
	* elf-bfd.h (_bfd_elf_get_symbol_version_name): New.
	* elf.c (_bfd_elf_get_symbol_version_name): New function.  Based
	on the previous _bfd_elf_get_symbol_version_string.
	(_bfd_elf_get_symbol_version_string): Use it.

binutils/

	PR binutils/25708
	* nm.c (SYM_NAME): Removed.
	(print_symname): Add a pointer to struct extended_symbol_info
	argument.  Call _bfd_elf_get_symbol_version_name to get symbol
	version.
	(print_symdef_entry): Pass NULL to print_symname.
	(print_symbol_info_bsd): Update call to print_symname.
	(print_symbol_info_sysv): Likewise.
	(print_symbol_info_posix): Likewise.

ld/

	PR binutils/25708
	* testsuite/ld-elf/pr25708.d: New file.
2020-03-24 04:23:11 -07:00
Alan Modra
5a814d6d96 readelf memory leak in process_mips_specific
* readelf.c (process_mips_specific): Free iconf on error path.
2020-03-24 13:19:14 +10:30
Nick Clifton
0636b24556 Avoid trigger an assertion failure in the STABS parser by replacing the abort with an error return.
PR 25714
	* wrstabs.c (stab_pop_type): Replace assertion with error return.
	* write_stabs_in_sections_debugging_info: Likewise.
	* stab_enum_type: Likewise.
	* stab_modify_type: Likewise.
	* stab_struct_field: Likewise.
	* stab_end_struct_type: Likewise.
	* stab_start_class_type: Likewise.
	* stab_class_static_member: Likewise.
	* stab_class_baseclass: Likewise.
	* stab_class_start_method: Likewise.
	* stab_class_method_var: Likewise.
	* stab_class_end_method: Likewise.
	* stab_end_class_type: Likewise.
	* stab_typedef_type: Likewise.
	* stab_start_function: Likewise.
	* stab_end_block: Likewise.
	* stab_lineno: Likewise.
2020-03-23 16:19:07 +00:00
Nick Clifton
5844b4657a Fix compile time warnings about the possibility of using uninitialised fields in the Elf_Internal_Chdr structure when building readelf.
* readelf.c (get_compression_header): Add ATTRIBUTE_WARN_UNUSED_RESULT.
	(process_section_headers): Check the return value from
	get_compression_header.
	(dump_section_as_strings): Likewise.
	(dump_section_as_bytes): Likewise.
	(load_specific_debug_section): Likewise.
2020-03-20 11:33:07 +00:00
H.J. Lu
3d98c46092 plugin: Don't invoke LTO-wrapper
Don't invoke LTO-wrapper since the LTO wrapper approach is not only
slow but also unreliable.  For GCC 10 or newer, LDPT_ADD_SYMBOLS_V2
will be used.

bfd/

	* configure.ac (HAVE_EXECUTABLE_SUFFIX): Removed.
	(EXECUTABLE_SUFFIX): Likewise.
	* config.in: Regenerated.
	* configure: Likewise.
	* plugin.c (bfd_plugin_close_and_cleanup): Defined as
	_bfd_generic_close_and_cleanup.
	(plugin_list_entry): Remove resolution_file, resolution_option,
	real_bfd, real_nsyms, real_syms, lto_nsyms, lto_syms, gcc,
	lto_wrapper, gcc_env and initialized,
	(need_lto_wrapper_p): Removed.
	(get_lto_wrapper): Likewise.
	(setup_lto_wrapper_env): Likewise.
	(register_all_symbols_read): Likewise.
	(egister_cleanup): Likewise.
	(get_symbols): Likewise.
	(add_input_file): Likewise.
	(bfd_plugin_set_program_name): Remove need_lto_wrapper.
	(add_symbols): Updated.
	(try_claim): Likewise.
	(try_load_plugin): Likewise.
	(bfd_plugin_canonicalize_symtab): Likewise.
	* plugin.h (bfd_plugin_set_program_name): Remove int argument.
	(plugin_data_struct): Remove real_bfd, real_nsyms and real_syms.

binutils/

	* ar.c (main): Update bfd_plugin_set_program_name call.
	* nm.c (main): Likewise.

ld/

	* testsuite/ld-plugin/lto.exp (lto_link_tests): Run PR ld/25355
	test only for GCC 10 or newer.
2020-03-20 03:55:30 -07:00
Nick Clifton
f3a08f7778 Fix discrepancies in nm's --line-number output by adding support for the DW_AT_specification DWARF Attttribute.
PR 25676
bfd	* dwarf2.c (struct varinfo): Add unit_offset field to record the
	location of the varinfo in the unit's debug info data.  Change the
	type of the stack field to a boolean.
	(lookup_var_by_offset): New function.  Returns the varinfo
	structure for the variable described at the given offset in the
	unit's debug info.
	(scan_unit_for_symbols): Add support for variables which have the
	DW_AT_specification attribute.

binutils* testsuite/binutils-all/dw4.s: New test source file.
	* testsuite/binutils-all/nm.exp: Run the new test.
2020-03-19 16:55:13 +00:00
H.J. Lu
ef3df11042 readelf.c: Use unsigned long to iterate over num_syms
process_symbol_table () has

  unsigned long num_syms;
  ...
  for (si = 0, psym = symtab; si < num_syms; si++, psym++)

We should use unsigned long to iterate over num_syms.

	* readelf.c (process_symbol_table): Use unsigned long for si.
2020-03-19 05:22:30 -07:00
Alan Modra
81a65eb338 Don't use bfd.h in binutils/elfcomm.c
Better than warning about bfd types, just don't include bfd.h and
warn against including the header again.

	* elfcomm.c: Don't include bfd.h or bucomm.h.
	(program_name): Declare.
	(process_archive_index_and_symbols): Replace bfd_boolean with int,
	and substitute FALSE and TRUE.
	(setup_archive, setup_nested_archive): Likewise.
	* elfcomm.h: Likewise.
2020-03-19 16:07:45 +10:30
Alan Modra
1cb7d8b1af readelf leak in process_archive
* readelf.c (process_archive): Always return via path freeing
	memory.  Formatting.
2020-03-19 12:22:32 +10:30
Alan Modra
b966f55ffa Invalid read in process_netbsd_elf_note
* readelf.c (process_netbsd_elf_note): Validate descsz before
	accessing descdata.  Formatting.
2020-03-19 12:22:00 +10:30
Alan Modra
645ba68105 setup_archive parameter mismatch
* elfcomm.c (setup_archive): Make file_size an off_t.  Comment.
	* elfcomm.h (setup_archive): Update prototype.
2020-03-19 11:55:04 +10:30
Alan Modra
28d1356774 asan: readelf leak in hppa_process_unwind
This extracts code reading symbol tables into a common function that
tidies up after errors.  I've also changed an error reporting multiple
string tables to an error on multiple symbol tables.

	* readelf.c (get_symbols): New function.
	(process_relocs, ia64_process_unwind, hppa_process_unwind),
	(arm_process_unwind, get_symbol_for_build_attribute): Use it.
2020-03-16 13:05:17 +10:30
Alan Modra
60e63c3e97 ubsan: shift exponent 70 is too large
* unwind-ia64.c (unw_decode_uleb128): Prevent overlarge shifts.
	Detect shift overflows and check that terminating byte is found.
	Print an error on a bad uleb128.
2020-03-16 13:04:49 +10:30
Alan Modra
1bd6175ae7 Re: asan: more readelf leaks
In git commit fd486f32d1 I put some static variables used by
get_symbol_for_build_attribute in a file scope ba_cache struct.  This
was to prevent leaks in get_symbol_for_build_attribute, and to tidy up
before readelf exited.  The patch wasn't quite right though.  When
readelf processes more than one file it was possible to double free
arrays allocated in get_symbol_for_build_attribute.

	* readelf.c (process_file): Clean ba_cache.
2020-03-14 20:23:52 +10:30
Alan Modra
780f96aed2 readelf large memory allocation
* elfcomm.h (setup_archive): Update prototype.
	* elfcomm.c (setup_archive): Add file_size parameter and sanity
	check longnames_size.
	(setup_nested_archive): Get file size and pass to setup_archive.
	* elfedit.c (process_archive): Likewise.
	* readelf.c (process_archive): Pass filedata->file_size to
	setup_archive.
2020-03-14 17:24:19 +10:30
Alan Modra
f761cb13a9 asan: readelf: memory leaks
* readelf.c (dump_section_as_strings): Free memory on error exit.
	(dump_section_as_bytes, process_notes_at): Likewise.
	(get_build_id): Free enote.
2020-03-14 17:24:19 +10:30
Kamil Rytarowski
06d949ec31 Implement NT_NETBSDCORE_LWPSTATUS (NetBSD-Core)
bfd/ChangeLog:

	* elf.c (elfcore_grok_netbsd_note): Add support for
	NT_NETBSDCORE_LWPSTATUS notes.

binutils/ChangeLog:

	* readelf.c (get_netbsd_elfcore_note_type): Add support for
	NT_NETBSDCORE_LWPSTATUS notes.

include/ChangeLog:

	* elf/common.h (NT_NETBSDCORE_LWPSTATUS): New define.
2020-03-14 00:31:16 +01:00
Alan Modra
fd486f32d1 asan: more readelf leaks
* elfcomm.c (get_archive_member_name): Always return malloc'd
	string or NULL.
	* elfedit.c (process_archive): Tidy memory on all return paths.
	* readelf.c (process_archive): Likewise.
	(process_symbol_table): Likewise.
	(ba_cache): New, replacing ..
	(get_symbol_for_build_attribute): ..static vars here.  Free
	strtab and symtab before loading new ones.  Reject symtab without
	valid strtab in loop, breaking out of loop on valid symtab.
	(process_file): Free ba_cache symtab and strtab here, resetting
	ba_cache.
2020-03-13 14:26:24 +10:30
Alan Modra
8fb879cd16 asan: readelf leaks
* readelf.c (process_section_headers): Don't just set
	filedata->section_headers NULL, free it first.  Similarly for
	dynamic_symbols, dynamic_strings, dynamic_syminfo and
	symtab_shndx_list.  Zero associated counts too.
	(process_object): Free symtab_shndx_list.
	(process_file): Free various allocated filedata tables.
2020-03-12 17:00:40 +10:30
Nick Clifton
5496f3c635 Add support for generating DWARF-5 format directory and file name tables from the assembler.
PR 25611
	PR 25614
	* dwarf.h (DWARF2_Internal_LineInfo): Add li_address_size and
	li_segment_size fields.
	* dwarf.c (read_debug_line_header): Record the address size and
	segment selector size values (if present) in the lineinfo
	structure.
	(display_formatted_table): Warn if the format count is empty but
	the table itself is not empty.
	Display the format count and entry count at the start of the table
	dump.
	(display_debug_lines_raw): Display the address size and segement
	selector size fields, if present.
	* testsuite/binutils-all/dw5.W: Update expected output.

gas	* dwarf2dbg.c (DWARF2_FILE_TIME_NAME): Default to -1.
	(DWARF2_FILE_SIZE_NAME): Default to -1.
	(DWARF2_LINE_VERSION): Default to the current dwarf level or 3,
	whichever is higher.
	(DWARF2_LINE_MAX_OPS_PER_INSN): Provide a default value of 1.
	(NUM_MD5_BYTES): Define.
	(struct file entry): Add md5 field.
	(get_filenum): Delete and replace with...
	(get_basename): New function.
	(get_directory_table_entry): New function.
	(allocate_filenum): New function.
	(allocate_filename_to_slot): New function.
	(dwarf2_where): Use new functions.
	(dwarf2_directive_filename): Add support for extended .file
	pseudo-op.
	(dwarf2_directive_loc): Allow the use of file number zero with
	DWARF 5 or higher.
	(out_file_list): Rename to...
	(out_dir_and_file_list): Add DWARF 5 support.
	(out_debug_line): Emit extra values into the section header for
	DWARF 5.
	(out_debug_str): Allow for file 0 to be used with DWARF 5.
	* doc/as.texi (.file): Update the description of this pseudo-op.
	* testsuite/gas/elf-dwarf-5-file0.s: Add more lines.
	* testsuite/gas/elf-dwarf-5-file0.d: Update expected dump output.
	* testsuite/gas/lns/lns-diag-1.l: Update expected error message.
	* NEWS: Mention the new feature.
2020-03-11 10:17:14 +00:00
Alan Modra
9cc89dc0ac PR25651, objcopy SIGSEGV in copy_object
With the right set of options, the second block of code dealing with
padding can see a different section count.  So don't use the new count.
Since I was editing those lines, I've also changed the code allocating
arrays a little.
    array = malloc (n * sizeof (*array));
for an array of ints is just better than
    array = malloc (n * sizeof (int));
It's easier to write correctly in the first place and more robust
against code changes that might modify the array element type.

	PR 25651
	* objcopy.c (copy_object): Test "gaps" not gap_fill_set or
	pad_to_set on second block of code dealing with padding.
	Replace "c" with "num_sec" and don't recalculate number of
	sections on second block.  Size arrays using sizeof (element)
	rather than sizeof (element type).
2020-03-11 15:01:15 +10:30
Alan Modra
41da082238 objdump disassembly of files without symbols
ubsan complains about memcpy with a NULL src even when size is zero.

	* objdump.c (disassemble_section): Don't call qsort unless
	sym count is at least two.
	(disassemble_data): Don't call memcpy with NULL src.
2020-03-10 13:54:01 +10:30
Alan Modra
9509988993 PR25645, readelf segfault reading fuzzed alpha-vms binary
PR 25645
	* readelf.c (dump_ia64_vms_dynamic_fixups): Pass size and nmemb
	to get_data rather than multiplying.
	(dump_ia64_vms_dynamic_relocs): Likewise.
	(process_version_sections): Correct order of size and nmemb args
	in get_data call.
	(process_mips_specific): Likewise.
2020-03-09 21:38:48 +10:30
H.J. Lu
a15de1f599 readelf.c: Fix a typo in comments
* readelf.c (get_dynamic_data): Replace "memory chekers" with
	"memory checkers" in comments.
2020-03-08 18:43:42 -07:00
Simon Marchi
9979ab6663 binutils: doc: move artifacts back to MAINTAINERCLEANFILES
In commit 2b44a6a237 (" binutils: doc: make `make clean` clean more
things"), I moved the doc build artifacts to MOSTLYCLEANFILES, which
made them get removed by "make clean".

Because generating binutils.info requires makeinfo, and we do not want
to require makeinfo when building from the tarball, binutils.info should
not get removed by "make clean" (otherwise, it won't be included in the
tarball).

And to be consistent with other projects (e.g. ld and gas), we also want
to ship the built man pages in the tarball.

This patch puts back all these in MAINTAINERCLEANFILES, so that they are
bundled in the tarball, and only cleaned if you use "make
maintainer-clean".

Tested by building a source release and confirming they are present.

binutils/ChangeLog:

	PR 25491
	* doc/Makefile.am: Rename MOSTLYCLEANFILES to MAINTAINERCLEANFILES.
	* doc/Makefile.in: Re-generate.
2020-03-06 22:06:34 -05:00
Nick Clifton
a0dcf29705 Fix an abort triggered when objcopy is used to set the "share" section flag on an ELF section.
binutils* objcopy.c (check_new_section_flags): New function.  Reject the
	SEC_COFF_SHARED flag if the target is not a COFF binary.
	(copy_object): Call check_new_section_flags.
	(setup_section): Likewise.
	* doc/binutils.texi (objcopy): Add a note that the 'share' section
	flag cannot be applied to ELF binaries.

bfd	* elf.c (_bfd_elf_set_section_contents): Replace call to abort
	with error messages and failure return values.
2020-03-06 10:09:22 +00:00
Alan Modra
a9b90127e8 PR25637, objcopy : SIGSEGV in copy_object
PR 25637
	* objcopy.c (filter_symbols): Correct rem_leading_char logic.
2020-03-06 10:34:19 +10:30
Alan Modra
d1faf7ca0a PR25629, objcopy : SIGSEGV in filter_symbols
PR 25629
	* objcopy.c (filter_symbols): Don't segfault on NULL
	prefix_symbols_string.
2020-03-05 15:23:22 +10:30
Christian Eggers
eef64366e1 objcopy: Fix for pr19005 on machines with more than one octet per byte.
On machines with more than one octet per byte, objcopy fills only a part
of the gap between sections.

	* objcopy.c (copy_object): Convert from bytes to octets for
	--gap-fill and --pad-to.
2020-03-04 10:59:30 +10:30
Nick Clifton
5be2b2f549 Remove a call to abort which can be triggered by running objdump on a corrupt input file.
PR 25625
	* prdbg.c (pr_tag_type): Remove call to abort.
2020-03-03 16:11:12 +00:00
Aaron Merey
b312fea191 The procedure to find an unused port for the debuginfod tests is susceptible to a TOCTOU failure. Change port finding in order to avoid this. Also use 'expect' to interact with the server process since we now use the server's output to determine whether a port is in use.
* binutils/testsuite/binutils-all/debuginfod.exp: Improve port
	selection.
2020-03-02 12:46:47 +00:00
Nick Clifton
ba3265d04c Restore readelf's string dump to previous behaviour where newlines were caused line breaks.
PR 25543
	* readelf.c (dump_section_as_strings): Display new-line characters
	as \n and then insert a line break.
	* testsuite/binutils-all/pr25543.s: New test.
	* testsuite/binutils-all/pr25543.d: Test driver.
	* testsuite/binutils-all/readelf.exp: Run the new test.
2020-03-02 10:02:02 +00:00
Nick Clifton
736990c442 Fix an illegal memory access by readelf when displaying the contents of a corrupt IA64 binary.
PR 25526
	* readelf.c (process_ia64_vms_dynamic_relocs): Check to see if
	get_data is unable to load the string table.
2020-02-27 16:28:25 +00:00
Alan Modra
dc1e8a474f Indent labels
Labels don't go in the first column according to standard emacs C
indent rules, and I got annoyed enough at seeing diff -p show a label
rather than the function name to fix this.

bfd/
	* aoutx.h: Indent labels correctly.  Format error strings.
	* archive.c: Likewise.
	* archive64.c: Likewise.
	* coff-arm.c: Likewise.
	* coff-rs6000.c: Likewise.
	* coff-stgo32.c: Likewise.
	* cpu-arm.c: Likewise.
	* dwarf2.c: Likewise.
	* elf-ifunc.c: Likewise.
	* elf-properties.c: Likewise.
	* elf-s390-common.c: Likewise.
	* elf-strtab.c: Likewise.
	* elf.c: Likewise.
	* elf32-arm.c: Likewise.
	* elf32-bfin.c: Likewise.
	* elf32-cr16.c: Likewise.
	* elf32-csky.c: Likewise.
	* elf32-i386.c: Likewise.
	* elf32-m68k.c: Likewise.
	* elf32-msp430.c: Likewise.
	* elf32-nds32.c: Likewise.
	* elf32-nios2.c: Likewise.
	* elf32-pru.c: Likewise.
	* elf32-xtensa.c: Likewise.
	* elf64-ia64-vms.c: Likewise.
	* elf64-x86-64.c: Likewise.
	* elfcode.h: Likewise.
	* elfcore.h: Likewise.
	* elflink.c: Likewise.
	* elfnn-aarch64.c: Likewise.
	* elfnn-ia64.c: Likewise.
	* elfnn-riscv.c: Likewise.
	* elfxx-mips.c: Likewise.
	* elfxx-sparc.c: Likewise.
	* elfxx-x86.c: Likewise.
	* i386lynx.c: Likewise.
	* merge.c: Likewise.
	* pdp11.c: Likewise.
	* plugin.c: Likewise.
	* reloc.c: Likewise.
binutils/
	* elfedit.c: Indent labels correctly.
	* readelf.c: Likewise.
	* resres.c: Likewise.
gas/
	* config/obj-elf.c: Indent labels correctly.
	* config/obj-macho.c: Likewise.
	* config/tc-aarch64.c: Likewise.
	* config/tc-alpha.c: Likewise.
	* config/tc-arm.c: Likewise.
	* config/tc-cr16.c: Likewise.
	* config/tc-crx.c: Likewise.
	* config/tc-frv.c: Likewise.
	* config/tc-i386-intel.c: Likewise.
	* config/tc-i386.c: Likewise.
	* config/tc-ia64.c: Likewise.
	* config/tc-mn10200.c: Likewise.
	* config/tc-mn10300.c: Likewise.
	* config/tc-nds32.c: Likewise.
	* config/tc-riscv.c: Likewise.
	* config/tc-s12z.c: Likewise.
	* config/tc-xtensa.c: Likewise.
	* config/tc-z80.c: Likewise.
	* read.c: Likewise.
	* symbols.c: Likewise.
	* write.c: Likewise.
ld/
	* emultempl/cskyelf.em: Indent labels correctly.
	* ldfile.c: Likewise.
	* ldlang.c: Likewise.
	* plugin.c: Likewise.
opcodes/
	* aarch64-asm.c: Indent labels correctly.
	* aarch64-dis.c: Likewise.
	* aarch64-gen.c: Likewise.
	* aarch64-opc.c: Likewise.
	* alpha-dis.c: Likewise.
	* i386-dis.c: Likewise.
	* nds32-asm.c: Likewise.
	* nfp-dis.c: Likewise.
	* visium-dis.c: Likewise.
2020-02-26 10:37:25 +10:30
H.J. Lu
ecda90163e Don't call lto-wrapper for ar and ranlib
Since ar and ranlib don't need to know symbol types to work properly,
we should avoid calling lto-wrapper for them to speed them up.

bfd/

	PR binutils/25584
	* plugin.c (need_lto_wrapper_p): New.
	(bfd_plugin_set_program_name): Add an int argument to set
	need_lto_wrapper_p.
	(get_lto_wrapper): Return FALSE if need_lto_wrapper_p isn't
	set.
	* plugin.h (bfd_plugin_set_program_name): Add an int argument.

binutils/

	PR binutils/25584
	* ar.c (main): Pass 0 to bfd_plugin_set_program_name.
	* nm.c (main): Pass 1 to bfd_plugin_set_program_name.
2020-02-25 03:31:40 -08:00
Nick Clifton
83d4d556e2 Fix a spelling mistake in the binutils documentation.
PR 25499
	* doc/binutils.texi (objdump): Fix typo in description of
	objdump's -g option.
2020-02-24 14:39:34 +00:00
Nelson Chu
bd0cf5a6ba RISC-V: Support the ISA-dependent CSR checking.
According to the riscv privilege spec, some CSR are only valid when rv32 or
the specific extension is set.  We extend the DECLARE_CSR and DECLARE_CSR_ALIAS
to record more informaton we need, and then check whether the CSR is valid
according to these information.  We report warning message when the CSR is
invalid, so we have a choice between error and warning by --fatal-warnings
option.  Also, a --no-warn/-W option is used to turn the warnings off, if
people don't want the warnings.

	gas/
	* config/tc-riscv.c (enum riscv_csr_class): New enum.  Used to decide
	whether or not this CSR is legal in the current ISA string.
	(struct riscv_csr_extra): New structure to hold all extra information
	of CSR.
	(riscv_init_csr_hash): New function.  According to the DECLARE_CSR and
	DECLARE_CSR_ALIAS, insert CSR extra information into csr_extra_hash.
	Call hash_reg_name to insert CSR address into reg_names_hash.
	(md_begin): Call riscv_init_csr_hashes for each DECLARE_CSR.
	(reg_csr_lookup_internal, riscv_csr_class_check): New functions.
	Decide whether the CSR is valid according to the csr_extra_hash.
	(init_opcode_hash): Update 'if (hash_error != NULL)' as hash_error is
	not a boolean.  This is same as riscv_init_csr_hash, so keep the
	consistent usage.

	* testsuite/gas/riscv/csr-dw-regnums.d: Add -march=rv32if option.
	* testsuite/gas/riscv/priv-reg.d: Add f-ext by -march option.
	* testsuite/gas/riscv/priv-reg-fail-fext.d: New testcase.  The source
	file is `priv-reg.s`, and the ISA is rv32i without f-ext, so the
	f-ext CSR are not allowed.
	* testsuite/gas/riscv/priv-reg-fail-fext.l: Likewise.
	* testsuite/gas/riscv/priv-reg-fail-rv32-only.d: New testcase.  The
	source file is `priv-reg.s`, and the ISA is rv64if, so the
	rv32-only CSR are not allowed.
	* testsuite/gas/riscv/priv-reg-fail-rv32-only.l: Likewise.

	include/
	* opcode/riscv-opc.h: Extend DECLARE_CSR and DECLARE_CSR_ALIAS to
	record riscv_csr_class.

	opcodes/
	* riscv-dis.c (print_insn_args): Updated since the DECLARE_CSR is changed.

	gdb/
	* riscv-tdep.c: Updated since the DECLARE_CSR is changed.
	* riscv-tdep.h: Likewise.
	* features/riscv/rebuild-csr-xml.sh: Generate the 64bit-csr.xml without
	rv32-only CSR.
	* features/riscv/64bit-csr.xml: Regernated.

	binutils/
	* dwarf.c: Updated since the DECLARE_CSR is changed.
2020-02-20 16:49:09 -08:00
Eric Christopher
741cb83912 2020-02-19 Jordan Rupprecht <rupprecht@google.com>
* objdump.c (show_line): call bfd_demangle when using do_demangle.
2020-02-19 13:57:26 -08:00
Andrew Burgess
9f1528a1bd Merge changes from GCC for the config/ directory
GCC's config/ChangeLog since the last time this merge was done
(in the binutils-gdb commit 0b4d000cc4) is included at the
end of this commit message.

It is worth noting that the binutils-gdb commit 301a9420d9
added the file config/debuginfod.m4 which is not present in GCC's
config/ directory.  This file is preserved, unmodified, after this
commit.

In order to regenerate all of the configure files, I configured with
--enable-maintainer-mode, and built the 'all' target.  I then did the
same thing on a source tree without this patch, and only committed
those files that changed when this patch was added.

GCC's config/ChangeLog entries:

  2020-02-12  Sandra Loosemore  <sandra@codesourcery.com>

  	PR libstdc++/79193
  	PR libstdc++/88999

  	* no-executables.m4: Use a non-empty program to test for linker
  	support.

  2020-02-01  Andrew Burgess  <andrew.burgess@embecosm.com>

  	* lib-link.m4 (AC_LIB_LINKFLAGS_BODY): Update shell syntax.

  2020-01-27  Andrew Burgess  <andrew.burgess@embecosm.com>

  	* lib-link.m4 (AC_LIB_LINKFLAGS_BODY): Add new
  	--with-libXXX-type=... option.  Use this to guide the selection of
  	either a shared library or a static library.

  2020-01-24  Maciej W. Rozycki  <macro@wdc.com>

  	* toolexeclibdir.m4: New file.

  2019-09-10  Christophe Lyon  <christophe.lyon@st.com>

  	* futex.m4: Handle *-uclinux*.
  	* tls.m4 (GCC_CHECK_TLS): Likewise.

  2019-09-06  Florian Weimer  <fweimer@redhat.com>

  	* futex.m4 (GCC_LINUX_FUTEX): Include <unistd.h> for the syscall
  	function.

  2019-07-08  Richard Sandiford  <richard.sandiford@arm.com>

  	* bootstrap-Og.mk: New file.

  2019-06-25  Kwok Cheung Yeung  <kcy@codesourcery.com>
              Andrew Stubbs  <ams@codesourcery.com>

  	* gthr.m4 (GCC_AC_THREAD_HEADER): Add case for gcn.

  2019-05-30  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

  	* ax_count_cpus.m4: New file.

  2019-05-02  Richard Biener  <rguenther@suse.de>

  	PR bootstrap/85574
  	* bootstrap-lto.mk (extra-compare): Set to gcc/lto1$(exeext).

  2019-04-16  Martin Liska  <mliska@suse.cz>

  	* bootstrap-lto-lean.mk: Filter out -flto in STAGEtrain_CFLAGS.

  2019-04-09  Martin Liska  <mliska@suse.cz>

  	* bootstrap-lto-lean.mk: New file.

  2019-03-02  Johannes Pfau  <johannespfau@gmail.com>

  	* mh-mingw: Also set __USE_MINGW_ACCESS flag for C++ code.

  2018-10-31  Joseph Myers  <joseph@codesourcery.com>

  	PR bootstrap/82856
  	* math.m4, tls.m4: Use AC_LANG_SOURCE.

  	Merge from binutils-gdb:
  	2018-06-19  Simon Marchi  <simon.marchi@ericsson.com>

  	* override.m4 (_GCC_AUTOCONF_VERSION): Bump from 2.64 to 2.69.

config/ChangeLog:

	* ax_count_cpus.m4: New file, backported from GCC.
	* bootstrap-Og.mk: New file, backported from GCC.
	* bootstrap-lto-lean.mk: New file, backported from GCC.
	* bootstrap-lto.mk: Changes backported from GCC.
	* futex.m4: Changes backported from GCC.
	* gthr.m4: Changes backported from GCC.
	* lib-link.m4: Changes backported from GCC.
	* mh-mingw: Changes backported from GCC.
	* no-executables.m4: Changes backported from GCC.
	* tls.m4: Changes backported from GCC.
	* toolexeclibdir.m4: New file, backported from GCC.

binutils/ChangeLog:

	* configure: Regenerate.

gdb/ChangeLog:

	* configure: Regenerate.

gdbserver/ChangeLog:

	* configure: Regenerate.

gdbsupport/ChangeLog:

	* configure: Regenerate.

intl/ChangeLog:

	* configure: Regenerate.

libiberty/ChangeLog:

	* configure: Regenerate.

zlib/ChangeLog.bin-gdb:

	* configure: Regenerate.
2020-02-19 17:51:24 +00:00
Fangrui Song
3a5d12fbb4 Allow objcopy's --set-section-flags options to add or remove the SHF_EXCLUDE flag of ELF sections.
* objcopy.c (parse_flags): Handle "exclude".
	* doc/binutils.texi: Document the support.
2020-02-10 16:22:00 +00:00
Aaron Merey
46471187e4 More debuginfod tests fixes.
Start server before setting environment variable.
	Specify tmpdir as the location of the server's
	database.
	Check additional server metrics at start-up.
2020-02-10 15:24:57 +00:00
Aaron Merey
678d457fb7 Fix potential problem with binutils debuginfod tests.
* binutils/testsuite/binutils-all/debuginfod.exp:
	Replace set ::env with setenv.
2020-02-10 15:20:41 +00:00
Nick Clifton
e8319fde71 Update release making notes.
* README-how-to-make-a-release: Add note about updating the
  GAS/NEWS URL in the next release.
2020-02-07 15:33:45 +00:00
Sergey Belyashov
9fc0b501af Add support for the GBZ80 and Z80N variants of the Z80 architecture, and add DWARF debug info support to the Z80 assembler.
PR 25469
bfd	* archures.c: Add GBZ80 and Z80N machine values.
	* reloc.c: Add BFD_RELOC_Z80_16_BE.
	* coff-z80.c: Add support for new reloc.
	* coffcode.h: Add support for new machine values.
	* cpu-z80.c: Add support for new machine names.
	* elf32-z80.c: Add support for new reloc.
	* bfd-in2.h: Regenerate.
	* libbfd.h: Regenerate.

binutils* readelf.c (get_machine_flags): Add support for Z80N machine
	number.

gas	* config/tc-z80.c: Add -gbz80 command line option to generate code
	for the GameBoy Z80.  Add support for generating DWARF.
	* config/tc-z80.h: Add support for DWARF debug information
	generation.
	* doc/c-z80.texi: Document new command line option.
	* testsuite/gas/z80/gbz80_all.d: New file.
	* testsuite/gas/z80/gbz80_all.s: New file.
	* testsuite/gas/z80/z80.exp: Run the new tests.
	* testsuite/gas/z80/z80n_all.d: New file.
	* testsuite/gas/z80/z80n_all.s: New file.
	* testsuite/gas/z80/z80n_reloc.d: New file.

include	* coff/internal.h (R_IMM16BE): Define.
	* elf/z80.h (EF_Z80_MACH_Z80N): Define.
	(R_Z80_16_BE): New reloc.

ld	* emulparams/elf32z80.sh: Use z80 emulation.
	* emultempl/z80.em: Make generic to both COFF and ELF Z80 emulations.
	* emultempl/z80elf.em: Delete.
	* testsuite/ld-elf/pr22450.d: Expect to fail for the Z80.
	* testsuite/ld-elf/sec64k.exp: Fix Z80 assembly.
	* testsuite/ld-unique/pr21529.s: Avoid register name conflict.
	* testsuite/ld-unique/unique.s: Likewise.
	* testsuite/ld-unique/unique_empty.s: Likewise.
	* testsuite/ld-unique/unique_shared.s: Likewise.
	* testsuite/ld-unique/unique.d: Updated expected output.
	* testsuite/ld-z80/arch_z80n.d: New file.
	* testsuite/ld-z80/comb_arch_z80_z80n.d: New file.
	* testsuite/ld-z80/labels.s: Add more labels.
	* testsuite/ld-z80/relocs.s: Add more reloc tests.
	* testsuite/ld-z80/relocs_f_z80n.d: New file

opcodes	* z80-dis.c: Add support for GBZ80 opcodes.
2020-02-07 14:53:46 +00:00
Nick Clifton
e1104d08fe Silcence a compile time warning message building the binutils with gcc-10 on an s390 host.
* dwarf.c (display_debug_lines_decoded): Force a NUL termination
	of the truncated file name.
2020-02-07 12:49:42 +00:00
Nick Clifton
c2e6f74465 Fix attributation of previous delta 2020-02-06 13:34:00 +00:00
Thomas Troeger
ece128295e Jump visualization: Handle the case where the disassembled bytes occupy two lines.
* objdump.c (print_jump_visualisation): New function.
	(disassemble_bytes): Call new function.
2020-02-06 13:17:19 +00:00
Alan Modra
02e0be6901 mbind gas tests and supports_gnu_osabi testsuite infrastructure
With the addition of section16 tests we have multiple tests
advertising themselves as "mbind sections" and "mbind section
contents".  This patch fixes that, and fails on quite a few targets
that force an OSABI value.  It's a pain specifying all the relevant
arm targets on an xfail line, so I wrote supports_gnu_osabi.

binutils/
	* testsuite/lib/binutils-common.exp (match_target): Accept '!' before
	TCL procedure.
	(supports_gnu_osabi): New procedure.
	(is_generic): New, from ld-lib.exp.
	(supports_gnu_unique): Use the above.
gas/
	* testsuite/gas/elf/section12a.d: Use supports_gnu_osabi in
	xfail, and rename test.
	* testsuite/gas/elf/section12b.d: Likewise.
	* testsuite/gas/elf/section16a.d: Likewise.
	* testsuite/gas/elf/section16b.d: Likewise.
ld/
	* testsuite/lib/ld-lib.exp (is_generic): Delete.
	* testsuite/ld-unique/unique.exp: Exclude tic6x.
2020-02-06 13:57:37 +10:30
Alan Modra
e8b791227f Missing objdump dependency od-elf32_avr
* Makefile.am (CFILES): Add od-elf32_avr.c.
	* Makefile.in: Regenerate.
	* po/POTFILES.in: Regenerate.
2020-02-04 21:56:29 +10:30
Andreas Schwab
27a45f4276 readelf: add missing newlines to error messages
* readelf.c (dump_relocations, dump_relocations)
	(decode_arm_unwind_bytecode, process_dynamic_section)
	(get_symbol_visibility, get_alpha_symbol_other): Add newline to
	error message.
2020-02-03 19:06:41 +01:00