Commit Graph

18174 Commits

Author SHA1 Message Date
Indu Bhagat
cf0e0a0ba9 bfd: linker: merge .sframe sections
The linker merges all the input .sframe sections.  When merging, the
linker verifies that all the input .sframe sections have the same
abi/arch.

The linker uses libsframe library to perform key actions on the
.sframe sections - decode, read, and create output data.  This
implies buildsystem changes to make and install libsframe before
libbfd.

The linker places the output .sframe section in a new segment of its
own: PT_GNU_SFRAME.  A new segment is not added, however, if the
generated .sframe section is empty.

When a section is discarded from the final link, the corresponding
entries in the .sframe section for those functions are also deleted.

The linker sorts the SFrame FDEs on start address by default and sets
the SFRAME_F_FDE_SORTED flag in the .sframe section.

This patch also adds support for generation of SFrame unwind
information for the .plt* sections on x86_64.  SFrame unwind info is
generated for IBT enabled PLT, lazy/non-lazy PLT.

The existing linker option --no-ld-generated-unwind-info has been
adapted to include the control of whether .sframe unwind information
will be generated for the linker generated sections like PLT.

Changes to the linker script have been made as necessary.

ChangeLog:

	* Makefile.def: Add install dependency on libsframe for libbfd.
	* Makefile.in: Regenerated.
	* bfd/Makefile.am: Add elf-sframe.c
	* bfd/Makefile.in: Regenerated.
	* bfd/bfd-in2.h (SEC_INFO_TYPE_SFRAME): Regenerated.
	* bfd/configure: Regenerate.
	* bfd/configure.ac: Add elf-sframe.lo.
	* bfd/elf-bfd.h (struct sframe_func_bfdinfo): New struct.
	(struct sframe_dec_info): Likewise.
	(struct sframe_enc_info): Likewise.
	(struct elf_link_hash_table): New member for encoded .sframe
	object.
	(struct output_elf_obj_tdata): New member.
	(elf_sframe): New access macro.
	(_bfd_elf_set_section_sframe): New declaration.
	* bfd/elf.c (get_segment_type): Handle new segment
	PT_GNU_SFRAME.
	(bfd_section_from_phdr): Likewise.
	(get_program_header_size): Likewise.
	(_bfd_elf_map_sections_to_segments): Likewise.
	* bfd/elf64-x86-64.c (elf_x86_64_link_setup_gnu_properties): Add
	contents to the .sframe sections or .plt* entries.
	* bfd/elflink.c (elf_section_ignore_discarded_relocs): Handle
	SEC_INFO_TYPE_SFRAME.
	(_bfd_elf_default_action_discarded): Handle .sframe section.
	(elf_link_input_bfd): Merge .sframe section.
	(bfd_elf_final_link): Write the output .sframe section.
	(bfd_elf_discard_info): Handle discarding .sframe section.
	* bfd/elfxx-x86.c (_bfd_x86_elf_size_dynamic_sections): Create
	.sframe section for .plt and .plt.sec.
	(_bfd_x86_elf_finish_dynamic_sections): Handle .sframe from
	.plt* sections.
	* bfd/elfxx-x86.h (PLT_SFRAME_FDE_START_OFFSET): New
	definition.
	(SFRAME_PLT0_MAX_NUM_FRES): Likewise.
	(SFRAME_PLTN_MAX_NUM_FRES): Likewise.
	(struct elf_x86_sframe_plt): New structure.
	(struct elf_x86_link_hash_table): New member.
	(struct elf_x86_init_table): New members for .sframe
	creation.
	* bfd/section.c: Add new definition SEC_INFO_TYPE_SFRAME.
	* binutils/readelf.c (get_segment_type): Handle new segment
	PT_GNU_SFRAME.
	* ld/ld.texi: Update documentation for
	--no-ld-generated-unwind-info.
	* ld/scripttempl/elf.sc: Support .sframe sections.
	* ld/Makefile.am (TESTSFRAMELIB): Use it.
	(check-DEJAGNU): Likewise.
	* ld/Makefile.in: Regenerated.
	* ld/configure.ac (TESTSFRAMELIB): Set to the .so or .a like TESTBFDLIB.
	* ld/configure: Regenerated.
	* bfd/elf-sframe.c: New file.

include/ChangeLog:

	* elf/common.h (PT_GNU_SFRAME): New definition.
	* elf/internal.h (struct elf_segment_map): Handle new segment
	type PT_GNU_SFRAME.

ld/testsuite/ChangeLog:

	* ld/testsuite/ld-bootstrap/bootstrap.exp: Add SFRAMELIB.
	* ld/testsuite/ld-aarch64/aarch64-elf.exp: Add new test
	  sframe-simple-1.
	* ld/testsuite/ld-aarch64/sframe-bar.s: New file.
	* ld/testsuite/ld-aarch64/sframe-foo.s: Likewise.
	* ld/testsuite/ld-aarch64/sframe-simple-1.d: Likewise.
	* ld/testsuite/ld-sframe/sframe-empty.d: New test.
	* ld/testsuite/ld-sframe/sframe-empty.s: New file.
	* ld/testsuite/ld-sframe/sframe.exp: New testsuite.
	* ld/testsuite/ld-x86-64/sframe-bar.s: New file.
	* ld/testsuite/ld-x86-64/sframe-foo.s: Likewise.
	* ld/testsuite/ld-x86-64/sframe-simple-1.d: Likewise.
	* ld/testsuite/ld-x86-64/sframe-plt-1.d: Likewise.
	* ld/testsuite/ld-x86-64/sframe-simple-1.d: Likewise.
	* ld/testsuite/ld-x86-64/x86-64.exp: Add new tests -
	  sframe-simple-1, sframe-plt-1.
	* ld/testsuite/lib/ld-lib.exp: Add new proc to check if
	  assembler supports SFrame section.
	* ld/testsuite/ld-sframe/discard.d: New file.
	* ld/testsuite/ld-sframe/discard.ld: Likewise.
	* ld/testsuite/ld-sframe/discard.s: Likewise.
2022-11-15 15:49:47 -08:00
GDB Administrator
8148339a74 Automatic date update in version.in 2022-11-15 00:00:31 +00:00
Dimitar Dimitrov
36f779c063 pru: bfd: Correct default to no execstack
Data and instruction memories are strictly separated, so it is not
possible to execute instructions from the stack memory on PRU.

I don't see any difference in testsuite results with or without this
change.

bfd/ChangeLog:

	* elf32-pru.c (elf_backend_default_execstack): Define as 0.

ld/ChangeLog:

	* testsuite/ld-elf/elf.exp (target_defaults_to_execstack):
	Return 0 for pru.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
2022-11-14 17:42:22 +02:00
Srinath Parvathaneni
cafdb713d8 arm: Add support for Cortex-X1C CPU.
This patch adds support for Cortex-X1C CPU in Arm.

bfd/ChangeLog:

2022-11-09  Srinath Parvathaneni  <srinath.parvathaneni@arm.com>

        * cpu-arm.c (processors): Add Cortex-X1C CPU entry.

gas/ChangeLog:

2022-11-09  Srinath Parvathaneni  <srinath.parvathaneni@arm.com>

        * NEWS: Update docs.
        * config/tc-arm.c (arm_cpus): Add cortex-x1c to -mcpu.
        * doc/c-arm.texi: Update docs.
        * testsuite/gas/arm/cpu-cortex-x1c.d: New test.
2022-11-14 13:56:05 +00:00
Alan Modra
4f5c4fce88 objcopy renaming section with explicit flags
This tidies SEC_RELOC handling in bfd, in the process fixing a bug
with objcopy when renaming sections.

bfd/
	* reloc.c (_bfd_generic_set_reloc): Set/clear SEC_RELOC depending
	on reloc count.
	* elf64-sparc.c (elf64_sparc_set_reloc): Likewise.
binutils/
	* objcopy.c (copy_relocations_in_section): Remove now unnecessary
	clearing of SEC_RELOC.
	* testsuite/binutils-all/rename-section-01.d: New test.
	* testsuite/binutils-all/objcopy.exp: Run it.
gas/
	* write.c (size_seg): Remove unneccesary twiddle of SEC_RELOC.
	(write_relocs): Likewise.  Always call bfd_set_reloc.
2022-11-14 11:36:46 +10:30
GDB Administrator
f31e4e02ee Automatic date update in version.in 2022-11-14 00:00:31 +00:00
GDB Administrator
28ebf3f8d0 Automatic date update in version.in 2022-11-13 00:00:30 +00:00
GDB Administrator
c9ea6bd322 Automatic date update in version.in 2022-11-12 00:00:21 +00:00
Alan Modra
f7502dfe3f PR28834, PR26946 sanity checking section size
This patch provides a new function to sanity check section sizes.
It's mostly extracted from what we had in bfd_get_full_section_contents
but also handles compressed debug sections.
Improvements are:
- section file offset is taken into account,
- added checks that a compressed section can be read from file.

The function is then used when handling multiple .debug_* sections
that need to be read into a single buffer, to sanity check sizes
before allocating the buffer.

	PR 26946, PR 28834
	* Makefile.am (LIBBFD_H_FILES): Add section.c.
	* compress.c (bfd_get_full_section_contents): Move section size
	sanity checks..
	* section.c (_bfd_section_size_insane): ..to here.  New function.
	* dwarf2.c (read_section): Use _bfd_section_size_insane.
	(_bfd_dwarf2_slurp_debug_info): Likewise.
	* Makefile.in: Regenerate.
	* libbfd.h: Regenerate.
2022-11-11 18:05:36 +10:30
Alan Modra
d0e5049d8f Sanity check SHT_MIPS_OPTIONS size
* elfxx-mips.c (_bfd_mips_elf_section_from_shdr): Use
	bfd_malloc_and_get_section to read contents of .MIPS.options.
2022-11-11 18:05:36 +10:30
GDB Administrator
a686428a8b Automatic date update in version.in 2022-11-11 00:00:43 +00:00
Alan Modra
ac71c620fd mach-o reloc size overflow
* mach-o.c (bfd_mach_o_canonicalize_reloc): Set bfd_error on
	multiply overflow.
2022-11-10 20:29:03 +10:30
Alan Modra
a3eb71adfe Sanity check reloc count in get_reloc_upper_bound
The idea here is the stop tools from allocating up to 32G per section
for the arelent pointer array, only to find a little later that the
section reloc count was fuzzed.  This usually doesn't hurt much (on
systems that allow malloc overcommit) except when compiled with asan.

We already do this for ELF targets, and while fixing the logic
recently I decided other targets ought to do the same.

	* elf64-sparc.c (elf64_sparc_get_reloc_upper_bound): Sanity check
	section reloc count against file size.
	* mach-o.c (bfd_mach_o_get_reloc_upper_bound): Likewise.
	* aoutx.h (get_reloc_upper_bound): Likewise, and don't duplicate
	check done in bfd_get_reloc_upper_bound.
	* pdp11.c (get_reloc_upper_bound): Likewise.
	* coffgen.c (coff_get_reloc_upper_bound): Likewise.
2022-11-10 20:29:03 +10:30
GDB Administrator
8a484e98ae Automatic date update in version.in 2022-11-10 00:00:31 +00:00
H.J. Lu
1db13039a7 ld: Always output local symbol for relocatable link
PR ld/29761
	* elflink.c (elf_link_output_symstrtab): Don't skip local symbol
	in SEC_EXCLUDE section for relocatable link.
2022-11-08 18:39:28 -08:00
GDB Administrator
d8719e695d Automatic date update in version.in 2022-11-09 00:00:31 +00:00
GDB Administrator
70f1d4d484 Automatic date update in version.in 2022-11-08 00:00:30 +00:00
Christophe Lyon
200164d467 configure: require libzstd >= 1.4.0
gas uses ZSTD_compressStream2 which is only available with libzstd >=
1.4.0, leading to build errors when an older version is installed.

This patch updates the check libzstd presence to check its version is
>= 1.4.0. However, since gas seems to be the only component requiring
such a recent version this may imply that we disable ZSTD support for
all components although some would still benefit from an older
version.

I ran 'autoreconf -f' in all directories containing a configure.ac
file, using vanilla autoconf-2.69 and automake-1.15.1. I noticed
several errors from autoheader in readline, as well as warnings in
intl, but they are unrelated to this patch.

This should fix some of the buildbots.

OK for trunk?

Thanks,

Christophe
2022-11-07 14:32:10 +01:00
Tsukasa OI
092a151a38 RISC-V: Remove RV32EF conflict
Despite that the RISC-V ISA Manual version 2.2 prohibited "RV32EF", later
versions beginning with the version 20190608-Base-Ratified removed this
restriction.  Because the 'E' extension is still a draft, the author chose
to *just* remove the conflict (not checking the ISA version).

Note that, because RV32E is only used with a soft-float calling convention,
there's no valid official ABI for RV32EF.  It means, even if we can assemble
a program with -march=rv32ef -mabi=ilp32e, floating-point registers are kept
in an unmanaged state (outside ABI management).

The purpose of this commit is to suppress unnecessary errors while parsing
an ISA string and/or disassembling, not to allow hard-float with RVE.

bfd/ChangeLog:

	* elfxx-riscv.c (riscv_parse_check_conflicts): Accept RV32EF
	because only older specifications disallowed it.

gas/ChangeLog:

	* testsuite/gas/riscv/march-fail-rv32ef.d: Remove as not directly
	prohibited.
	* testsuite/gas/riscv/march-fail-rv32ef.l: Likewise.
2022-11-07 04:44:34 +00:00
GDB Administrator
2f008f0640 Automatic date update in version.in 2022-11-07 00:00:24 +00:00
GDB Administrator
25e64b5276 Automatic date update in version.in 2022-11-06 00:00:20 +00:00
GDB Administrator
31ee179e27 Automatic date update in version.in 2022-11-05 00:00:21 +00:00
Jojo R
853ba67882 Support multiple .eh_frame sections
This patch is based on MULTIPLE_FRAME_SECTIONS and EH_FRAME_LINKONCE,
	it allows backend to enable this feature and use '--gc-sections' simply.

	* gas/dw2gencfi.h (TARGET_MULTIPLE_EH_FRAME_SECTIONS): New.
	(MULTIPLE_FRAME_SECTIONS): Add TARGET_MULTIPLE_EH_FRAME_SECTIONS.
	* gas/dw2gencfi.c (EH_FRAME_LINKONCE): Add TARGET_MULTIPLE_EH_FRAME_SECTIONS.
	(is_now_linkonce_segment): Likewise.
	(get_cfi_seg): Create relocation info between .eh_frame.* and .text.* section.

	* bfd/elf-bfd.h (elf_backend_can_make_multiple_eh_frame): New.
	* bfd/elfxx-target.h (elf_backend_can_make_multiple_eh_frame): Likewise.
	* bfd/elflink.c (_bfd_elf_default_action_discarded): Add checking for
	elf_backend_can_make_multiple_eh_frame.
2022-11-04 10:30:18 +08:00
GDB Administrator
231f62da1d Automatic date update in version.in 2022-11-04 00:00:16 +00:00
GDB Administrator
ae1c45ead6 Automatic date update in version.in 2022-11-03 00:00:08 +00:00
GDB Administrator
e8572cd6aa Automatic date update in version.in 2022-11-02 00:00:08 +00:00
GDB Administrator
1751ca43fd Automatic date update in version.in 2022-11-01 00:00:10 +00:00
GDB Administrator
beaad49235 Automatic date update in version.in 2022-10-31 00:00:08 +00:00
GDB Administrator
60095ba3b8 Automatic date update in version.in 2022-10-30 00:00:07 +00:00
Alan Modra
bb94ac4f95 pef: sanity check before malloc
And do the sanity check in a way that can't overflow.

	* pef.c (bfd_pef_parse_function_stubs): Sanity check header
	imported_library_count and total_imported_symbol_count before
	allocating memory.
2022-10-29 15:23:58 +10:30
Alan Modra
13de66dd34 NULL dereference read in som_write_object_contents
objcopy copy_object may omit the call to bfd_copy_private_bfd_data for
various conditions deemed non-fatal, in which case obj_som_exec_data
will be NULL for the output file.

	* som.c (som_finish_writing): Don't dereference NULL
	obj_som_exec_data.
2022-10-29 15:23:47 +10:30
GDB Administrator
541b65e4bc Automatic date update in version.in 2022-10-29 00:00:11 +00:00
Nelson Chu
40f1a1a456 RISC-V: Output mapping symbols with ISA string.
RISC-V Psabi pr196,
https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/196

bfd/
    * elfxx-riscv.c (riscv_release_subset_list): Free arch_str if needed.
    (riscv_copy_subset_list): Copy arch_str as well.
    * elfxx-riscv.h (riscv_subset_list_t): Store arch_str for each subset list.
gas/
    * config/tc-riscv.c (riscv_reset_subsets_list_arch_str): Update the
    architecture string in the subset_list.
    (riscv_set_arch): Call riscv_reset_subsets_list_arch_str after parsing new
    architecture string.
    (s_riscv_option): Likewise.
    (need_arch_map_symbol): New boolean, used to indicate if .option
    directives do affect instructions.
    (make_mapping_symbol): New boolean parameter reset_seg_arch_str.  Need to
    generate $x+arch for MAP_INSN, and then store it into tc_segment_info_data
    if reset_seg_arch_str is true.
    (riscv_mapping_state): Decide if we need to add $x+arch for MAP_INSN.  For
    now, only add $x+arch if the architecture strings in subset list and segment
    are different.  Besides, always add $x+arch at the start of section, and do
    not add $x+arch for code alignment, since rvc for alignment can be judged
    from addend of R_RISCV_ALIGN.
    (riscv_remove_mapping_symbol): If current and previous mapping symbol have
    same value, then remove the current $x only if the previous is $x+arch;
    Otherwise, always remove previous.
    (riscv_add_odd_padding_symbol): Updated.
    (riscv_check_mapping_symbols): Don't need to add any $x+arch if
    need_arch_map_symbol is false, so changed them to $x.
    (riscv_frag_align_code): Updated since riscv_mapping_state is changed.
    (riscv_init_frag): Likewise.
    (s_riscv_insn): Likewise.
    (riscv_elf_final_processing): Call riscv_release_subset_list to release
    subset_list of riscv_rps_as, rather than only release arch_str in the
    riscv_write_out_attrs.
    (riscv_write_out_attrs): No need to call riscv_arch_str, just get arch_str
    from subset_list of riscv_rps_as.
    * config/tc-riscv.h (riscv_segment_info_type): Record current $x+arch mapping
    symbol of each segment.
    * testsuite/gas/riscv/mapping-0*: Merged and replaced by mapping.s.
    * testsuite/gas/riscv/mapping.s: New testcase, to test most of the cases in
    one file.
    * testsuite/gas/riscv/mapping-symbols.d: Likewise.
    * testsuite/gas/riscv/mapping-dis.d: Likewise.
    * testsuite/gas/riscv/mapping-non-arch.s: New testcase for the case that
    does need any $x+arch.
    * testsuite/gas/riscv/mapping-non-arch.d: Likewise.
    * testsuite/gas/riscv/option-arch-01a.d: Updated.
opcodes/
    * riscv-dis.c (riscv_disassemble_insn): Set riscv_fpr_names back to
    riscv_fpr_names_abi or riscv_fpr_names_numeric when zfinx is disabled
    for some specfic code region.
    (riscv_get_map_state): Recognized mapping symbols $x+arch, and then reset
    the architecture string once the ISA is different.
2022-10-28 11:11:23 +08:00
GDB Administrator
c58a5b7fd9 Automatic date update in version.in 2022-10-28 00:00:07 +00:00
Nelson Chu
f52fb00908 RISC-V: Fix build failures for -Werror=sign-compare.
elfnn-riscv.c: In function ‘riscv_relax_resolve_delete_relocs’:
elfnn-riscv.c:4256:30: error: operand of ‘?:’ changes signedness from ‘int’ to ‘unsigned int’ due to unsignedness of other operand [-Werror=sign-compare]

So make the operands unsigned could resolve problem.

bfd/
    * elfnn-riscv.c (riscv_relax_resolve_delete_relocs): Fixed build
    failures for -Werror=sign-compare.
2022-10-27 16:45:43 +08:00
GDB Administrator
ecb58b32cd Automatic date update in version.in 2022-10-27 00:00:09 +00:00
Alan Modra
f84ffabbb3 buffer overflow in _bfd_XX_print_ce_compressed_pdata
More fuzzed fun.

	* peXXigen.c (_bfd_XX_print_ce_compressed_pdata): Use smaller of
	virt_size and bfd section size as limit of function table.
2022-10-26 17:56:38 +10:30
Alan Modra
5dcae8f603 Correct ELF reloc size sanity check
The external reloc size check was wrong.  Here asect is the code/data
section, not the reloc section.  So using this_hdr gave the size of
the code/data section.

	* elf.c (_bfd_elf_get_reloc_upper_bound): Properly get
	external size from reloc headers.
2022-10-26 17:27:45 +10:30
Alan Modra
b8d97d3857 som.c reloc sanity checking
This patch checks that relocations emitted in som_write_fixups have
offsets that are monotonic and within a section.  To do that properly
using bfd_reloc_offset_in_range it is necessary to set the reloc howto
size field, which isn't used otherwise by the som backend.  Note that
the sizes used are not exactly those in the old sizing switch
statement deleted from som_write_fixups, but all relocs handled by the
main switch statement there get the same size.  Most unhandled relocs
get a zero size (exceptions being R_RELOCATION, R_SPACE_REF,
R_MILLI_REL, R_BREAKPOINT which all involve writing one word according
to my SOM reference).  I figure it doesn't matter since any unhandled
reloc is converted to 0xff R_RESERVED, and a default of zero is better
for a "don't know" reloc.

Besides tidying the code, stringizing name from type in SOM_HOWTO
fixes R_REPEATED_INIT name.

	* som.c (SOM_HOWTO): Add SIZE arg, delete NAME.  Stringize type
	to name.
	(som_hppa_howto_table): Update with sizes.
	(som_write_fixups): Delete sizing switch statement.  Sanity check
	bfd_reloc address against subsection size.
2022-10-26 15:36:14 +10:30
Alan Modra
2f6ba62ed3 som.c buffer overflow
Fuzzed object files can put random values in bfd_reloc->address,
leading to large som_reloc_skip output.

	* som.c (som_write_fixups): Allow for maximal som_reloc_skip.
2022-10-26 15:36:14 +10:30
GDB Administrator
9254cd1fd8 Automatic date update in version.in 2022-10-26 00:00:08 +00:00
Michael Matz
a2267dbfc9 x86-64: Use only one default max-page-size
On x86-64 the default ELF_MAXPAGESIZE depends on a configure
option (--disable-separate-code).  Since 9833b775
("PR28824, relro security issues") we use max-page-size for relro
alignment (with a short interval, from 31b4d3a ("PR28824, relro
security issues, x86 keep COMMONPAGESIZE relro") to its revert
a1faa5ea, where x86-64 only used COMMONPAGESIZE as relro alignment
target).

But that means that a linker configured with --disable-separate-code
behaves different from one configured with --enable-separate-code
(the default), _even if using "-z {no,}separate-code" option to use
the non-configured behaviour_ .  In particular it means that when
configuring with --disable-separate-code the linker will produce
binaries aligned to 2MB pages on disk, and hence generate 2MB
executables for a hello world (and even 6MB when linked with
"-z separate-code").

Generally we can't have constants that ultimately land in static
variables be depending on configure options if those only influence
behaviour that is overridable by command line options.

So, do away with that, make the default MAXPAGESIZE be 4k (as is default
for most x86-64 configs anyway, as most people won't configure with
--disable-separate-code).  If people need more they can use the
"-z max-page-size" (with would have been required right now for a
default configure binutils).

bfd/
	* elf64-x86-64.c (ELF_MAXPAGESIZE): Don't depend on
	DEFAULT_LD_Z_SEPARATE_CODE.
2022-10-25 16:41:26 +02:00
Nelson Chu
845652b784 RISC-V: Should reset `again' flag for _bfd_riscv_relax_pc.
The R_RISCV_DELETE relocations are no longer deleted at another relax pass,
so we should reset 'again' flag to true for _bfd_riscv_relax_pc, while the
deleted bytes are marked as R_RISCV_DELETE.

bfd/
    * elfnn-riscv.c (_bfd_riscv_relax_pc): Set `again' to true while the
    deleted bytes are marked as R_RISCV_DELETE.
2022-10-25 09:20:39 +08:00
Patrick O'Neill
43025f01a0 RISC-V: Improve link time complexity.
The riscv port does deletion and symbol table update for each relocation
while relaxing, so we are moving section bytes and scanning symbol table once
for each relocation.  Compared to microblaze port, they record the relaxation
changes into a table, then do the deletion and symbol table update once per
section, rather than per relocation.  Therefore, they should have better link
time complexity than us.

To improve the link time complexity, this patch try to make the deletion in
linear time.  Compared to record the relaxation changes into a table, we
replace the unused relocation with R_RISCV_DELETE for the deleted bytes, and
then resolve them at the end of the section.  Assuming the number of
R_RISCV_DELETE is m, and the number of symbols is n, the total link complexity
should be O(m) for moving section bytes, and O(m*n^2) for symbol table update.
If we record the relaxation changes into the table, and then sort the symbol
table by values, then probably can reduce the time complexity to O(m*n*log(n))
for updating symbol table, but it doesn't seem worth it for now.

bfd/
    * elfnn-riscv.c (_riscv_relax_delete_bytes): Renamed from
    riscv_relax_delete_bytes, updated to reduce the tiem complexity to O(m)
    for memmove.
    (typedef relax_delete_t): Function pointer declaration of delete functions.
    (riscv_relax_delete_bytes): Can choose to use _riscv_relax_delete_piecewise
    or _riscv_relax_delete_immediate for deletion.
    (_riscv_relax_delete_piecewise): Just mark the deleted bytes as R_RISCV_DELETE.
    (_riscv_relax_delete_immediate): Delete some bytes from a section while
    relaxing.
    (riscv_relax_resolve_delete_relocs): Delete the bytes for R_RISCV_DELETE
    relocations from a section, at the end of _bfd_riscv_relax_section.
    (_bfd_riscv_relax_call): Mark deleted bytes as R_RISCV_DELETE by reusing
    R_RISCV_RELAX.
    (_bfd_riscv_relax_lui): Likewise, but reuse R_RISCV_HI20 for lui, and reuse
    R_RISCV_RELAX for c.lui.
    (_bfd_riscv_relax_tls_le): Likewise, but resue R_RISCV_TPREL_HI20 and
    R_RISCV_TPREL_ADD.
    (_bfd_riscv_relax_pc): Likewise, but resue R_RISCV_PCREL_HI20 for auipc.
    (_bfd_riscv_relax_align): Updated, don't need to resue relocation since
    calling _riscv_relax_delete_immediate.
    (_bfd_riscv_relax_delete): Removed.
    (_bfd_riscv_relax_section): Set riscv_relax_delete_bytes for each relax_func,
    to delete bytes immediately or later.  Call riscv_relax_resolve_delete_relocs
    to delete bytes for DELETE relocations from a section.
2022-10-25 09:20:23 +08:00
GDB Administrator
4ed07377e4 Automatic date update in version.in 2022-10-25 00:00:07 +00:00
GDB Administrator
05962dc48c Automatic date update in version.in 2022-10-24 00:00:07 +00:00
GDB Administrator
df5ffabf1c Automatic date update in version.in 2022-10-23 00:00:06 +00:00
GDB Administrator
095e74caa7 Automatic date update in version.in 2022-10-22 00:00:07 +00:00
GDB Administrator
44c4f3d437 Automatic date update in version.in 2022-10-21 00:00:08 +00:00
Mark Harmstone
f6f30f347b ld: Add --pdb option
Second patch incorporates fixes for endian and UB issues in calc_hash, as per
https://sourceware.org/pipermail/binutils/2022-October/123514.html.
2022-10-20 15:22:37 +10:30
GDB Administrator
f2db12c248 Automatic date update in version.in 2022-10-20 00:00:07 +00:00
Alan Modra
a4f02dc189 Obsolete beos
* config.bfd: Obsolete *-*-beos*.  Simplify x86 beos match.
2022-10-20 09:45:42 +10:30
Nick Clifton
5c831a3c7f Fix an illegal memory access when parsing an ELF file containing corrupt symbol version information.
PR 29699
	* elf.c (_bfd_elf_slurp_version_tables): Fail if the sh_info field
	of the section header is zero.
2022-10-19 15:09:12 +01:00
Andrew Burgess
6d6ae7c23d bfd: fix undefined references to aarch64_pe_le_vec
After commit:

  commit c60b380679
  Date:   Wed Oct 19 10:57:12 2022 +0200

      aarch64-pe support for LD, GAS and BFD

It appears that bfd/Makefile.in and bfd/configure were not regenerated
correctly.  The differences in the configure file are only whitespace,
but in Makefile.in a critical reference to pe-aarch64.lo was missing.
2022-10-19 12:12:37 +01:00
Jedidiah Thompson
c60b380679 aarch64-pe support for LD, GAS and BFD
Allows aarch64-pe to be targeted natively, not having to use objcopy to convert it from ELF to PE.
Based on initial work by Jedidiah Thompson

Co-authored-by: Jedidiah Thompson <wej22007@outlook.com>
Co-authored-by: Zac Walker <zac.walker@linaro.org>
2022-10-19 10:57:12 +02:00
Andreas Krebbel
906f69cf65 IBM zSystems: Issue error for *DBL relocs on misaligned symbols
Relocs like PC32DBL require a right shift of the symbol value.  There
is no situation where dropping symbol value bits with the right shift
is a good thing.  Hence we now issue an error to detect such problems.
2022-10-19 09:03:17 +02:00
GDB Administrator
fd320c4c29 Automatic date update in version.in 2022-10-19 00:00:07 +00:00
GDB Administrator
02a8b5c258 Automatic date update in version.in 2022-10-18 00:00:07 +00:00
GDB Administrator
07a33c2bc1 Automatic date update in version.in 2022-10-17 00:00:06 +00:00
Alan Modra
206e9791cb zlib-gabi to zstd woes
So we had a zlib-gabi .debug_info section that increased in size with
zstd, so much so that it was better to leave the section
uncompressed.  Things went horribly wrong when the section was read
again later.  The section was read again off disk using the
uncompressed size.  So you get the zlib section again with some
garbage at the end.  Fix that particular problem by setting the
section flag SEC_IN_MEMORY.  Any future read will get sec->contents.

Also, if the section is to be left uncompressed, the input
SHF_COMPRESSED flag needs to be reset otherwise objcopy will copy it
to output.

Finally, bfd_convert_section_contents needed a small update to handle
zstd compressed sections, and I've deleted bfd_cache_section_contents.

	* bfd.c (bfd_convert_section_contents): Handle zstd.
	* compress.c (bfd_compress_section_contents): When section
	contents are uncompressed set SEC_IN_MEMORY flag,
	compress_status to COMRESS_SECTION_NONE, and clear
	SHF_COMPRESSED.  Set SEC_IN_MEMORY for compressed contents.
	(bfd_get_full_section_contents): Don't check section size
	against file size when SEC_IN_MEMORY.
	(bfd_cache_section_contents): Delete function.
	* elf32-arm.c (elf32_arm_get_synthetic_symtab): Expand
	bfd_cache_section_contents here.
	* bfd-in2.h: Regenerate.
2022-10-16 13:54:50 +10:30
GDB Administrator
4f722d4a72 Automatic date update in version.in 2022-10-16 00:00:31 +00:00
GDB Administrator
488054071b Automatic date update in version.in 2022-10-15 00:00:42 +00:00
Alan Modra
d12f8998d2 PR29677, Field the_bfd of asymbol is uninitialised
Besides not initialising the_bfd of synthetic symbols, counting
symbols when sizing didn't match symbols created if there were any
dynsyms named "".  We don't want synthetic symbols without names
anyway, so get rid of them.  Also, simplify and correct sanity checks.

	PR 29677
	* mach-o.c (bfd_mach_o_get_synthetic_symtab): Rewrite.
2022-10-14 22:07:18 +10:30
Jan Beulich
d2552ba3e0 RISC-V: Zicbo{m,p,z} adjustments to riscv_multi_subset_supports_ext()
The lack thereof did caused gas to issue "internal: unreachable
INSN_CLASS_*" errors when trying to assemble respective insns without
the feature(s) enabled via e.g. ".option arch, ...". Of course a proper
hint towards the missing extension then wasn't given either.
2022-10-14 12:52:16 +02:00
Tsukasa OI
b16e13328b RISC-V: Imply 'Zicsr' from privileged extensions with CSRs
'H', 'Smstateen', 'Sscofpmf' and 'Sstc' are four privileged extensions with
their CSR definitions and 'Smepmp' is a privileged extension with additional
CSR bits.

Volume II: Privileged Architecture of the RISC-V ISA Manual states that the
privileged architecture requires the 'Zicsr' extension.  However, current
GNU Binutils has no direct way whether the program has dependency to the
privileged architecture itself.

As a workaround, we should add implications from privileged extensions that
either add new CSRs, extend existing CSRs or depends on using CSRs.

This commit adds such implications for existing privileged extensions that
satisfy this condition.

gas/ChangeLog:

	* testsuite/gas/riscv/march-imply-h.d: New test, at least for 'H'.

bfd/ChangeLog:

	* elfxx-riscv.c (riscv_implicit_subsets): Add 'Zicsr'
	implicications for privileged extensions 'H', 'Smstateen',
	'Sscofpmf', 'Sstc' and 'Smepmp'.
2022-10-14 05:21:42 +00:00
GDB Administrator
091782c46d Automatic date update in version.in 2022-10-14 00:00:42 +00:00
GDB Administrator
1d4e62f498 Automatic date update in version.in 2022-10-13 00:00:18 +00:00
GDB Administrator
8652404e81 Automatic date update in version.in 2022-10-12 00:00:18 +00:00
Martin Liska
735fab23d6 fix compressed_debug_section_names definition for "zlib"
bfd/ChangeLog:

	* libbfd.c: Set COMPRESS_DEBUG_GABI_ZLIB for "zlib" value.
2022-10-11 15:25:49 +02:00
Martin Liska
857bddbe73 refactor usage of compressed_debug_section_type
bfd/ChangeLog:

	* bfd-in.h (bfd_hash_set_default_size): Add COMPRESS_UNKNOWN
	  enum value.
	(struct compressed_type_tuple): New.
	* bfd-in2.h (bfd_hash_set_default_size): Regenerate.
	(struct compressed_type_tuple): Likewise.
	* libbfd.c (ARRAY_SIZE): New macro.
	(bfd_get_compression_algorithm): New function.
	(bfd_get_compression_algorithm_name): Likewise.

gas/ChangeLog:

	* as.c: Do not special-case, use the new functions.

ld/ChangeLog:

	* emultempl/elf.em: Do not special-case, use the new functions.
	* lexsup.c (elf_static_list_options): Likewise.
2022-10-11 14:13:26 +02:00
GDB Administrator
4a5d6345a0 Automatic date update in version.in 2022-10-11 00:00:15 +00:00
GDB Administrator
bbcf4de018 Automatic date update in version.in 2022-10-10 00:00:14 +00:00
GDB Administrator
c10a862f17 Automatic date update in version.in 2022-10-09 00:00:18 +00:00
GDB Administrator
4cbfd0daab Automatic date update in version.in 2022-10-08 00:00:13 +00:00
Alan Modra
ea4e4a19b7 PR29653, objcopy/strip: fuzzed small input file induces large output file
_bfd_check_format functions should not print errors or warnings if
they return NULL.  A NULL return means the particular target under
test does not match, so there isn't any reason to make a complaint
about the target.  In fact there isn't a good reason to warn even if
the target matches, except via the _bfd_per_xvec_warn mechanism; Some
other target might be a better match.

This patch tidies pe_bfd_object_p with the above in mind, and
restricts the PE optional header SectionAlignment and FileAlignment
fields somewhat.  I chose to warn on nonsense values rather than
refusing to match.  Refusing to match would be OK too.

	PR 29653
	* peXXigen.c (_bfd_XXi_swap_aouthdr_in): Don't emit error about
	invalid NumberOfRvaAndSizes here.  Limit loop copying data
	directory to IMAGE_NUMBEROF_DIRECTORY_ENTRIES.
	* peicode.h (pe_bfd_object_p): Don't clear and test bfd_error
	around bfd_coff_swap_aouthdr_in.  Warn on invalid SectionAlignment,
	FileAlignment and NumberOfRvaAndSizes.  Don't return NULL on
	invalid NumberOfRvaAndSizes.
2022-10-07 12:30:28 +10:30
GDB Administrator
fea044ba7b Automatic date update in version.in 2022-10-07 00:00:25 +00:00
GDB Administrator
a1509b60cf Automatic date update in version.in 2022-10-06 00:00:17 +00:00
Alan Modra
769a27ade5 Re: bfd BLD-POTFILES.in dependencies
Removing $BLD_POTFILES from BFD-POTFILES.in was correct, but left a
hole in dependencies.
make[4]: Entering directory '/home/alan/build/gas/all/bfd/po'
make[4]: *** No rule to make target '../elf32-aarch64.c', needed by '/home/alan/src/binutils-gdb/bfd/po/bfd.pot'.  Stop.

	* Makefile.am (BUILT_SOURCES): Add BUILD_CFILES.
	* Makefile.in: Regenerate.
2022-10-06 09:45:56 +10:30
Alan Modra
011a136134 Re: stab nearest_line bfd_malloc_and_get_section
It didn't take long for the fuzzers to avoid size checks in
bfd_malloc_and_get_section.  Plug this hole.

	* syms.c (_bfd_stab_section_find_nearest_line): Ignore fuzzed
	sections with no contents.
2022-10-05 14:53:41 +10:30
GDB Administrator
63418f080f Automatic date update in version.in 2022-10-05 00:00:11 +00:00
Nelson Chu
136ea87420 RISC-V: Renamed INSN_CLASS for floating point in integer extensions.
Just added suffix _INX for those INSN_CLASS should be enough to represent
their fpr can be replaced by gpr.
2022-10-04 21:15:51 +08:00
Alan Modra
758dd750bc Support objcopy changing compression to or from zstd
Commit 2cac01e3ff lacked support for objcopy changing compression
style.  Add that support, which meant a rewrite of
bfd_compress_section_contents.  In the process I've fixed some memory
leaks.

	* compress.c (bfd_is_section_compressed_info): Rename from
	bfd_is_section_compressed_with_header and add ch_type param
	to return compression header ch_type field.
	Update all callers.
	(decompress_section_contents): Remove buffer and size params.
	Rewrite.  Update callers.
	(bfd_init_section_compress_status): Free contents on failure.
	(bfd_compress_section): Likewise.
	* elf.c (_bfd_elf_make_section_from_shdr): Support objcopy
	changing between any of the three compression schemes.  Report
	"unable to compress/decompress" rather than "unable to
	initialize compress/decompress status" on compress/decompress
	failures.
	* bfd-in2.h: Regenerate.
2022-10-04 18:42:54 +10:30
Alan Modra
034235cebd Re: compress .gnu.debuglto_.debug_* sections if requested
Enable zlib-gnu compression for .gnu.debuglto_.debug_*.  This differs
from zlib-gnu for .debug_* where the name is changed to .zdebug_*.
The name change isn't really needed.

bfd/
	* elf.c (elf_fake_sections): Replace "." with ".z" in debug
	section names only when name was ".d*", ie. ".debug_*".
	(_bfd_elf_assign_file_positions_for_non_load): Likewise.
gas/
	* write.c (compress_debug): Compress .gnu.debuglto_.debug_*
	for zlib-gnu too.  Compress .gnu.linkonce.wi.*.
2022-10-04 18:36:45 +10:30
Martin Liska
7afbac7ddd compress .gnu.debuglto_.debug_* sections if requested
Right now, when using LTO, the intermediate object files do contain
debug info in sections starting with .gnu.debuglto_ prefix and are
not compressed when --compress-debug-sections is used.

It's a mistake and we can save quite some disk space. The following
example comes from tramp3d when the corresponding LTO sections
are compressed with zlib:

$ bloaty tramp3d-v4-v2.o -- tramp3d-v4.o
    FILE SIZE        VM SIZE
 --------------  --------------
   +83%     +10  [ = ]       0    [Unmapped]
 -68.0%    -441  [ = ]       0    .gnu.debuglto_.debug_line
 -52.3%    -759  [ = ]       0    .gnu.debuglto_.debug_line_str
 -62.4% -3.24Ki  [ = ]       0    .gnu.debuglto_.debug_abbrev
 -64.8% -1.12Mi  [ = ]       0    .gnu.debuglto_.debug_info
 -88.8% -4.58Mi  [ = ]       0    .gnu.debuglto_.debug_str
 -27.7% -5.70Mi  [ = ]       0    TOTAL

bfd/ChangeLog:

	* elf.c (_bfd_elf_make_section_from_shdr): Compress all debug
	  info sections.

gas/ChangeLog:

	* write.c (compress_debug): Compress also ".gnu.debuglto_.debug_"
	if the compression algorithm is different from zlib-gnu.
2022-10-04 18:36:40 +10:30
Potharla, Rupesh
09fbd1cf93 ignore DWARF debug information for -gsplit-dwarf with dwarf-5
Skip dwo_id for split dwarf.

* dwarf2.c (parse_comp_unit): Skip DWO_id for DW_UT_skeleton.
2022-10-04 09:39:53 +02:00
GDB Administrator
cf0136a276 Automatic date update in version.in 2022-10-04 00:00:14 +00:00
GDB Administrator
e1fc9bcfac Automatic date update in version.in 2022-10-03 00:00:11 +00:00
GDB Administrator
f7052ade77 Automatic date update in version.in 2022-10-02 00:00:18 +00:00
GDB Administrator
06bed95d8d Automatic date update in version.in 2022-10-01 00:00:12 +00:00
liuzhensong
c4a7e6b562 LoongArch: Update ELF e_flags handling according to specification.
Update handling of e_flags according to the documentation
  update [1] (discussions [2][3]).

  Object file bitness is now represented in the EI_CLASS byte.
  The e_flags field is now interpreted as follows:

  e_flags[2:0]: Base ABI modifier

  - 0x1: soft-float
  - 0x2: single-precision hard-float
  - 0x3: double-precision hard-float

  e_flags[7:6]: ELF object ABI version

  - 0x0: v0
  - 0x1: v1

  [1]: https://github.com/loongson/LoongArch-Documentation/blob/main/docs/LoongArch-ELF-ABI-EN.adoc#e_flags-identifies-abi-type-and-version
  [2]: https://github.com/loongson/LoongArch-Documentation/pull/61
  [3]: https://github.com/loongson/LoongArch-Documentation/pull/47
2022-09-30 14:00:47 +08:00
Tsukasa OI
d6b99a8071 RISC-V: Add privileged extensions without instructions/CSRs
Currently, GNU Binutils does not support following privileged extensions:

-   'Smepmp'
-   'Svnapot'
-   'Svpbmt'

as they do not provide new CSRs or new instructions ('Smepmp' extends the
privileged architecture CSRs but does not define the CSR itself).  However,
adding them might be useful as we no longer have to "filter" ISA strings
just for toolchains (if full ISA string is given by a vendor, we can
straightly use it).

And there's a fact that supports this theory: there's already an
(unprivileged) extension which does not provide CSRs or instructions (but
only an architectural guarantee): 'Zkt' (constant timing guarantee for
certain subset of RISC-V instructions).

This simple commit simply adds three privileged extensions listed above.

bfd/ChangeLog:

	* elfxx-riscv.c (riscv_supported_std_s_ext): Add 'Smepmp',
	'Svnapot' and 'Svpbmt' extensions.
2022-09-30 04:02:13 +00:00
GDB Administrator
478fced3a8 Automatic date update in version.in 2022-09-30 00:00:13 +00:00
GDB Administrator
1557c9ff81 Automatic date update in version.in 2022-09-29 00:00:20 +00:00
Alan Modra
f8a8e1b263 regen bfd/configure 2022-09-28 10:27:08 +09:30
Alan Modra
8e4a500a5c asan: _bfd_stab_section_find_nearest_line segv
The segv was on "info->strs[strsize - 1] = 0;" with strsize zero.  OK,
if strsize is zero we don't have any filenames in stabs so no useful
info.

	* syms.c (_bfd_stab_section_find_nearest_line): Exit if either
	stabsize or strsize is zero.
2022-09-28 10:27:07 +09:30
Alan Modra
540e53422c asan: segv in _bfd_archive_close_and_cleanup
Uninitialised arelt_data->parent_cache led to this segv.

	* pdb.c (pdb_get_elt_at_index): Clear arelt_data.
2022-09-28 10:26:45 +09:30
GDB Administrator
4f56cf059c Automatic date update in version.in 2022-09-28 00:00:15 +00:00
Fangrui Song
2cac01e3ff binutils, gdb: support zstd compressed debug sections
PR29397 PR29563: Add new configure option --with-zstd which defaults to
auto.  If pkgconfig/libzstd.pc is found, define HAVE_ZSTD and support
zstd compressed debug sections for most tools.

* bfd: for addr2line, objdump --dwarf, gdb, etc
* gas: support --compress-debug-sections=zstd
* ld: support ELFCOMPRESS_ZSTD input and --compress-debug-sections=zstd
* objcopy: support ELFCOMPRESS_ZSTD input for
  --decompress-debug-sections and --compress-debug-sections=zstd
* gdb: support ELFCOMPRESS_ZSTD input.  The bfd change references zstd
  symbols, so gdb has to link against -lzstd in this patch.

If zstd is not supported, ELFCOMPRESS_ZSTD input triggers an error.  We
can avoid HAVE_ZSTD if binutils-gdb imports zstd/ like zlib/, but this
is too heavyweight, so don't do it for now.

```
% ld/ld-new a.o
ld/ld-new: a.o: section .debug_abbrev is compressed with zstd, but BFD is not built with zstd support
...

% ld/ld-new a.o --compress-debug-sections=zstd
ld/ld-new: --compress-debug-sections=zstd: ld is not built with zstd support

% binutils/objcopy --compress-debug-sections=zstd a.o b.o
binutils/objcopy: --compress-debug-sections=zstd: binutils is not built with zstd support

% binutils/objcopy b.o --decompress-debug-sections
binutils/objcopy: zstd.o: section .debug_abbrev is compressed with zstd, but BFD is not built with zstd support
...
```
2022-09-26 19:50:13 -07:00
GDB Administrator
64dc622ffb Automatic date update in version.in 2022-09-27 00:00:11 +00:00
Alan Modra
c7afb87bea PR29613, use of uninitialized value in objcopy
PR 29613
	* elf.c (_bfd_elf_write_secondary_reloc_section): Trim sh_size
	back to relocs written.  Use better types for vars.
2022-09-26 18:32:46 +09:30
Alan Modra
f3bc603561 stab nearest_line bfd_malloc_and_get_section
bfd_malloc_and_get_section performs some sanity checks on the section
size before allocating memory.  This patch avails the stab
nearest_line code of that sanity checking, and tidies up memory
afterward.

	* coffgen.c (_bfd_coff_close_and_cleanup): Call _bfd_stab_cleanup.
	* elf.c (_bfd_elf_close_and_cleanup): Likewise.
	* syms.c (_bfd_stab_section_find_nearest_line): Set *pinfo earlier.
	Use bfd_malloc_and_get_section.  Free malloc'd buffers on failure.
	Malloc indextable.
	(_bfd_stab_cleanup): New function.
	* libbfd-in.h (_bfd_stab_cleanup): Declare.
	* libbfd.h: Regnerate.
2022-09-26 14:23:29 +09:30
GDB Administrator
db0f0fcbf3 Automatic date update in version.in 2022-09-26 00:00:11 +00:00
GDB Administrator
58d69206b8 Automatic date update in version.in 2022-09-25 00:00:13 +00:00
Alan Modra
5aa0f10c42 The problem with warning in elf_object_p
elfcode.h can emit three warnings in elf_object_p for various things,
"section extending past end of file", "corrupt string table index",
and "program header with invalid alignment".  The problem with doing
this is that the warning can be emitted for multiple possible targets
as each one is tried.  I was looking at a fuzzer testcase that had an
object file with 6144 program headers, 5316 of which had invalid
alignment.  It would be bad enough to get 5316 messages all the same,
but this object was contained in an archive and resulted in 4975776
repeats.

Some trimming can be done by not warning if the bfd is already marked
read_only, as is done for the "section extending past end of file"
warning, but that still results in an unacceptable number of
warnings for object files in archives.  Besides that, it is just wrong
to warn about a problem detected by a target elf_object_p other than
the one that actually matches.  At some point we might have more
target specific warnings.

So what to do?  One obvious solution is to remove the warnings.
Another is to poke any warning strings into the target xvec, emitting
them if that xvec is the final one chosen.  This also has the benefit
of solving the archive problem.  A warning when recursing into
_bfd_check_format for the first element of the archive (to find the
correct target for the archive) will still be on the xvec at the point
that target is chosen for the archive.  However, target xvecs are
read-only.  Thus the need for per_xvec_warn to logically extend
bfd_target with a writable field.  I've made per_xvec_warn one larger
than bfd_target_vector to provide one place for user code that makes
private copies of target xvecs.

	* elfcode.h (elf_swap_shdr_in, elf_object_p): Stash potential
	warnings in _bfd_per_xvec_warn location.
	* format.c (clear_warnmsg): New function.
	(bfd_check_format_matches): Call clear_warnmsg before trying
	a new xvec.  Print warnings for the successful non-archive
	match.
	* targets.c: Include libiberty.h.
	(_bfd_target_vector_entries): Use ARRAY_SIZE.
	(per_xvec_warn): New.
	(_bfd_per_xvec_warn): New function.
	* Makefile.am (LIBBFD_H_FILES): Add targets.c.
	* Makefile.in: Regenerate.
	* libbfd.h: Regenerate.
2022-09-24 11:28:55 +09:30
Alan Modra
31f4ff5731 Re: bfd_cleanup for object_p
Bits still missing from commit cb001c0d28.

	* aoutx.h (aout_@var{size}_some_aout_object_p): Correct synopsis.
	* i386lynx.c (lynx_core_file_p): Correct return type.
	* ptrace-core.c (ptrace_unix_core_file_p): Likewise.
2022-09-24 10:06:37 +09:30
GDB Administrator
e64d74cafa Automatic date update in version.in 2022-09-24 00:00:10 +00:00
Christoph Müllner
eb668e5003 RISC-V: Add Zawrs ISA extension support
This patch adds support for the Zawrs ISA extension
("wrs.nto" and "wrs.sto" instructions).

The specification can be found here:
https://github.com/riscv/riscv-zawrs/blob/main/zawrs.adoc

Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
2022-09-23 19:51:29 +02:00
Alan Modra
22997c77b0 pdb: _bfd_generic_close_and_cleanup
Every format that might appear inside a generic archive needs to call
_bfd_generic_close_and_cleanup, so that the archive element lookup
htab can be tidied on closing an element.  Otherwise you get stale
entries in the htab pointing at freed and perhaps reused memory,
resulting in segfaults when the archive is closed.

Calling _bfd_generic_close_and_cleanup on close means tdata needs to
be set up too, since pdb claims to be of format bfd_archive.

	* pdb.c (pdb_close_and_cleanup): Define as
	_bfd_generic_close_and_cleanup.
	(pdb_archive_p): Set up tdata for bfd_archive format.
2022-09-23 11:56:04 +09:30
Alan Modra
4bea06d73c Don't attempt to compress bss sections
It doesn't make sense to try to compress a section without contents
since those sections take no space on disk.  Compression can only
increase the disk image size.

	* coffgen.c (make_a_section_from_file): Exclude !SEC_HAS_CONTENTS
	sections from compression and decompression.
	* elf.c (_bfd_elf_make_section_from_shdr): Likewise.
2022-09-23 11:55:47 +09:30
GDB Administrator
35cff32e9e Automatic date update in version.in 2022-09-23 00:00:31 +00:00
Christoph Müllner
6e17ae6255 RISC-V: Add T-Head MemPair vendor extension
T-Head has a range of vendor-specific instructions.
Therefore it makes sense to group them into smaller chunks
in form of vendor extensions.

This patch adds the XTheadMemPair extension, a collection of T-Head specific
two-GP-register memory operations.
The 'th' prefix and the "XTheadMemPair" extension are documented in a PR
for the RISC-V toolchain conventions ([1]).

[1] https://github.com/riscv-non-isa/riscv-toolchain-conventions/pull/19

Co-developed-by: Lifang Xia <lifang_xia@linux.alibaba.com>
Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
2022-09-22 18:06:09 +02:00
Christoph Müllner
27cfd142d0 RISC-V: Add T-Head MemIdx vendor extension
T-Head has a range of vendor-specific instructions.
Therefore it makes sense to group them into smaller chunks
in form of vendor extensions.

This patch adds the XTheadMemIdx extension, a collection of T-Head specific
GPR memory access instructions.
The 'th' prefix and the "XTheadMemIdx" extension are documented in a PR
for the RISC-V toolchain conventions ([1]).

In total XTheadCmo introduces the following 44 instructions
(BU,HU,WU only for loads (zero-extend instead of sign-extend)):

* {L,S}{D,W,WU,H,HU,B,BU}{IA,IB} rd, rs1, imm5, imm2
* {L,S}R{D,W,WU,H,HU,B,BU} rd, rs1, rs2, imm2
* {L,S}UR{D,W,WU,H,HU,B,BU} rd, rs1, rs2, imm2

[1] https://github.com/riscv-non-isa/riscv-toolchain-conventions/pull/19

Co-developed-by: Lifang Xia <lifang_xia@linux.alibaba.com>
Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
2022-09-22 18:06:09 +02:00
Christoph Müllner
f511f80fa3 RISC-V: Add T-Head FMemIdx vendor extension
T-Head has a range of vendor-specific instructions.
Therefore it makes sense to group them into smaller chunks
in form of vendor extensions.

This patch adds the XTheadFMemIdx extension, a collection of
T-Head-specific floating-point memory access instructions.
The 'th' prefix and the "XTheadFMemIdx" extension are documented
in a PR for the RISC-V toolchain conventions ([1]).

[1] https://github.com/riscv-non-isa/riscv-toolchain-conventions/pull/19

Co-developed-by: Lifang Xia <lifang_xia@linux.alibaba.com>
Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
2022-09-22 18:06:09 +02:00
Christoph Müllner
4041e11db3 RISC-V: Add T-Head MAC vendor extension
T-Head has a range of vendor-specific instructions.
Therefore it makes sense to group them into smaller chunks
in form of vendor extensions.

This patch adds the XTheadMac extension, a collection of
T-Head-specific multiply-accumulate instructions.
The 'th' prefix and the "XTheadMac" extension are documented
in a PR for the RISC-V toolchain conventions ([1]).

[1] https://github.com/riscv-non-isa/riscv-toolchain-conventions/pull/19

Co-developed-by: Lifang Xia <lifang_xia@linux.alibaba.com>
Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
2022-09-22 18:06:09 +02:00
Christoph Müllner
7344223096 RISC-V: Add T-Head CondMov vendor extension
T-Head has a range of vendor-specific instructions.
Therefore it makes sense to group them into smaller chunks
in form of vendor extensions.

This patch adds the XTheadCondMov extension, a collection of
T-Head-specific conditional move instructions.
The 'th' prefix and the "XTheadCondMov" extension are documented
in a PR for the RISC-V toolchain conventions ([1]).

[1] https://github.com/riscv-non-isa/riscv-toolchain-conventions/pull/19

Co-developed-by: Lifang Xia <lifang_xia@linux.alibaba.com>
Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
2022-09-22 18:06:09 +02:00
Christoph Müllner
8254c3d2c9 RISC-V: Add T-Head Bitmanip vendor extension
T-Head has a range of vendor-specific instructions.
Therefore it makes sense to group them into smaller chunks
in form of vendor extensions.

This patch adds the XThead{Ba,Bb,Bs} extensions, a collection of
T-Head-specific bitmanipulation instructions.
The 'th' prefix and the "XThead{Ba,Bb,Bs}" extension are documented
in a PR for the RISC-V toolchain conventions ([1]).

[1] https://github.com/riscv-non-isa/riscv-toolchain-conventions/pull/19

Co-developed-by: Lifang Xia <lifang_xia@linux.alibaba.com>
Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
2022-09-22 18:06:09 +02:00
Christoph Müllner
547c18d9bb RISC-V: Add T-Head SYNC vendor extension
T-Head has a range of vendor-specific instructions.
Therefore it makes sense to group them into smaller chunks
in form of vendor extensions.

This patch adds the XTheadSync extension, a collection of
T-Head-specific multi-processor synchronization instructions.
The 'th' prefix and the "XTheadSync" extension are documented in a PR
for the RISC-V toolchain conventions ([1]).

[1] https://github.com/riscv-non-isa/riscv-toolchain-conventions/pull/19

Co-developed-by: Lifang Xia <lifang_xia@linux.alibaba.com>
Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
2022-09-22 18:06:09 +02:00
Christoph Müllner
a9ba8bc2d3 RISC-V: Add T-Head CMO vendor extension
T-Head has a range of vendor-specific instructions.
Therefore it makes sense to group them into smaller chunks
in form of vendor extensions.

This patch adds the XTheadCmo extension, a collection of T-Head specific
cache management operations.
The 'th' prefix and the "XTheadCmo" extension are documented in a PR
for the RISC-V toolchain conventions ([1]).

In total XTheadCmo introduces the following 21 instructions:

* DCACHE.{C,CI,I}ALL
* DCACHE.{C,CI,I}{PA,VA,SW} rs1
* DCACHE.C{PAL1,VAL1} rs1
* ICACHE.I{ALL,ALLS}
* ICACHE.I{PA,VA} rs1
* L2CACHE.{C,CI,I}ALL

Contrary to Zicbom, the XTheadCmo instructions don't have a constant
displacement, therefore we have a different syntax for the arguments.
To clarify this is intended behaviour, there is a set of negative test
for Zicbom-style arguments in x-thead-cmo-fail.s.

[1] https://github.com/riscv-non-isa/riscv-toolchain-conventions/pull/19

v2:
- Add missing DECLARE_INSN() list
- Fix ordering

Co-developed-by: Lifang Xia <lifang_xia@linux.alibaba.com>
Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
2022-09-22 18:06:09 +02:00
Christoph Müllner
fb1737381d RISC-V: Add generic support for vendor extensions
This patch introduces changes that allow the integration of vendor ISA
extensions:
* Define a list of vendor extensions (riscv_supported_vendor_x_ext)
  where vendor extensions can be added
* Introduce a section with a table in the documentation where vendor
  extensions can be added

To add a vendor extension that consists of instructions only,
the following things need to be done:
* Add the extension to the riscv_supported_vendor_x_ext list
* Add lookup entry in riscv_multi_subset_supports
* Documenting the extension in c-riscv.texti
* Add test cases for all instructions
* Add MATCH*/MASK* constants and DECLARE_INSN() for all instructions
* Add new instruction class to enum riscv_insn_class
* Define the instructions in riscv_opcodes
* Additional changes if necessary (depending on the instructions)

Co-developed-by: Lifang Xia <lifang_xia@linux.alibaba.com>
Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
2022-09-22 18:06:09 +02:00
GDB Administrator
8cdbd5231e Automatic date update in version.in 2022-09-22 00:00:10 +00:00
Alan Modra
d13102c03e bfd BLD-POTFILES.in dependencies
A file that consists of a list of files doesn't depend on those files
being built.  This patch came from trying to avoid a maintainer-mode
make -j bug, where the recipe for targmatch.h was being run twice in
parallel.  Typical output shown below.

make[2]: Entering directory '/build/gas/all/bfd'
  GEN      bfdver.h
  GEN      elf32-target.h
  GEN      elf64-target.h
  GEN      targmatch.h
Making info in po
make[3]: Entering directory '/build/gas/all/bfd/po'
cd .. && make po/SRC-POTFILES.in
cd .. && make po/BLD-POTFILES.in
make[4]: Entering directory '/build/gas/all/bfd'
  GEN      elf32-aarch64.c
  GEN      elf64-aarch64.c
  GEN      elf32-ia64.c
  GEN      elf64-ia64.c
  GEN      elf32-loongarch.c
  GEN      elf64-loongarch.c
  GEN      elf32-riscv.c
  GEN      elf64-riscv.c
  GEN      peigen.c
  GEN      pepigen.c
  GEN      pex64igen.c
  GEN      pe-aarch64igen.c
  GEN      targmatch.h
make[4]: Entering directory '/build/gas/all/bfd'
  CCLD     doc/chew.stamp
mv: cannot stat 'targmatch.new': No such file or directory
make[4]: *** [Makefile:2325: targmatch.h] Error 1

	* Makefile.am (po/BLD-POTFILES.in): Don't depend on $(BLD_POTFILES).
	(po/SRC-POTFILES.in): Don't depend on $(SRC_POTFILES).
2022-09-22 08:14:55 +09:30
Alan Modra
f9a59eea78 PR29566, objdump -p considers an empty .gnu.version_r invalid
Allow and ignore an empty section.

	PR 29566
	* elf.c (bfd_section_from_shdr): Don't set elf_dynverdef or
	elf_dynverref for empty sections.
	(_bfd_elf_slurp_version_tables): Remove now redundant tests.
2022-09-21 22:10:14 +09:30
Alan Modra
3094c89e9c PR29573, addr2line doesn't display file/line for local symbols
The DWARF standard is clear that DW_AT_linkage_name is optional.
Compilers may not provide the attribute on functions and variables,
even though the language mangles names.  g++ does not for local
variables and functions.  Without DW_AT_linkage_name, mangled object
file symbols can't be directly matched against the source-level
DW_AT_name in DWARF info.  One possibility is demangling the object
file symbols, but that comes with its own set of problems:
1) A demangler might not be available for the compiler/language.
2) Demangling doesn't give the source function name as stored in
   DW_AT_name.  Class and template parameters must be stripped at
   least.

So this patch takes a simpler approach.  A symbol matches DWARF info
if the DWARF address matches the symbol address, and if the symbol
name contains the DWARF name as a sub-string.  Very likely the name
matching is entirely superfluous.

	PR 29573
	* dwarf.c (lookup_symbol_in_function_table): Match a symbol
	containing the DWARF source name as a substring.
	(lookup_symbol_in_variable_table): Likewise.
	(_bfd_dwarf2_find_nearest_line_with_alt): If stash_find_line_fast
	returns false, fall back to comp_unit_find_line.
2022-09-21 16:08:38 +09:30
Alan Modra
6c5e237146 dwarf2.c: simplify best_fit_len tests
* dwarf2.c (lookup_address_in_function_table): Simplify
	best_fit_len test.
	(info_hash_lookup_funcinfo): Likewise.
	(lookup_symbol_in_function_table): Likewise, also reorder tests
	and check "file" is set.
	(lookup_symbol_in_variable_table): Reorder tests.
2022-09-21 15:55:10 +09:30
Alan Modra
4609af80c2 dwarf2.c: mangle_style
non_mangled incorrectly returned "true" for Ada.  Correct that, and
add a few more non-mangled entries.  Return a value suitable for
passing to cplus_demangle to control demangling.

	* dwarf2.c: Include demangle.h.
	(mangle_style): Rename from non_mangled.  Return DMGL_* value
	to suit lang.  Adjust all callers.
2022-09-21 15:55:10 +09:30
Alan Modra
6c0cf2ca0d dwarf2.c remove varinfo and funcinfo sec field
The "sec" field in these structures is only set and used in lookup
functions.  It always starts off as NULL.  So the only possible effect
of the field is to modify the return of the lookup, which was its
purpose back in 2005 when HJ fixed PR990.  Since then we solved the
problem of relocatable object files with the fix for PR2338, so this
field is now redundant.

	* dwarf.c (struct funcinfo, struct varinfo): Remove "sec" field.
	(lookup_symbol_in_function_table): Don't set or test "sec".
	(lookup_symbol_in_variable_table): Likewise.
	(info_hash_lookup_funcinfo, info_hash_lookup_varinfo): Likewise.
2022-09-21 15:55:10 +09:30
Shihua
96462b0129 RISC-V: Implement Ztso extension
This patch support ZTSO extension. It will turn on the tso flag for elf_flags
once we have enabled Ztso extension.  This is intended to implement v0.1 of
the proposed specification which can be found in Chapter 25 of,
https://github.com/riscv/riscv-isa-manual/releases/download/draft-20220723-10eea63/riscv-spec.pdf.

bfd\ChangeLog:

        * elfnn-riscv.c (_bfd_riscv_elf_merge_private_bfd_data): Set TSO flag.
        * elfxx-riscv.c: Add Ztso's arch.

binutils\ChangeLog:

        * readelf.c (get_machine_flags): Set TSO flag.

gas\ChangeLog:

        * config/tc-riscv.c (riscv_set_tso): Ditto.
        (riscv_set_arch): Ditto.
        * testsuite/gas/riscv/ztso.d: New test.

include\ChangeLog:

        * elf/riscv.h (EF_RISCV_TSO): Ditto.
2022-09-21 11:43:35 +08:00
GDB Administrator
e348122963 Automatic date update in version.in 2022-09-21 00:00:13 +00:00
Alan Modra
8c8fa33c20 looping in alpha_vms_slurp_relocs
The direct cause for the looping was failing to test for error return
from _bfd_vms_get_object_record inside a while(1) loop.  Fix that.
Also record status of first alpha_vms_slurp_relocs call and return
that for all subsequent calls.  (The object format has one set of
relocation records for all sections.)  If the first call fails, all
others should too.

	* vms-alpha.c (struct vms_private_data_struct): Make reloc_done
	a tri-state int.
	(alpha_vms_slurp_relocs): Set reloc_done to 1 on success, -1 on
	failure.  Return that status on subsequent calls.  Check
	_bfd_vms_get_object_record return status.
	(alpha_vms_get_reloc_upper_bound): Return status from
	alpha_vms_slurp_relocs.
	(alpha_vms_write_exec): Exclude sections with contents NULL due
	to previous errors from layout, and don't try to write them.
2022-09-21 09:06:21 +09:30
Nick Clifton
7e19db932c New Serbian translations for various binutils sub-directories. 2022-09-20 11:33:16 +01:00
Xi Ruoyao
ae2e4d4035 LoongArch: Fix R_LARCH_IRELATIVE insertion after elf_link_sort_relocs
loongarch_elf_finish_dynamic_symbol is called after elf_link_sort_relocs
if -z combreloc.  elf_link_sort_relocs redistributes the contents of
.rela.* sections those would be merged into .rela.dyn, so the slot for
R_LARCH_IRELATIVE may be out of relplt->contents now.

To make things worse, the boundary check

    dyn < dyn + relplt->size / sizeof (*dyn)

is obviously wrong ("x + 10 < x"? :), causing the issue undetected
during the linking process and the resulted executable suddenly crashes
at runtime.

The issue was found during an attempt to add static-pie support to the
toolchain.

Fix it by iterating through the inputs of .rela.dyn to find the slot.
2022-09-20 17:16:06 +08:00
Xi Ruoyao
6224a6c2ea LoongArch: Don't write into GOT for local ifunc
Local ifuncs are always resolved at runtime via R_LARCH_IRELATIVE, so
there is no need to write anything into GOT.  And when we write the GOT
we actually trigger a heap-buffer-overflow: If a and b are different
sections, we cannot access something in b with "a->contents + (offset
from a)" because "a->contents" and "b->contents" are heap buffers
allocated separately, not slices of a large buffer.

So stop writing into GOT for local ifunc now.
2022-09-20 17:16:05 +08:00
GDB Administrator
6519cd1a15 Automatic date update in version.in 2022-09-20 00:00:17 +00:00
GDB Administrator
c99b2113a4 Automatic date update in version.in 2022-09-19 00:00:12 +00:00
GDB Administrator
4e38ed582c Automatic date update in version.in 2022-09-18 00:00:11 +00:00
GDB Administrator
5e3cecb21a Automatic date update in version.in 2022-09-17 00:00:14 +00:00
Alan Modra
839a4671a9 pdb sanity check block_size
* pdb.c (pdb_get_elt_at_index): Only allow block_size to be
	512, 1024, 2048, or 4096.
2022-09-16 13:05:41 +09:30
Nelson Chu
8838766ad6 RISC-V: Make g imply zmmul extension.
bfd/
	* elfxx-riscv.c (riscv_implicit_subset): Moved entry of m after g,
	so that g can imply zmmul.
gas/
	* testsuite/gas/riscv/attribute-01.d: Updated.
	* 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-10.d: Likewise.
	* testsuite/gas/riscv/march-imply-g.d: Likewise.
	* testsuite/gas/riscv/march-imply-unsupported.d: Likewise.
2022-09-16 09:30:57 +08:00
GDB Administrator
ca4f92520e Automatic date update in version.in 2022-09-16 00:00:10 +00:00
Tsukasa OI
d0975d8002 bfd, binutils, gas: Remove/mark unused variables
Clang generates a warning on unused (technically, written but not read
thereafter) variables.  By the default configuration (with "-Werror"), it
causes a build failure (unless "--disable-werror" is specified).

This commit adds ATTRIBUTE_UNUSED attribute to some of them, which means
they are *possibly* unused (can be used but no warnings occur when
unused) and removes others.

bfd/ChangeLog:

	* elf32-lm32.c (lm32_elf_size_dynamic_sections): Mark unused
	rgot_count variable.
	* elf32-nds32.c (elf32_nds32_unify_relax_group): Remove unused
	count variable.
	* mmo.c (mmo_scan): Mark unused lineno variable.

binutils/ChangeLog:

	* windmc.c (write_rc): Remove unused i variable.

gas/ChangeLog:

	* config/tc-riscv.c (riscv_ip): Remove unused argnum variable.

ld/ChangeLog:

	* pe-dll.c (generate_reloc): Remove unused bi and page_count
	variables.
2022-09-15 10:46:02 +00:00
GDB Administrator
8422cbe455 Automatic date update in version.in 2022-09-15 00:00:13 +00:00
Alan Modra
8d783d5e1d looping in bfd_mach_o_fat_openr_next_archived_file
mach-o.c doesn't sanity check mach-o-fat archives, making it easy for
fuzzers to create an archive with mach_o_fat_archentry headers that
point to the same offset.  bfd_mach_o_fat_openr_next_archived_file
uses the previous element offset to find its header, and thus the next
element.  If two offsets are the same, any tool reading the archive
will get stuck.  This patch rejects such archives, and any with
overlapping elements.

	* mach-o.c (overlap_previous): New function.
	(bfd_mach_o_fat_archive_p): Sanity check that elements do not
	overlap each other or the file and archive headers.
2022-09-14 17:14:06 +09:30
Alan Modra
faf351b59d regen pofiles 2022-09-14 15:45:19 +09:30
Tsukasa OI
491cf3178f bfd: Stop using -Wstack-usage=262144 when built with Clang
Some components of GNU Binutils will pass "-Wstack-usage=262144" when
"GCC >= 5.0" is detected.  However, Clang does not support "-Wstack-usage",
despite that related configuration part in bfd/warning.m4 handles the latest
Clang (15.0.0 as of this writing) as "GCC >= 5.0".

The option "-Wstack-usage" was ignored when the first version of Clang is
released but even this "ignoring" behavior is removed before Clang 4.0.0.
So, if we give Clang "-Wstack-usage=262144", it generates a warning, making
the build failure.

This commit checks "__clang__" macro to prevent adding the option if the
compiler is identified as Clang.

bfd/ChangeLog:

	* warning.m4: Stop appending "-Wstack-usage=262144" option when
	compiled with Clang.
	* configure: Regenerate.

binutils/ChangeLog:

	* configure: Regenerate.

gas/ChangeLog:

	* configure: Regenerate.

gold/ChangeLog:

	* configure: Regenerate.

gprof/ChangeLog:

	* configure: Regenerate.

ld/ChangeLog:

	* configure: Regenerate.

opcodes/ChangeLog:

	* configure: Regenerate.
2022-09-14 05:42:17 +00:00
Alan Modra
acfd5524fa asan: som_set_reloc_info heap buffer overflow
Also a bugfix.  The first time the section was read, the contents
didn't supply an addend.

	* som.c (som_set_reloc_info): Sanity check offset.  Do process
	contents after reading.  Tidy section->contents after freeing.
2022-09-14 10:19:57 +09:30
Alan Modra
72e366db62 ubsan: som_is_space null dereference
On objcopy of fuzzed file.

	* som.c (som_write_fixups): Exit loop if space sections all
	processed.
2022-09-14 10:19:56 +09:30
Alan Modra
3cb5e955a3 msan: vms-alpha use-of-uninitialized-value in dst_retrieve_location
* vms-alpha.c (dst_define_location): Init any unused entries.
2022-09-14 10:19:56 +09:30
Alan Modra
365bf300da PR29540, R_PPC64_NONE in .rela.dyn when linking Linux vdso
PR 29540
	* elf64-ppc.c (allocate_dynrelocs): Don't alloc space for relocs
	against discarded sections.
	(ppc64_elf_size_dynamic_sections): Use standard test for discarded
	sections.
	* elf32-ppc.c (allocate_dynrelocs): Don't alloc space for relocs
	against discarded sections.
	(ppc_elf_size_dynamic_sections): Use standard test for discarded
	sections.
2022-09-14 10:19:56 +09:30
GDB Administrator
620fe92831 Automatic date update in version.in 2022-09-14 00:00:17 +00:00
Mark Harmstone
6a69b0a180 Add pdb archive format
Resubmitted with changes in
https://sourceware.org/pipermail/binutils/2022-September/122791.html
made.
2022-09-13 10:31:05 +01:00
GDB Administrator
20e2bd5c63 Automatic date update in version.in 2022-09-13 00:00:19 +00:00
Nelson Chu
ecb915b4de RISC-V: PR28509, the default visibility symbol cannot be referenced by R_RISCV_JAL.
When generating the shared object, the default visibility symbols may bind
externally, which means they will be exported to the dynamic symbol table,
and are preemptible by default.  These symbols cannot be referenced by the
non-pic R_RISCV_JAL and R_RISCV_RVC_JUMP.  However, consider that linker
may relax the R_RISCV_CALL relocations to R_RISCV_JAL or R_RISCV_RVC_JUMP,
if these relocations are relocated to the plt entries, then we won't report
error for them.  Perhaps we also need the similar checks for the
R_RISCV_BRANCH and R_RISCV_RVC_BRANCH relocations.

After applying this patch, and revert the following glibc patch,
riscv: Fix incorrect jal with HIDDEN_JUMPTARGET
https://sourceware.org/git/?p=glibc.git;a=commit;h=68389203832ab39dd0dbaabbc4059e7fff51c29b

I get the expected errors as follows,
ld: relocation R_RISCV_RVC_JUMP against `__sigsetjmp' which may bind externally can not be used when making a shared object; recompile with -fPIC
ld: relocation R_RISCV_JAL against `exit' which may bind externally can not be used when making a shared object; recompile with -fPIC

Besides, we also have similar changes for libgcc,
RISC-V: jal cannot refer to a default visibility symbol for shared object
45116f3420

bfd/
	pr 28509
	* elfnn-riscv.c (riscv_elf_relocate_section): Report errors when
	makeing a shard object, and the referenced symbols of R_RISCV_JAL
	relocations are default visibility.  Besides, we should handle most
	of the cases here, so don't need the unresolvable check later for
	R_RISCV_JAL and R_RISCV_RVC_JUMP.
ld/
	pr 28509
	* testsuite/ld-riscv-elf/ld-riscv-elf.exp: Updated.
	* testsuite/ld-riscv-elf/lib-nopic-01a.s: Removed.
	* testsuite/ld-riscv-elf/lib-nopic-01b.d: Likewise.
	* testsuite/ld-riscv-elf/lib-nopic-01b.s: Likewise.
	* testsuite/ld-riscv-elf/shared-lib-nopic-01.d: New testcase.
	* testsuite/ld-riscv-elf/shared-lib-nopic-01.s: Likewise.
	* testsuite/ld-riscv-elf/shared-lib-nopic-02.d: Likewise.
	* testsuite/ld-riscv-elf/shared-lib-nopic-02.s: Likewise.
	* testsuite/ld-riscv-elf/shared-lib-nopic-03.d: Likewise.
	* testsuite/ld-riscv-elf/shared-lib-nopic-03.s: Likewise.
	* testsuite/ld-riscv-elf/shared-lib-nopic-04.d: Likewise.
	* testsuite/ld-riscv-elf/shared-lib-nopic-04.s: Likewise.
2022-09-12 11:31:41 +08:00
GDB Administrator
0967e2e492 Automatic date update in version.in 2022-09-12 00:00:10 +00:00
GDB Administrator
20a64ae9cb Automatic date update in version.in 2022-09-11 00:00:12 +00:00
GDB Administrator
9d3b25ecc5 Automatic date update in version.in 2022-09-10 00:00:07 +00:00
Nick Clifton
efc1521e40 Support debuginfo files with empty group sections.
PR 29532
bfd	* elf.c (setup_group): Do not return false if there is no group
	information available.

bionutils* objcopy.c (setup_section): Leave group sections intact when
	creating separate debuginfo files.
2022-09-09 12:01:55 +01:00
GDB Administrator
58448ad29c Automatic date update in version.in 2022-09-09 00:00:26 +00:00
GDB Administrator
f42546b6cc Automatic date update in version.in 2022-09-08 00:00:07 +00:00
GDB Administrator
3c4e228256 Automatic date update in version.in 2022-09-07 00:00:08 +00:00
Aaron Merey
6e7a29c7de bfd: Add bfd_find_nearest_line_with_alt
bfd_find_nearest_line_with_alt functions like bfd_find_nearest_line with
the addition of a parameter for specifying the filename of a supplementary
debug file such as one referenced by .gnu_debugaltlink or .debug_sup.

This patch focuses on implementing bfd_find_nearest_line_with_alt
support for ELF/DWARF2 .gnu_debugaltlink. For other targets this
function simply sets the invalid_operation bfd_error.
2022-09-06 10:42:50 -04:00
GDB Administrator
a49fdb49c8 Automatic date update in version.in 2022-09-06 00:00:07 +00:00
GDB Administrator
06c00d5fea Automatic date update in version.in 2022-09-05 00:00:07 +00:00
GDB Administrator
d236680ae9 Automatic date update in version.in 2022-09-04 00:00:07 +00:00
GDB Administrator
148b68a56c Automatic date update in version.in 2022-09-03 00:00:08 +00:00
Max Filippov
658ba81aef xtensa: bfd: fix TLS relocations generated for PIE
When generating TLS dynamic relocations the existing xtensa BFD code
treats linking to a PIE exactly as linking to a shared object, resulting
in generation of wrong relocations for TLS entries. Fix that and add
tests.

bfd/
	* elf32-xtensa.c (elf_xtensa_check_relocs): Use bfd_link_dll
	instead of bfd_link_pic. Add elf_xtensa_dynamic_symbol_p test
	when generating GOT entries.
	(elf_xtensa_relocate_section): Use bfd_link_dll instead of
	bfd_link_pic.
ld/
	* testsuite/ld-xtensa/tlspie.dd: New file.
	* testsuite/ld-xtensa/tlspie.rd: New file.
	* testsuite/ld-xtensa/tlspie.sd: New file.
	* testsuite/ld-xtensa/tlspie.td: New file.
	* testsuite/ld-xtensa/xtensa-linux.exp (TLS PIE transitions):
	New test.
2022-09-02 09:54:49 -07:00
Frederic Cambus
d0a122d311 Add OpenBSD ARM Little Endian BFD support.
* config.bfd (arm-*-openbsd*): Restore target.
2022-09-02 11:29:54 +01:00
GDB Administrator
5edf42b635 Automatic date update in version.in 2022-09-02 00:00:13 +00:00
GDB Administrator
a651b117e1 Automatic date update in version.in 2022-09-01 00:00:07 +00:00
GDB Administrator
649cd1d8df Automatic date update in version.in 2022-08-31 00:00:07 +00:00
Nick Clifton
37833b9665 BFD library: Use entry 0 in directory and filename tables of DWARF-5 debug info.
PR 29529
	* dwarf2.c (struct line_info_table): Add new field:
	use_dir_and_file_0.
	(concat_filename): Use new field to help select the correct table
	slot.
	(read_formatted_entries): Do not skip entry 0.
	(decode_line_info): Set new field depending upon the version of
	DWARF being parsed.  Initialise filename based upon the setting of
	the new field.
2022-08-30 16:01:20 +01:00
Tsukasa OI
0938b032da RISC-V: Add 'Zmmul' extension in assembler.
Three-part patch set from Tsukasa OI to support zmmul in assembler.

The 'Zmmul' is a RISC-V extension consisting of only multiply instructions
(a subset of 'M' which has multiply and divide instructions).

bfd/
	* elfxx-riscv.c (riscv_implicit_subsets): Add 'Zmmul' implied by 'M'.
	(riscv_supported_std_z_ext): Add 'Zmmul' extension.
	(riscv_multi_subset_supports): Add handling for new instruction class.
gas/
	* testsuite/gas/riscv/attribute-09.d: Updated implicit 'Zmmul' by 'M'.
	* testsuite/gas/riscv/option-arch-02.d: Likewise.
	* testsuite/gas/riscv/m-ext.s: New test.
	* testsuite/gas/riscv/m-ext-32.d: New test (RV32).
	* testsuite/gas/riscv/m-ext-64.d: New test (RV64).
	* testsuite/gas/riscv/zmmul-32.d: New expected output.
	* testsuite/gas/riscv/zmmul-64.d: Likewise.
	* testsuite/gas/riscv/m-ext-fail-xlen-32.d: New test (failure
	by using RV64-only instructions in RV32).
	* testsuite/gas/riscv/m-ext-fail-xlen-32.l: Likewise.
	* testsuite/gas/riscv/m-ext-fail-zmmul-32.d: New failure test
	(RV32 + Zmmul but with no M).
	* testsuite/gas/riscv/m-ext-fail-zmmul-32.l: Likewise.
	* testsuite/gas/riscv/m-ext-fail-zmmul-64.d: New failure test
	(RV64 + Zmmul but with no M).
	* testsuite/gas/riscv/m-ext-fail-zmmul-64.l: Likewise.
	* testsuite/gas/riscv/m-ext-fail-noarch-64.d: New failure test
	(no Zmmul or M).
	* testsuite/gas/riscv/m-ext-fail-noarch-64.l: Likewise.
include/
	* opcode/riscv.h (enum riscv_insn_class): Added INSN_CLASS_ZMMUL.
ld/
	* testsuite/ld-riscv-elf/attr-merge-arch-01.d: We don't care zmmul in
	these testcases, so just replaced m by a.
	* testsuite/ld-riscv-elf/attr-merge-arch-01a.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-arch-01b.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-arch-02.d: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-arch-02a.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-arch-03.d: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-arch-03a.s: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-user-ext-01.d: Likewise.
	* testsuite/ld-riscv-elf/attr-merge-user-ext-rv32i2p1_a2p0.s: Renamed.
	* testsuite/ld-riscv-elf/attr-merge-user-ext-rv32i2p1_a2p1.s: Renamed.
opcodes/
	* riscv-opc.c (riscv_opcodes): Updated multiply instructions to zmmul.
2022-08-30 17:46:11 +08:00
GDB Administrator
fae8f4d1fd Automatic date update in version.in 2022-08-30 00:00:07 +00:00
GDB Administrator
27d582267a Automatic date update in version.in 2022-08-29 00:00:07 +00:00
GDB Administrator
d91ab9a73b Automatic date update in version.in 2022-08-28 00:00:14 +00:00
rupothar
9c17922bfe bfd: Fix minor bug in read_indexed_address function.
read_indexed_address function is using offset_size instead of
addr_size while reading addrx forms.
2022-08-27 14:25:44 +09:30
GDB Administrator
46e59b72f2 Automatic date update in version.in 2022-08-27 00:00:08 +00:00
GDB Administrator
8d00b2b74b Automatic date update in version.in 2022-08-26 00:00:06 +00:00
H.J. Lu
2c43d202ae x86: Ignore protected visibility in shared libraries on Solaris
On x86, the PLT entry in executable may be used as function address for
functions in shared libraries.  If functions are protected, the function
address used in executable can be different from the function address
used in shared library.  This will lead to incorrect run-time behavior
if function pointer equality is needed.  By default, x86 linker issues
an error in this case.

On Solaris, linker issued an error for

struct tm *tb = (kind == CPP_time_kind::FIXED ? gmtime : localtime) (&tt);

where gmtime is a protected function in libc.so.  Use gmtime's PLT entry
in executable as function address is safe since function pointer equality
isn't needed.  Ignore protected visibility in shared libraries on Solaris
to disable linker error.  If function pointer equality is needed, linker
will silently generate executable with incorrect run-time behavior on
Solaris.

	PR ld/29512
	* elf32-i386.c (elf_i386_scan_relocs): Ignore protected
	visibility in shared libraries on Solaris.
	* elf64-x86-64.c (elf_x86_64_scan_relocs): Likewise.
2022-08-25 09:10:45 -07:00
Alan Modra
c2d7de232b PR11290, avr-ld "out of range error" is confusing
Don't overload bfd_reloc_outofrange with what is really a domain error
(target at odd address), or an overflow.

	PR 11290
	* reloc.c (bfd_reloc_other): Correct comment.
	* elf32-avr.c (avr_final_link_relocate): Return bfd_reloc_other
	for unaligned reloc target values.  Return bfd_reloc_overflow
	when stubs are too far away and when R_AVR_LDS_STS_16,
	R_AVR_PORT6, or R_AVR_PORT5 overflow.
	(elf32_avr_relocate_section): Report more descriptive relocation
	errors.
	* bfd-in2.h: Regenerate.
2022-08-25 17:20:01 +09:30
GDB Administrator
66a43cf1a7 Automatic date update in version.in 2022-08-25 00:00:08 +00:00
liuzhensong
42bd5254fb LoongArch: ld: Fix bug not generate plt when link a dso
Fix the bug that can not generate func@plt
  when linking a undefined function with cmodel=medium.
  Add testcase.

  bfd/
    * elfnn-loongarch.c
  ld/testsuite/ld-loongarch-elf/
    * cmodel-libjirl.dd
    * cmodel.exp
    * libjirl.s
2022-08-24 14:27:03 +08:00
GDB Administrator
044193ebf6 Automatic date update in version.in 2022-08-24 00:00:10 +00:00
Alan Modra
37c49d0d63 SHT_RELR sh_link and sh_info
I don't think it makes any sense for a SHT_RELR section to specify a
symbol table with sh_link.  SHT_RELR relocations don't use symbols.
There is no real need to specify sh_info either, SHT_RELR is not for
relocatable object files.  Anyway, fuzzers of course don't restrict
themselves to even half-sensible objects.  So they found a hole in
objcopy using a non-alloc SHT_RELR in an ET_EXEC.  In that case BFD
set up the SHT_RELR section as if it were a SHT_REL against the
sh_info target section.  When it came to reading in the target section
relocs, the count was horribly wrong which caused a buffer overflow.

	* elf.c (bfd_section_from_shdr <SHT_RELR>): Always just make a
	normal section, don't treat it as a reloc section.
2022-08-23 21:10:51 +09:30
Alan Modra
6ecc36f7b7 Re: bfd_elf_set_group_contents assertion
Further to commit 7744e3278b.

	* elf.c (bfd_elf_set_group_contents): Restrict loc in loop writing
	contents, and add another assertion.
2022-08-23 18:32:25 +09:30
GDB Administrator
f8bfbd5b75 Automatic date update in version.in 2022-08-23 00:00:12 +00:00
Frederic Cambus
ba86e75013 Add OpenBSD AArch64 Little Endian BFD support.
* config.bfd (aarch64-*-openbsd*): Add target.
2022-08-22 10:19:42 +01:00
GDB Administrator
1034d824d8 Automatic date update in version.in 2022-08-22 00:00:07 +00:00
GDB Administrator
12f26cb22e Automatic date update in version.in 2022-08-21 00:00:11 +00:00
Alan Modra
7749133722 symbols for bfd_simple_get_relocated_section_contents
If symbols are provided by the caller of this function they are
passed on to bfd_get_relocated_section_contents.  No surprises there.
It gets a little weird if they are not provided.  In that case they
are read from the bfd by _bfd_generic_link_add_symbols, and global
symbols are added to the generic linker hash table.  Global symbols
are not added to the linker hash table if symbols *are* provided.  Now
the linker hash table symbols are not used by the generic
bfd_get_relocated_section_conents, and also not by most target
versions when called from bfd_simple_get_relocated_section_contents
except for symbols like "_gp".  So it mostly doesn't matter whether
symbols are in the linker hash table, but it's odd that there is a
difference.  We could always add them, but I'm inclined to think that
is unnecessary work so this patch always leaves them out.

Also, symbols are canonicalized and written into a malloc'd buffer.
The buffer isn't freed, see commit 8e16317ca5.  I don't know whether
that matters any more, but in any case I can't see why we need another
copy of the symbols when _bfd_generic_link_read_symbols has already
cached symbols.

	* simple.c (bfd_simple_get_relocated_section_contents): If not
	provided, read symbols via bfd_generic_link_read_symbols.  Do
	not create another copy of symbols.  Tidy failure exits.
	Minor tidy of bfd_get_relocated_section_contents and
	bfd_get_full_section_contents arguments.
2022-08-21 07:54:27 +09:30
GDB Administrator
a6ac3352ac Automatic date update in version.in 2022-08-20 00:00:07 +00:00
Alan Modra
866318daa3 loongarch64_pei_vec garbage in objcopy'd relocs
Like commit a9c09a3667, but for loongarch64.

	* coff-loongarch64.c (SWAP_IN_RELOC_OFFSET): Define.
	(SWAP_OUT_RELOC_OFFSET): Define.
2022-08-19 10:30:45 +09:30
GDB Administrator
c9dc8fbd9b Automatic date update in version.in 2022-08-19 00:00:09 +00:00
GDB Administrator
2b57654c27 Automatic date update in version.in 2022-08-18 00:00:07 +00:00
Alan Modra
7744e3278b bfd_elf_set_group_contents assertion
objcopy of broken SHT_GROUP sections shouldn't write garbage.

	* elf.c (bfd_elf_set_group_contents): If number of entries is
	unexpected, fill out section with zeros.
2022-08-17 17:29:42 +09:30
Alan Modra
31e43bfffb timeout in mmo_get_symbols
Fix mmo_get_byte to return a fail-safe value, not just on the first
call with a read error but on subsequent calls too.

	* mmo.c (mmo_get_byte): Return the fail-safe value on every
	call after a read error.
2022-08-17 16:35:57 +09:30
Alan Modra
7a1bc25b9d mmo.c leak in mmo_make_section
* mmo.c (mmo_make_section): Alloc name using bfd_alloc.  Use
	bfd_error_no_memory.
	(mmo_decide_section): Check for NULL return from mmo_make_section.
2022-08-17 16:35:57 +09:30
Alan Modra
2bda15d73c asan: heap buffer overflow in mmo_scan
mmo_get_loc needs to handle arbitrary vma and size chunks.  Fuzzers
found that it wasn't working so well when the end of chunks were
getting close to address wrap-around.

	* mmo.c (mmo_get_loc): Make "size" unsigned.  Avoid arithmetic
	overflow when calculating whether range hits an existing chunk.
2022-08-17 16:32:04 +09:30
Alan Modra
11c6a7c623 elf.c tidy
Swap params of is_note, so they are section, segment like others used
in rewrite_elf_program_header.  Whitespace fixes, plus wrapping of
overlong lines.
2022-08-17 11:53:21 +09:30
GDB Administrator
cd78bd1e8c Automatic date update in version.in 2022-08-17 00:00:07 +00:00
Torbjörn SVENSSON
4ae982e83c bfd: Define ___lc_codepage_func prototype for older MinGW-w64
In commit 68e80d96a8, the usage of
___lc_codepage_func was introduced to determine the current encoding.

Prior to version 9.0 of MinGW-w64, the function prototype for
___lc_codepage_func was missing and trying to build BFD caused the
following error:

error: implicit declaration of function ‘___lc_codepage_func’

This changeset adds a conditonal definition of
___lc_codepage_func to allow a sucessful build with MinGW-w64.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
2022-08-16 18:04:21 +01:00
Alan Modra
45d92439ae PR29495, rewrite_elf_program_header looping
This patch, in order of significance:
1) Replaces some macros with inline functions.
2) Those inline functions catch and avoid arithmetic overflows when
   comparing addresses.
3) When assigning sections to segments (IS_SECTION_IN_INPUT_SEGMENT)
   use bed->want_p_paddr_set_to_zero to decide whether lma vs p_paddr
   or vma vs p_vaddr should be tested.  When remapping, use the same
   test, and use is_note rather than the more restrictive
   IS_COREFILE_NOTE.

It's important that the later tests not be more restrictive.  If they
are it can lead to the situation triggered by the testcases, where a
section seemingly didn't fit and thus needed a new mapping.  It didn't
fit the new mapping either, and this repeated until memory exhausted.

	PR 29495
	* elf.c (SEGMENT_END, SECTION_SIZE, IS_CONTAINED_BY_VMA): Delete.
	(IS_CONTAINED_BY_LMA, IS_NOTE, IS_COREFILE_NOTE): Delete.
	(segment_size, segment_end, section_size): New inline function.
	(is_contained_by, is_note): Likewise.
	(rewrite_elf_program_header): Use new functions.
2022-08-16 18:19:34 +09:30
GDB Administrator
246cb4b5a1 Automatic date update in version.in 2022-08-16 00:00:08 +00:00
Alan Modra
a9c09a3667 aarch64_pei_vec
I know this target is just a skeleton, but let's not write out relocs
with uninitialised garbage.

	* coff-aarch64.c (SWAP_IN_RELOC_OFFSET): Define.
	(SWAP_OUT_RELOC_OFFSET): Define.
2022-08-15 10:19:57 +09:30
GDB Administrator
7cc124ae97 Automatic date update in version.in 2022-08-15 00:00:07 +00:00
GDB Administrator
8ad969a3fe Automatic date update in version.in 2022-08-14 00:00:07 +00:00
Alan Modra
ef186fe54a PR29482 - strip: heap-buffer-overflow
PR 29482
	* coffcode.h (coff_set_section_contents): Sanity check _LIB.
2022-08-13 15:32:47 +09:30
Alan Modra
8007515072 asan: NULL dereference in spu_elf_object_p
* elf32-spu.c (spu_elf_object_p): Don't dereference NULL
	shdr->bfd_section.
2022-08-13 14:11:27 +09:30
Alan Modra
9effb9f15f ubsan: undefined shift in sign_extend
* libhppa.h (sign_extend): Avoid undefined behaviour.
2022-08-13 14:11:27 +09:30
Alan Modra
8c68d88cc4 asan: NULL dereference in som_set_reloc_info
* som.c (som_set_reloc_info): Ignore non-existent previous
	fixup references.
2022-08-13 14:11:27 +09:30
GDB Administrator
901dd67d0d Automatic date update in version.in 2022-08-13 00:00:06 +00:00
GDB Administrator
6f419c9825 Automatic date update in version.in 2022-08-12 00:00:14 +00:00
Fangrui Song
453595283c RISC-V: Remove R_RISCV_GNU_VTINHERIT/R_RISCV_GNU_VTENTRY
They were legacy relocation types copied from other ports.  The related
-fvtable-gc was removed from GCC in 2003.

The associated assembler directives (.vtable_inherit and .vtable_entry)
have never been supported by the RISC-V port.  Remove related ld code.

Link: https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/323
2022-08-10 22:01:41 -07:00
Alan Modra
5291ecf972 regen potfiles 2022-08-11 10:50:50 +09:30
GDB Administrator
7030e40b76 Automatic date update in version.in 2022-08-11 00:00:07 +00:00
Youling Tang
31f6009538 bfd: Add support for LoongArch64 EFI (efi-*-loongarch64).
This adds support for efi-loongarch64 by virtue of adding a new PEI target
pei-loongarch64.  This is not a full target and only exists to support EFI at
this time.

This means that this target does not support relocation processing and is mostly
a container format.  This format has been added to elf based loongarch64 targets
such that efi images can be made natively on Linux.

However this target is not valid for use with gas but only with objcopy.

We should't limit addresses to 32-bits for 64-bit vma, otherwise there will be
"RVA truncated" error when using objcopy on loongarch64.

With these changes the resulting file is recognized as an efi image.

Any magic number is based on the Microsoft PE specification [1].

The test results are as follows:
$ make check-binutils RUNTESTFLAGS='loongarch64.exp'
  PASS: Check if efi app format is recognized

$ objdump -h -f tmpdir/loongarch64copy.o
  tmpdir/loongarch64copy.o:     file format pei-loongarch64
  architecture: Loongarch64, flags 0x00000132:
  EXEC_P, HAS_SYMS, HAS_LOCALS, D_PAGED
  start address 0x0000000000000000

  Sections:
  Idx Name          Size      VMA               LMA               File off  Algn
    0 .text         0000003c  00000000200000b0  00000000200000b0  00000200  2**2
                    CONTENTS, ALLOC, LOAD, READONLY, CODE

[1] https://docs.microsoft.com/en-us/windows/win32/debug/pe-format

bfd:
  * .gitignore (pe-loongarch64igen.c): New.
  * Makefile.am (pei-loongarch64.lo, pe-loongarch64igen.lo, pei-loongarch64.c,
  pe-loongarch64igen.c): Add support.
  * Makefile.in: Likewise.
  * bfd.c (bfd_get_sign_extend_vma): Add pei-loongarch64.
  * coff-loongarch64.c: New file.
  * coffcode.h (coff_set_arch_mach_hook, coff_set_flags,
  coff_write_object_contents) Add loongarch64 (loongarch64_pei_vec) support.
  * config.bfd: Likewise.
  * configure: Likewise.
  * configure.ac: Likewise.
  * libpei.h (GET_OPTHDR_IMAGE_BASE, PUT_OPTHDR_IMAGE_BASE,
  GET_OPTHDR_SIZE_OF_STACK_RESERVE, PUT_OPTHDR_SIZE_OF_STACK_RESERVE,
  GET_OPTHDR_SIZE_OF_STACK_COMMIT, PUT_OPTHDR_SIZE_OF_STACK_COMMIT,
  GET_OPTHDR_SIZE_OF_HEAP_RESERVE, PUT_OPTHDR_SIZE_OF_HEAP_RESERVE,
  GET_OPTHDR_SIZE_OF_HEAP_COMMIT, PUT_OPTHDR_SIZE_OF_HEAP_COMMIT,
  GET_PDATA_ENTRY, _bfd_peLoongArch64_bfd_copy_private_bfd_data_common,
  _bfd_peLoongArch64_bfd_copy_private_section_data,
  _bfd_peLoongArch64_get_symbol_info, _bfd_peLoongArch64_only_swap_filehdr_out,
  _bfd_peLoongArch64_print_private_bfd_data_common,
  _bfd_peLoongArch64i_final_link_postscript,
  _bfd_peLoongArch64i_only_swap_filehdr_out, _bfd_peLoongArch64i_swap_aouthdr_in,
  _bfd_peLoongArch64i_swap_aouthdr_out, _bfd_peLoongArch64i_swap_aux_in,
  _bfd_peLoongArch64i_swap_aux_out, _bfd_peLoongArch64i_swap_lineno_in,
  _bfd_peLoongArch64i_swap_lineno_out, _bfd_peLoongArch64i_swap_scnhdr_out,
  _bfd_peLoongArch64i_swap_sym_in, _bfd_peLoongArch64i_swap_sym_out,
  _bfd_peLoongArch64i_swap_debugdir_in, _bfd_peLoongArch64i_swap_debugdir_out,
  _bfd_peLoongArch64i_write_codeview_record,
  _bfd_peLoongArch64i_slurp_codeview_record,
  _bfd_peLoongArch64_print_ce_compressed_pdata): New.
  * peXXigen.c (_bfd_XXi_swap_aouthdr_in, _bfd_XXi_swap_aouthdr_out,
  _bfd_XXi_swap_scnhdr_out, pe_print_pdata, _bfd_XX_print_private_bfd_data_common,
  _bfd_XX_bfd_copy_private_section_data, _bfd_XXi_final_link_postscript):
  Support COFF_WITH_peLoongArch64,
  * pei-loongarch64.c: New file.
  * peicode.h (coff_swap_scnhdr_in, pe_ILF_build_a_bfd, pe_ILF_object_p):
  Support COFF_WITH_peLoongArch64.
  (jtab): Add dummy entry that traps.
  * targets.c (loongarch64_pei_vec): New.

binutils
  * testsuite/binutils-all/loongarch64/loongarch64.exp: New file.
  * testsuite/binutils-all/loongarch64/pei-loongarch64.d: New test.
  * testsuite/binutils-all/loongarch64/pei-loongarch64.s: New test.

include
  * coff/loongarch64.h: New file.
  * coff/pe.h (IMAGE_FILE_MACHINE_LOONGARCH64): New.

Signed-off-by: Youling Tang <tangyouling@loongson.cn>
2022-08-10 09:26:25 +08:00
GDB Administrator
4c3cb23cc0 Automatic date update in version.in 2022-08-10 00:00:10 +00:00
GDB Administrator
ded48050c1 Automatic date update in version.in 2022-08-09 00:00:07 +00:00
Martin Liska
e441b55e94 add splay tree for info_ptr -> CU mapping
While using perf top for MozillaThunderbird I noticed quite some slow
dissably call with source code involved. E.g.

time ./objdump --start-address=0x0000000004e0dcd0 --stop-address=0x0000000004e0df8b -l -d --no-show-raw-insn -S -C /usr/lib64/thunderbird/libxul.so

took 2.071s and I noticed quite some time is spent in
find_abstract_instance:

    33.46%  objdump  objdump               [.] find_abstract_instance
    18.22%  objdump  objdump               [.] arange_add
    13.77%  objdump  objdump               [.] read_attribute_value
     4.82%  objdump  objdump               [.] comp_unit_maybe_decode_line_info
     3.10%  objdump  libc.so.6             [.] __memset_avx2_unaligned_erms

where linked list of CU is iterated when searing for where info_ptr
belongs to:

         : 3452   for (u = unit->prev_unit; u != NULL; u = u->prev_unit)
    0.00 :   4c61f7: mov    0x10(%rbx),%rax
    0.00 :   4c61fb: test   %rax,%rax
    0.00 :   4c61fe: je     4c6215 <find_abstract_instance+0x365>
         : 3453   if (info_ptr >= u->info_ptr_unit && info_ptr < u->end_ptr)
    0.00 :   4c6200: cmp    0x60(%rax),%rdx
   83.20 :   4c6204: jb     4c620c <find_abstract_instance+0x35c>
    0.00 :   4c6206: cmp    0x78(%rax),%rdx
    6.89 :   4c620a: jb     4c6270 <find_abstract_instance+0x3c0>
         : 3452   for (u = unit->prev_unit; u != NULL; u = u->prev_unit)
    0.00 :   4c620c: mov    0x10(%rax),%rax
    7.90 :   4c6210: test   %rax,%rax
    0.00 :   4c6213: jne    4c6200 <find_abstract_instance+0x350>

The following scan can be replaced with search in a splay tree and with
that I can get to 1.5s and there are other symbols where the difference
is even bigger.

bfd/ChangeLog:

	PR 29081
	* dwarf2.c (struct addr_range): New.
	(addr_range_intersects): Likewise.
	(splay_tree_compare_addr_range): Likewise.
	(splay_tree_free_addr_range): Likewise.
	(struct dwarf2_debug_file): Add comp_unit_tree.
	(find_abstract_instance): Use the splay tree when searching
	for a info_ptr.
	(stash_comp_unit): Insert to the splay tree.
	(_bfd_dwarf2_cleanup_debug_info): Clean up the splay tree.
2022-08-08 13:51:14 +02:00
Martin Liska
06ce017c7d dwarf: use find_abstract_instance for vars and DW_AT_specification
The following simple test case fails when dwz is used:

$ cat demo.C
namespace std {
  enum { _S_fixed, _S_floatfield = _S_fixed };
  struct {
    struct {};
  }
  __ioinit;
}

int main() {
  return 0;
}

$ g++ demo.C -g && cp a.out b.out && dwz -m xxx.so a.out b.out && objdump -S a.out >/dev/null
objdump: DWARF error: could not find variable specification at offset 0x3d3

As seen the reference is defined in xxx.so shared part:

$ eu-readelf -w -N a.out | grep -A3 -B3 3d3
             decl_column          (data1) 11
             sibling              (ref_udata) [   387]
 [   387]    variable             abbrev: 30
             specification        (GNU_ref_alt) [   3d3]
             location             (exprloc)
              [ 0] addr 0x404019
 [   396]    subprogram           abbrev: 32

$ eu-readelf -w -N a.out | less

...

 Compilation unit at offset 920:
 Version: 5, Abbreviation section offset: 0, Address size: 8, Offset size: 4
 Unit type: partial (3)
...
 [   3d3]      variable             abbrev: 31
               name                 (strp) "__ioinit"
               decl_file            (data1) demo.C (10)
               decl_line            (data1) 6
               decl_column          (data1) 3
               type                 (ref_udata) [   3c4]
               declaration          (flag_present) yes

With the patch the same output is emitted as before usage of dwz.

bfd/ChangeLog:

	PR 29442
	* dwarf2.c (struct varinfo): Use const char * type.
	(scan_unit_for_symbols): Call find_abstract_instance for
	DW_AT_specification for variables that can be in a different CU
	(e.g. done by dwz)
2022-08-08 13:51:10 +02:00
GDB Administrator
dd27fd47f1 Automatic date update in version.in 2022-08-08 00:00:10 +00:00
GDB Administrator
3ba7b1551b Automatic date update in version.in 2022-08-07 00:00:08 +00:00
Alan Modra
45c8663b92 asan: heap buffer overflow in _bfd_error_handler
On coff_slurp_symbol_table printing "unrecognized storage class"
for a symbol error.  If the symbol name is the last string in its
section and not terminated, we run off the end of the buffer.

	* coffgen.c (build_debug_section): Terminate the section with
	an extra 0.
2022-08-06 19:59:02 +09:30
Alan Modra
431d48ef28 asan: segfault in coff_write_auxent_fname
More fuzzed input file nonsense.

	* coffgen.c (coff_write_symbol): Don't call coff_write_auxent_fname
	when extrap is NULL.
2022-08-06 18:43:24 +09:30
Alan Modra
f7a559d5e1 msan: bfd_mach_o_layout_commands use of uninitialised value
Catches fuzzed input with unterminated strings that later run off the
end of their buffers when calling strlen.

	* mach-o.c: Use size_t vars where approprite.
	(bfd_mach_o_alloc_and_read): Add "extra" param.  Allocate that
	much extra and clear.  Update all callers, those that set up
	strings with one extra byte.
2022-08-06 18:43:24 +09:30
Alan Modra
578a7392c3 objcopy section alignment
bfd_set_section_alignment currently always returns true.  This patch
changes it to return false on silly alignment values, avoiding yet
another way to trigger ubsan errors like coffcode.h:3192:12: runtime
error: shift exponent 299 is too large for 32-bit type 'int'.  We'll
catch that one in objcopy.c:setup_sections.  However, setup_sections
gives up on other setup operations that are necessary even after an
error of some sort.  Change that to keep going, which might change the
error message but that shouldn't matter in the least.

bfd/
	* section.c (bfd_set_section_alignment): Return false and
	don't set alignment_power for stupidly large alignments.
	* bfd-in2.h: Regenerate.
	* coffcode.h (coff_compute_section_file_positions): Don't use
	an int constant when calculating alignment.
binutils/
	* objcopy.c (setup_section): Keep on going after hitting
	non-fatal errors.
2022-08-06 18:43:24 +09:30
Alan Modra
77b38f6db9 ubsan: som.c undefined shift in som_set_reloc_info
Do the shift using unsigned variables to avoid UB on << 8.

	* som.c (som_set_reloc_info): Make v unsigned.  Localise some
	variables to their blocks.
2022-08-06 18:43:04 +09:30
GDB Administrator
9663a947c0 Automatic date update in version.in 2022-08-06 00:00:09 +00:00
Alan Modra
4900c4e60c Get rid of BFD_VMA_FMT
Remove the BFD_VMA_FMT defines in bfd.h and configure support.

	* bfd-in.h (BFD_VMA_FMT): Don't define.
	* configure.ac (BFD_INT64_FMT): Remove configure test.
	* configure.com: Likewise.
	* Makefile.in: Regenerate.
	* bfd-in2.h: Regenerate.
	* configure: Regenerate.
2022-08-06 08:08:32 +09:30
Alan Modra
37c59664ad asan: ppc64_elf_get_synthetic_symtab heap buffer overflow
Fuzzed input files with sizes of .dynamic not a multiple of dynamic
tag size can result in reading past the end of the buffer with the
current simple checks.  Fix that, and use the same check in other
files that process input object .dynamic section.  (There is no need
for buffer overflow checks in the linker's generated .dynamic
section.)

	* elf32-ppc.c (ppc_elf_get_synthetic_symtab): Sanity check
	.dynamic content buffer reads.
	* elf64-ppc.c (ppc64_elf_get_synthetic_symtab): Likewise.
	* elf64-ia64-vms.c (elf64_vms_link_add_object_symbols): Likewise.
	* elf.c (_bfd_elf_print_private_bfd_data): Simplify .dynamic
	buffer sanity checks.
	* elflink.c (elf_link_add_object_symbols): Avoid possible UB
	subtracting sizeof_dyn from pointer.
2022-08-05 20:48:29 +09:30
GDB Administrator
62b73b6580 Automatic date update in version.in 2022-08-05 00:00:16 +00:00
Alan Modra
b82817674f Don't use BFD_VMA_FMT in binutils
BFD_VMA_FMT can't be used in format strings that need to be
translated, because the translation won't work when the type of
bfd_vma differs from the machine used to compile .pot files.  We've
known about this for a long time, but patches slip through review.

So just get rid of BFD_VMA_FMT, instead using the appropriate PRId64,
PRIu64, PRIx64 or PRIo64 and SCN variants for scanf.  The patch is
mostly mechanical, the only thing requiring any thought is casts
needed to preserve PRId64 output from bfd_vma values, or to preserve
one of the unsigned output formats from bfd_signed_vma values.
2022-08-04 12:22:39 +09:30
Alan Modra
94e27e8e69 MIPS: Use R_MIPS_REL16 for BFD_RELOC_16
R_MIPS_REL16 isn't a pc-relative reloc as the name might indicate.

	* elf64-mips.c (mips_reloc_map): Map BFD_RELOC_16 to R_MIPS_REL16.
	* elfn32-mips.c (mips_reloc_map): Likewise.
2022-08-04 11:42:33 +09:30
GDB Administrator
fcbfb25dcc Automatic date update in version.in 2022-08-04 00:00:08 +00:00
H.J. Lu
59f214544c elf: Reset alignment for each PT_LOAD segment
Reset alignment for each PT_LOAD segment to avoid using alignment from
the previous PT_LOAD segment.

bfd/

	PR ld/29435
	* elf.c (assign_file_positions_for_load_sections): Reset
	alignment for each PT_LOAD segment.

ld/

	PR ld/29435
	* testsuite/ld-elf/pr29435.d: New file.
	* testsuite/ld-elf/pr29435.s: Likewise.
2022-08-03 13:34:01 -07:00
Alan Modra
a6ad791442 Fix a conflict between the linker's need to rename some PE format input libraries and the BFD library's file caching mechanism.
PR 29389
bfd	* bfd.c (BFD_CLOSED_BY_CACHE): New bfd flag.
	* cache.c (bfd_cache_delete): Set BFD_CLOSED_BY_DELETE on the
	closed bfd.
	(bfd_cache_lookup_worker): Clear BFD_CLOSED_BY_DELETE on the newly
	reopened bfd.
	* opncls.c (bfd_set_filename): Refuse to change the name of a bfd
	that has been closed by bfd_cache_delete.  Mark changed bfds as
	uncacheable.
	* bfd-in2.h: Regenerate.

ld	* ldlang.h (lang_input_statement_struct): Add sort_key field.
	* emultempl/pe.em (after_open): If multiple import libraries refer
	to the same bfd, store their names in the sort_key field.
	* emultempl/pep.em (after_open): Likewise.
	* ldlang.c (sort_filename): New function.  Returns the filename to
	be used when sorting input files.
	(wild_sort): Use the sort_filename function.
2022-08-03 13:31:57 +01:00
Alan Modra
ecfc6ddb80 Re: PE objdump -x
All of these buffer overrun tests are better written as a comparison
against size remaining, due to ISO C 9899 standard 6.5.2 para 8
regarding adding a constant to a pointer:

"If both the pointer operand and the result point to elements of the
same array object, or one past the last element of the array object,
the evaluation shall not produce an overflow; otherwise, the behavior
is undefined."

So "ex_dta + 4" might be undefined behaviour, if you interpret "the
array object" in this case to be the malloc'd section contents!

	* pei-x86_64.c (pex64_get_unwind_info): Tidy sanity checks.
	(pex64_xdata_print_uwd_codes): Likewise.
2022-08-03 17:00:17 +09:30
GDB Administrator
8aaafe957c Automatic date update in version.in 2022-08-03 00:00:07 +00:00
Jan Beulich
2ba2f09618 ELF: emit symbol table when there are relocations
Even when there are no symbols (e.g. all relocations being against
absolute values), a symbol table (with just the first placeholder entry)
needs to be emitted. Otherwise tools like objdump won't properly process
the relocations. The respective checks in assign_section_numbers() and
_bfd_elf_compute_section_file_positions() support also this view. Oddly
enough so far HAS_RELOC was only set when reading in an object file, but
not when generating one anew; the flag would only have been cleared when
no relocations were found (anymore).

While there also amend the affected function's leading comment to also
mention gas.
2022-08-02 15:43:26 +02:00
Matthew Malcomson
976f16630b ld: aarch64: Adjust TLS relaxation condition
In aarch64_tls_transition_without_check and elfNN_aarch64_tls_relax we
choose whether to perform a relaxation to an IE access model or an LE
access model based on whether the symbol itself is marked as local (i.e.
`h == NULL`).

This is problematic in two ways.  The first is that sometimes a global
dynamic access can be relaxed to an initial exec access when creating a
shared library, and if that happens on a local symbol then we currently
relax it to a local exec access instead.  This usually does not happen
since we only relax an access if aarch64_can_relax_tls returns true and
aarch64_can_relax_tls does not have the same problem.  However, it can
happen when we have seen both an IE and GD access on the same symbol.
This case is exercised in the newly added testcase tls-relax-gd-ie-2.

The second problem is that deciding based on whether the symbol is local
misses the case when the symbol is global but is still non-interposable
and known to be located in the executable.  This happens on all global
symbols in executables.
This case is exercised in the newly added testcase tls-relax-ie-le-4.

Here we adjust the condition we base our relaxation on so that we relax
to local-exec if we are creating an executable and the relevant symbol
we're accessing is stored inside that executable.

-- Updating tests for new relaxation criteria

Many of the tests added to check our relaxation to IE were implemented
by taking advantage of the fact that we did not relax a global symbol
defined in an executable.

Since a global symbol defined in an executable is still not
interposable, we know that a TLS version of such a symbol will be in the
main TLS block.  This means that we can perform a stronger relaxation on
such symbols and relax their accesses to a local-exec access.

Hence we have to update all tests that relied on the older suboptimal
decision making.

The two cases when we still would want to relax a general dynamic access
to an initial exec one are:
1) When in a shared library and accessing a symbol which we have already
   seen accessed with an initial exec access sequence.
2) When in an executable and accessing a symbol defined in a shared
   library.

Both of these require shared library support, which means that these
tests are now only available on targets with that.

I have chosen to switch the existing testcases from a plain executable
to one dynamically linked to a shared object as that doesn't require
changing the testcases quite so much (just requires accessing a
different variable rather than requiring adding another code sequence).

The tls-relax-all testcase was an outlier to the above approach, since
it included a general dynamic access to both a local and global symbol
and inspected for the difference accordingly.
2022-08-02 12:10:01 +01:00
Alan Modra
217cbb0055 PE objdump -x
objdump -x on PE executables produces lots of "xdata section corrupt"
and "corrupt unwind data" warnings, and refuses to dump that info.  It
turns out that the sanity checks were bad, not the data.  Fix them.

	* pei-x86_64.c (pex64_get_unwind_info): Correct buffer overrun
	sanity checks.
	(pex64_xdata_print_uwd_codes): Similarly.
2022-08-02 17:01:56 +09:30
GDB Administrator
c1165f1bcf Automatic date update in version.in 2022-08-02 00:00:08 +00:00
Alan Modra
f493c2174e Get rid of fprintf_vma and sprintf_vma
These two macros print either a 16 digit hex number or an 8 digit
hex number.  Unfortunately they depend on both target and host, which
means that the output for 32-bit targets may be either 8 or 16 hex
digits.

Replace them in most cases with code that prints a bfd_vma using
PRIx64.  In some cases, deliberately lose the leading zeros.
This change some output, notably in base/offset fields of m68k
disassembly which I think looks better that way, and in error
messages.  I've kept leading zeros in symbol dumps (objdump -t)
and in PE header dumps.

bfd/
	* bfd-in.h (fprintf_vma, sprintf_vma, printf_vma): Delete.
	* bfd-in2.h: Regenerate.
	* bfd.c (bfd_sprintf_vma): Don't use sprintf_vma.
	(bfd_fprintf_vma): Don't use fprintf_vma.
	* coff-rs6000.c (xcoff_reloc_type_tls): Don't use sprintf_vma.
	Instead use PRIx64 to print bfd_vma values.
	(xcoff_ppc_relocate_section): Likewise.
	* cofflink.c (_bfd_coff_write_global_sym): Likewise.
	* mmo.c (mmo_write_symbols_and_terminator): Likewise.
	* srec.c (srec_write_symbols): Likewise.
	* elf32-xtensa.c (print_r_reloc): Similarly for fprintf_vma.
	* pei-x86_64.c (pex64_dump_xdata): Likewise.
	(pex64_bfd_print_pdata_section): Likewise.
	* som.c (som_print_symbol): Likewise.
	* ecoff.c (_bfd_ecoff_print_symbol): Use bfd_fprintf_vma.
opcodes/
	* dis-buf.c (perror_memory, generic_print_address): Don't use
	sprintf_vma.  Instead use PRIx64 to print bfd_vma values.
	* i386-dis.c (print_operand_value, print_displacement): Likewise.
	* m68k-dis.c (print_base, print_indexed): Likewise.
	* ns32k-dis.c (print_insn_arg): Likewise.
	* ia64-gen.c (_opcode_int64_low, _opcode_int64_high): Delete.
	(opcode_fprintf_vma): Delete.
	(print_main_table): Use PRIx64 to print opcode.
binutils/
	* od-macho.c: Replace all uses of printf_vma with bfd_printf_vma.
	* objcopy.c (copy_object): Don't use sprintf_vma.  Instead use
	PRIx64 to print bfd_vma values.
	(copy_main): Likewise.
	* readelf.c (CHECK_ENTSIZE_VALUES): Likewise.
	(dynamic_section_mips_val): Likewise.
	(print_vma): Don't use printf_vma.  Instead use PRIx64 to print
	bfd_vma values.
	(dump_ia64_vms_dynamic_fixups): Likewise.
	(process_version_sections): Likewise.
	* rddbg.c (stab_context): Likewise.
gas/
	* config/tc-i386.c (offset_in_range): Don't use sprintf_vma.
	Instead use PRIx64 to print bfd_vma values.
	(md_assemble): Likewise.
	* config/tc-mips.c (load_register, macro): Likewise.
	* messages.c (as_internal_value_out_of_range): Likewise.
	* read.c (emit_expr_with_reloc): Likewise.
	* config/tc-ia64.c (note_register_values): Don't use fprintf_vma.
	Instead use PRIx64 to print bfd_vma values.
	(print_dependency): Likewise.
	* listing.c (list_symbol_table): Use bfd_sprintf_vma.
	* symbols.c (print_symbol_value_1): Use %p to print pointers.
	(print_binary): Likewise.
	(print_expr_1): Use PRIx64 to print bfd_vma values.
	* write.c (print_fixup): Use %p to print pointers.  Don't use
	fprintf_vma.
	* testsuite/gas/all/overflow.l: Update expected output.
	* testsuite/gas/m68k/mcf-mov3q.d: Likewise.
	* testsuite/gas/m68k/operands.d: Likewise.
	* testsuite/gas/s12z/truncated.d: Likewise.
ld/
	* deffilep.y (def_file_print): Don't use fprintf_vma.  Instead
	use PRIx64 to print bfd_vma values.
	* emultempl/armelf.em (gld${EMULATION_NAME}_finish): Don't use
	sprintf_vma.  Instead use PRIx64 to print bfd_vma values.
	* emultempl/pe.em (gld${EMULATION_NAME}_finish): Likewise.
	* ldlang.c (lang_map): Use %V to print region origin.
	(lang_one_common): Don't use sprintf_vma.
	* ldmisc.c (vfinfo): Don't use fprintf_vma or sprintf_vma.
	* pe-dll.c (pe_dll_generate_def_file): Likewise.
gdb/
	* remote.c (remote_target::trace_set_readonly_regions): Replace
	uses of sprintf_vma with bfd_sprintf_vma.
2022-08-01 13:52:18 +09:30
liuzhensong
48ca1b26b9 LoongArch: Set defaults to exec stack 0. 2022-08-01 09:05:00 +08:00
Alan Modra
1a5178fe28 PR29348, BFD_VMA_FMT wrong
There is a problem with my commit 0e3c1eebb2, which replaced
bfd_uint64_t with uint64_t: Some hosts typedef int64_t to long long
even when long is the same size as long long.  That confuses the code
choosing one of "l", "ll", or "I64" for BFD_VMA_FMT, and results in
warnings.

Write a direct configure test for the printf int64_t style instead.
This removes the last use of BFD_HOST_64BIT_LONG, so delete that.
Note that the changes to configure.com are pure guesswork.

	PR 29348
	* bfd-in.h (BFD_HOST_64BIT_LONG): Don't define.
	(BFD_VMA_FMT): Define using BFD_INT64_FMT when 64-bit.
	(bfd_vma, bfd_signed_vma): Move comments to 64-bit typedefs.
	* configure.ac (BFD_HOST_64BIT_LONG): Delete.
	(BFD_INT64_FMT): New config test.
	* configure.com: Update similarly.
	* Makefile.in: Regenerate.
	* bfd-in2.h: Regenerate.
	* configure: Regenerate.
2022-08-01 09:30:33 +09:30
GDB Administrator
df0e73ff93 Automatic date update in version.in 2022-08-01 00:00:06 +00:00
GDB Administrator
55ea1654ab Automatic date update in version.in 2022-07-31 00:00:07 +00:00
GDB Administrator
017772c826 Automatic date update in version.in 2022-07-30 00:00:08 +00:00
Alan Modra
10948fb9fd Re: PR16005, avr linker crash on a particular instruction sequence with --relax
The last patch wasn't so clever.  The contents in fact have already
been read, just not cached where relax_delete_bytes expects them.
relax_delete_bytes also modifies relocs and syms, so they should be
cached too.

	PR 16005
	* elf32-avr.c (elf32_avr_relax_delete_bytes): Revert last change.
	(elf32_avr_relax_section): Cache contents, relocs and syms
	before calling relax_delete_bytes.
2022-07-29 23:28:04 +09:30
Nick Clifton
b44cfc5de1 Stop the linker from complaining about unrecognised DW_FORM-rnglistx and DW_FORM_loclistx format attributes.
PR 29424
	* dwarf2.c (read_attribute_value): Handle DW_FORM_rnglistx and
	DW_FORM_loclistx.
2022-07-29 12:58:10 +01:00
Alan Modra
b875e9c93d PR16005, avr linker crash on a particular instruction sequence with --relax
It's possible for relax_delete_bytes to be called with section
contents NULL, as demonstrated by the testcase in this PR.

	PR 16005
	* elf32-avr.c (elf32_avr_relax_delete_bytes): Get section contents
	if not already available.
2022-07-29 17:25:35 +09:30