Commit Graph

9574 Commits

Author SHA1 Message Date
Nick Clifton
c203a2e3a8 Set development and experimental to false. Update version number to 2.40. Add release markers. Regenerate files 2023-01-14 13:42:32 +00:00
Nick Clifton
ea766c9dd6 Updated Romainian translation for the bfd sub-directory 2023-01-13 11:43:18 +00:00
Nick Clifton
3e307d538c Fix a potential illegal memory access in the BFD library when parsing a corrupt DWARF file.
PR 29988
	* dwarf2.c (read_indexed_address): Fix check for an out of range
	offset.
2023-01-11 12:13:46 +00:00
Nick Clifton
e1aec9c131 Updated Bulgarian and Russian translations for LD and BFD respectively 2023-01-06 11:01:44 +00:00
Alan Modra
6d53c0962c Update year range in copyright notice of binutils files
The newer update-copyright.py fixes file encoding too, removing cr/lf
on binutils/bfdtest2.c and ld/testsuite/ld-cygwin/exe-export.exp, and
embedded cr in binutils/testsuite/binutils-all/ar.exp string match.
2023-01-04 22:14:02 +10:30
Nick Clifton
447625978d Updated translations for various languages and sub-directories 2023-01-03 11:37:29 +00:00
Nick Clifton
a72b07181d Add markers for 2.40 branch 2022-12-31 12:05:28 +00:00
Nick Clifton
8af23b30ed Fix illegal memory access parsing corrupt DWARF information.
PR 29936
	* dwarf2.c (concat_filename): Fix check for a directory index off
	the end of the directory table.
2022-12-23 13:02:42 +00:00
Nick Clifton
ea6ed58e63 Updated Romanian translation for the BFD sub-directory. 2022-12-21 12:19:04 +00:00
Nick Clifton
83f18e5ebe Fix a dereference of NULL when scanning the symbol hashes array in the ARM linker.
PR 29852
	* elf32-arm.c (cmse_scan): Check for NULL entries in the
	sym_hashes array.
	(elf32_arm_gc_mark_extra_sections): Likewise.
2022-12-06 11:24:12 +00:00
Nick Clifton
942fa4fb32 Fix an illegal memory access when parsing a corrupt VMS Alpha file.
PR 29848
	* vms-alpha.c (parse_module): Fix potential out of bounds memory
	access.
2022-12-05 11:11:44 +00:00
Nick Clifton
6ef35c04df Fix verilog output when the width is > 1.
PR 25202
bfd	* bfd.c (VerilogDataEndianness): New variable.
	(verilog_write_record): Use VerilogDataEndianness, if set, to
	choose the endianness of the output.
	(verilog_write_section): Adjust the address by the data width.

binutils* objcopy.c (copy_object): Set VerilogDataEndianness to the
	endianness of the input file.
	(copy_main): Verifiy the value set by the --verilog-data-width
	option.
	* testsuite/binutils-all/objcopy.exp: Add tests of the new behaviour.
	* testsuite/binutils-all/verilog-I4.hex: New file.
2022-12-01 13:09:26 +00:00
Nick Clifton
1a7e622b82 Fix ARM and AArch64 assembler tests to work in a multi-arch environment.
PR 29764
gas	* testsuite/gas/arm/cpu-cortex-a76ae.d: Add arm prefix to the -m
	option passed to objdump.
	* testsuite/gas/arm/cpu-cortex-a77.d: Likewise.
	* testsuite/gas/aarch64/cpu-cortex-a76ae.d: Add aarch64 prefix to
	the -m option passed to objdump.
	* testsuite/gas/aarch64/cpu-cortex-a77.d: Likewise.

bfd	* cpu-arm.c (scan): Accept machine names prefixed with "arm:".
	* cpu-aarch64.c (scan): Accept machine names prefixed with "aarch64:".

bin	* doc/binutils.texi (objdump): Note that the -m option supports
	the <architecture>:<machine> syntax.
2022-11-21 16:44:02 +00:00
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
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
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
Frederic Cambus
d0a122d311 Add OpenBSD ARM Little Endian BFD support.
* config.bfd (arm-*-openbsd*): Restore target.
2022-09-02 11:29:54 +01: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
Frederic Cambus
ba86e75013 Add OpenBSD AArch64 Little Endian BFD support.
* config.bfd (aarch64-*-openbsd*): Add target.
2022-08-22 10:19:42 +01: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
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
Nick Clifton
27121f6740 Fix indentation in loongarch code, preventing a compile time warning. 2022-07-26 11:33:51 +01:00
Nick Clifton
0bd0932314 Add markers for 2.39 branch 2022-07-08 10:41:07 +01:00
Yvan Roux
5f3fc928df _bfd_real_fopen should not use ccs parameter on Windows
PR 25713
	* bfdio.c (_bfd_real_fopen): Delete ccs string.
2022-05-19 10:58:13 +01:00
John Baldwin
8e6afe4013 Create pseudo sections for NT_ARM_TLS notes on FreeBSD.
bfd/ChangeLog:

	* elf.c (elfcore_grok_freebsd_note): Handle NT_ARM_TLS notes.
2022-04-27 08:06:39 -07:00
Nick Clifton
0d38576a34 Emit a note warning the user that creating an executable stack because of a missing .note.GNU-stack section is deprecated.
PR 29072
bfd	* elflink.c (bfd_elf_size_dynamic_sections): Display a note to the
	user that the current ehaviour of creating an executable stack
	because of a missing .note.GNU-stack section is deprecated and
	will be changed in a future release.

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

ld	* testsuite/ld-elf/pr29072.b.warn: Update to include the note
	about the linker's behaviour being depreccated.
2022-04-25 12:53:08 +01:00
Cl?ment Chigot
2d23f9656c xcoff: implement linker relaxation
bfd/ChangeLog:

	* coff-rs6000.c (xcoff_reloc_type_noop): Add info argument.
	(xcoff_reloc_type_fail): Likewise.
	(xcoff_reloc_type_pos): Likewise.
	(xcoff_reloc_type_neg): Likewise.
	(xcoff_reloc_type_rel): Likewise.
	(xcoff_reloc_type_toc): Likewise.
	(xcoff_reloc_type_ba): Likewise.
	(xcoff_reloc_type_crel): Likewise.
	(xcoff_reloc_type_tls): Likewise.
	(xcoff_reloc_type_br): Add stub handler.
	(xcoff_ppc_relocate_section): Add info to
	xcoff_calculate_relocation.
	(xcoff_stub_indirect_call_code): New constant.
	(xcoff_stub_shared_call_code): Likewise.
	(bfd_xcoff_backend_data): Add stub code fields.
	(bfd_pmac_xcoff_backend_data): Likewise.
	* coff64-rs6000.c (xcoff64_reloc_type_br): Add stub handler.
	(xcoff64_ppc_relocate_section): Add info to
	xcoff64_calculate_relocation.
	(xcoff64_stub_indirect_call_code): New constant.
	(xcoff64_stub_shared_call_code): Likewise.
	(bfd_xcoff_backend_data): Add stub code fields.
	(bfd_xcoff_aix5_backend_data): Likewise.
	* libxcoff.h (struct xcoff_backend_data_rec): Add stub fields.
	(bfd_xcoff_stub_indirect_call_code): New define.
	(bfd_xcoff_stub_indirect_call_size): New define.
	(bfd_xcoff_stub_shared_call_code): New define.
	(bfd_xcoff_stub_shared_call_size): New define.
	(xcoff_reloc_function): Add info argument.
	(enum xcoff_stub_type): New enum.
	(struct xcoff_stub_hash_entry): New structure.
	* xcofflink.c (struct xcoff_link_hash_table): Add stub hash
	table and params fields.
	(xcoff_stub_hash_entry): New define.
	(xcoff_stub_hash_lookup): New define.
	(stub_hash_newfunc): New function.
	(_bfd_xcoff_bfd_link_hash_table_free): Free the new stub hash
	table.
	(_bfd_xcoff_bfd_link_hash_table_create): Create the new stub
	hash table.
	(xcoff_link_add_symbols): Save rawsize for XTY_SD.
	(bfd_xcoff_link_init): New function.
	(xcoff_stub_csect_name): New function.
	(xcoff_stub_get_csect_in_range): New function.
	(xcoff_stub_name): New function.
	(bfd_xcoff_get_stub_entry): New function.
	(bfd_xcoff_type_of_stub): New function.
	(xcoff_add_stub): New function.
	(xcoff_build_one_stub): New function.
	(bfd_xcoff_size_stubs): New function.
	(bfd_xcoff_build_stubs): New function.
	(xcoff_stub_create_relocations): New function.
	(xcoff_link_input_bfd): Adapt relocations to stub.
	(xcoff_write_global_symbol): Adapt to new TOC entries generated
	for stubs.
	(_bfd_xcoff_bfd_final_link): Handle stub file.
	* xcofflink.h (struct bfd_xcoff_link_params): New structure.

ld/ChangeLog:

	* emultempl/aix.em (params): New variable.
	(stub_file): New variable.
	(xcoff_add_stub_section): New function.
	(xcoff_layout_sections_again): New function
	(hook_in_stub): New function.
	(_after_allocation): Add stub creation.
	(_create_output_section_statements): Allocate stub file and
	pass params to backend.
2022-04-20 15:11:47 +01:00
Cl?ment Chigot
1876a54217 Stubs (added in a later patch) will generate new .loader symbols, once the allocations have been done. Thus, the .loader section cannot be layout before that.
bfd/ChangeLog:

	* coff-rs6000.c (_bfd_xcoff_put_ldsymbol_name): Write len in
	  ldinfo->strings instead of directly in the output_bfd.
	* coff64-rs6000.c (_bfd_xcoff64_put_ldsymbol_name): Likewise.
	* xcofflink.c (struct xcoff_link_hash_table): Remove ldrel_count
	  field. Add ldinfo field.
	(xcoff_mark_symbol): Adjust to new ldinfo field.
	(xcoff_mark): Likewise.
	(bfd_xcoff_link_count_reloc): Likewise.
	(xcoff_build_loader_section): Split into two functions: one that
	build the loader section (this function) and one that only size
	it...
	(xcoff_size_loader_section): ... (this function).
	(bfd_xcoff_size_dynamic_sections): Adapt to new ldinfo field.
	Move the part where the dynamic sections are build to ...
	(bfd_xcoff_build_dynamic_sections): ... this function.
	* xcofflink.h: Add bfd_xcoff_build_dynamic_sections prototype.

include/ChangeLog:

	* coff/xcoff.h (struct xcoff_loader_info): Add ldrel_count and
	libpath fields.

ld/ChangeLog:

	* emultempl/aix.em (_after_allocation): New function.
2022-04-20 15:07:50 +01:00
Alexander von Gluck IV
f5e7605006 binutils: enable PE on 32bit haiku build
* config.bfd (x86-haiku): Add i386_pei_vec as a selectable format.
2022-04-13 14:58:22 +01:00
Nick Clifton
7d41169b6d Debug info for function in Windows PE binary on wrong instruction
PR 29038
	* coffgen.c (coff_find_nearest_line_with_names): Fix typo
	retrieving saved bias.
2022-04-08 16:04:22 +01:00
Mark Harmstone
145667f8d9 Add support for COFF secidx relocations
bfd	* coff-i386.c (in_reloc_p): Add R_SECTION.
	(howto_table): Add R_SECTION.
	(coff_pe_i386_relocation_section): Add support for R_SECTION.
	(coff_i386_reloc_type_lookup): Add support for
	BFD_RELOC_16_SECCIDX.
	* coff-x86_64.c (in_reloc_p): Add R_SECTION.
	(howto_table): Add R_SECTION.
	(coff_pe_amd64_relocation_section): Add support for R_SECTION.
	(coff_amd64_reloc_type_lookup): Add support for
	BFD_RELOC_16_SECCIDX.
	* reloc.c: Add BFD_RELOC_16_SECIDX.
	* bfd-in2.h: Regenerate.
	* libbfd.h: Regenerate.

gas	* config/tc-i386.c (pe_directive_secidx): New function.
	(md_pseudo_table): Add support for secidx.
	(x86_cons_fix_new): Likewise.
	(tc_gen_reloc): Likewise.
	* expr.c (op_rank): Add O_secidx.
	* expr.h (operatorT): Likewise.
	* symbols.c (resolve_symbol_value): Add support for O_secidx.
	* testsuite/gas/i386/secidx.s: New test source file.
	* testsuite/gas/i386/secidx.d: New test driver file.
	* testsuite/gas/i386/i386.exp: Run new test.

include	* coff/i386.h: Define R_SECTION.
	* coff/x86_64.h: Likewise.

ld	* testsuite/ld-pe/secidx1.s: New test source file.
	* testsuite/ld-pe/secidx2.s: New test source file.
	* testsuite/ld-pe/secidx.d: New test driver file.
	* testsuite/ld-pe/secidx_64.d: New test driver file.
	* testsuite/ld-pe/pe.exp: Add new tests.
2022-04-07 14:47:17 +01:00
John Baldwin
b5c2367c3a Use pseudosections for NT_FREEBSD_X86_SEGBASES core dump notes.
This includes adding pseudosections when reading a core dump as well
as support for writing out a core dump note from a pseudosection.

bfd/ChangeLog:

	* elf-bfd.h (elfcore_write_x86_segbases): New.
	* elf.c (elfcore_grok_freebsd_note): Add pseudosections for
	NT_FREEBSD_X86_SEGBASES register notes.
	(elfcore_write_x86_segbases): New.
	(elfcore_write_register_note): Write NT_FREEBSD_X86_SEGBASES
	register notes.
2022-04-01 13:16:46 -07:00
John Baldwin
e330d4c033 elfcore_grok_freebsd_note: Remove checks of note->namesz.
This function is only called if the note name is "FreeBSD", so
checking the name size is unnecessary.

bfd/ChangeLog:

	* elf.c (elfcore_grok_freebsd_note): Remove checks for namesz.
2022-04-01 13:16:46 -07:00
Steiner H Gunderson
86ed2a5eae Fix return code in _bfd_dwarf2_find_nearest_line().
* dwarf2.c (_bfd_dwarf2_find_nearest_line): if a function name is
	found, but no line number info, then return a result of 2.
2022-03-22 15:32:32 +00:00
Steiner H Gunderson
30cbd32aec Reduce O(n2) performance overhead when parsing DWARF unit information.
PR 28978
	* dwarf2.c (scan_unit_for_symbols): When performing second pass,
	check to see if the function or variable being processed is the
	same as the previous one.
2022-03-21 14:29:12 +00:00
Viorel Preoteasa
a747a286b9 Fix ld-arm bug in encoding of blx calls jumping from thumb to arm instructions
PR 28924
	* elf32-arm.c (THM_MAX_FWD_BRANCH_OFFSET): Fix definition.
	(THM2_MAX_FWD_BRANCH_OFFSET): Likewise.
2022-03-18 15:32:28 +00:00
Simon Marchi
978602e83f bfd: add AMDGCN architecture
Add support for the AMDGCN architecture to BFD.

This is the bare minimum to get

  $ ./configure --target=amdgcn-hsa-amdhsa --disable-gas
  $ make all-binutils

working later in this series.

The specific AMDGCN models added here are a bit arbitrary, based on
what we intend to initially support in GDB.  This list will need to be
updated in the future anyway.  The complete up-to-date list of existing
AMDGPU models can be found here:

  https://llvm.org/docs/AMDGPUUsage.html#processors

The ELF format for this architecture is documented here:

  https://llvm.org/docs/AMDGPUUsage.html#elf-code-object

The flags for the "HSA" OS ABI are properly versioned and documented on
that page.  But the NONE, PAL and MESA3D OS ABIs are not well documented
nor versioned.  Taking a peek at the LLVM source code, we see that they
encode their flags the same way as HSA v3.  For example, for PAL:

  c8b614cd74/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp (L601)

So at least, we know that all AMDGPU objects (of which AMDGCN objects
are a subset of) at the time of writing encode the specific GPU model in
the EF_AMDGPU_MACH field of e_flags.

bfd/ChangeLog:

	* Makefile.am (ALL_MACHINES, ALL_MACHINES_CFILES):
	Add cpu-amdgcn.c.
	(BFD64_BACKENDS): Add elf64-amdgcn.lo.
	(BFD64_BACKENDS_CFILES): Add elf64-amdgcn.c.
	* Makefile.in: Re-generate.
	* cpu-amdgcn.c: New.
	* elf64-amdgcn.c: New.
	* archures.c (bfd_architecture): Add bfd_arch_amdgcn and related
	mach defines.
	(bfd_amdgcn_arch): New.
	(bfd_archures_list): Add bfd_amdgcn_arch.
	* bfd-in2.h: Re-generate.
	* config.bfd: Handle amdgcn* target.
	* configure.ac: Handle amdgcn_elf64_le_vec.
	* configure: Re-generate.
	* elf-bfd.h (elf_target_id): Add AMDGCN_ELF_DATA.
	* targets.c (amdgcn_elf64_le_vec): New.
	(_bfd_target_vector): Add amdgcn_elf64_le_vec.

include/ChangeLog:

	* elf/amdgpu.h: New.
	* elf/common.h (ELFOSABI_AMDGPU_HSA): Add.

Change-Id: I969f7b14960797e88891c308749a6e341eece5b2
2022-03-16 09:00:27 -04:00
Nick Clifton
ba0eb22c8b Fix a typo in the previous delta to bfdio.c.
PR 25713
	* bfdio.c (_bfd_real_fopen): Fix typo.
2022-03-01 13:13:42 +00:00
Nick Clifton
81c9e0f6c4 Prevent an assertion from being triggered when linking an ARM object file with incorrectly set build attributes.
PR 28848
	PR 28859
	* elf32-arm.c (elf32_arm_merge_eabi_attributes): If the first
	input bfd has a Tag_ABI_HardFP_use set to 3 but does not also have
	TAG_FP_arch set then reset the TAG_ABI_HardFP_use.
2022-03-01 09:51:59 +00:00
Torbj?rn Svensson
cb7da2a640 Further correct the handling of long pathnames on Windows hosts.
PR 25713
	* bfdio.c (_bfd_real_fopen): Fix handling of parhs longer than 260
	characters on Windows hosts.
2022-02-28 12:17:33 +00:00
Nick Clifton
eda240cd35 Clarify the wording of the error message when an obsolete configuration is encountered.
PR 28886
	* config.bfd: Update error message for obsolete configurations.
2022-02-28 12:05:30 +00:00
Nick Clifton
36d285b9da Updated Serbian translations for the bfd, gold, ld and opcodes directories 2022-02-17 15:18:59 +00:00
Fangrui Song
c212f39d9a ld: Support customized output section type
bfd/
    PR ld/28841
    * bfd-in2.h (struct bfd_section): Add type.
    (discarded_section): Add field.
    * elf.c (elf_fake_sections): Handle bfd_section::type.
    * section.c (BFD_FAKE_SECTION): Add field.
    * mri.c (mri_draw_tree): Update function call.

ld/
    PR ld/28841
    * ld.texi: Document new output section type.
    * ldlex.l: Add new token TYPE.
    * ldgram.y: Handle TYPE=exp.
    * ldlang.h: Add type_section to list of section types.
    * ldlang.c (lang_add_section): Handle type_section.
    (map_input_to_output_sections): Handle type_section.
    * testsuite/ld-scripts/output-section-types.t: Add tests.
    * testsuite/ld-scripts/output-section-types.d: Update.
2022-02-16 17:41:23 +00:00
Michael Forney
5d0d011be3 bfd: Remove return with expression in void function
* bfd.c (bfd_set_gp_value): Remove return with expression
        in void function.
2022-02-11 12:45:40 +00:00
Nick Clifton
0f38fd87ea Update the obsolete list and how-to-make-a-release documentation now that the 2.38 release is out. 2022-02-09 13:44:14 +00:00
Nick Clifton
41ba8b76cc Stop the BFD library complaining about compressed dwarf debug string sections being too big.
PR 28834
	* dwarf2.c (read_section): Change the heuristic that checks for
	overlarge dwarf debug info sections.
2022-02-02 17:06:22 +00:00
Stafford Horne
c7c6e55b60 or1k: Avoid R_OR1K_GOT16 signed overflow by using special howto
Previously when fixing PR 21464 we masked out upper bits of the
relocation value in order to avoid overflow complaints when acceptable.
It turns out this does not work when the relocation value ends up being
signed.

To fix this this patch introduces a special howto with
complain_on_overflow set to complain_overflow_dont.  This is used in
place of the normal R_OR1K_GOT16 howto when we detect R_OR1K_GOT_AHI16
relocations.

bfd/ChangeLog:

	PR 28735
	* elf32-or1k.c (or1k_elf_got16_no_overflow_howto): Define.
	(or1k_elf_relocate_section): Use new howto instead of trying to
	mask out relocation bits.
2022-02-02 20:11:56 +09:00
Roland McGrath
fdf55097a3 bfd/doc: Fix racy build failure from missing mkdir
bfd/
	* doc/local.mk (%D%/bfdver.texi): Add mkdir command.
2022-01-24 12:38:50 -08:00
Nick Clifton
5fe73d4624 Update Bulgarian, French, Romaniam and Ukranian translation for some of the sub-directories 2022-01-24 14:22:49 +00:00
Nick Clifton
f908e960c5 Change version number to 2.38.50 and regenerate files 2022-01-22 12:39:28 +00:00