Commit Graph

19331 Commits

Author SHA1 Message Date
GDB Administrator
57db1af8ba Automatic date update in version.in 2024-08-23 00:00:29 +00:00
GDB Administrator
622be1889a Automatic date update in version.in 2024-08-22 00:00:35 +00:00
GDB Administrator
28c3bf55f0 Automatic date update in version.in 2024-08-21 00:00:30 +00:00
GDB Administrator
1b32f601b1 Automatic date update in version.in 2024-08-20 00:00:12 +00:00
GDB Administrator
d71c16aec2 Automatic date update in version.in 2024-08-19 00:00:29 +00:00
GDB Administrator
f9b44496e6 Automatic date update in version.in 2024-08-18 00:00:17 +00:00
GDB Administrator
fe70001da2 Automatic date update in version.in 2024-08-17 00:00:27 +00:00
GDB Administrator
81e9e54636 Automatic date update in version.in 2024-08-16 00:00:17 +00:00
H.J. Lu
a6f8fe0a9e lto: Don't include unused LTO archive members in output
When plugin_object_p is called by elf_link_is_defined_archive_symbol to
check if a symbol in archive is a real definition, set archive member
plugin_format to bfd_plugin_yes_unused to avoid including the unused LTO
archive members in linker output.  When plugin_object_p is called as
known used, call plugin claim_file if plugin_format is bfd_plugin_unknown
or bfd_plugin_yes_unused.

To get the proper support for archives with LTO common symbols with GCC,
the GCC fix for

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

is needed.

bfd/

	PR ld/32083
	* archures.c (bfd_arch_get_compatible): Treat bfd_plugin_yes_unused
	the same as bfd_plugin_yes.
	* elflink.c (elf_link_is_defined_archive_symbol): Likewise.
	* bfd.c (bfd_plugin_format): Add bfd_plugin_yes_unused.
	* plugin.c (try_claim): Try claim_file_v2 first.
	* bfd-in2.h: Regenerated.

ld/

	PR ld/32083
	* plugin.c (plugin_call_claim_file): Add an argument to return
	if LDPT_REGISTER_CLAIM_FILE_HOOK_V2 is used.
	(plugin_object_p): When KNOWN_USED is false, we call plugin
	claim_file if plugin_format is bfd_plugin_unknown and set
	plugin_format to bfd_plugin_yes_unused on LTO object.  When
	KNOWN_USED is true, we call plugin claim_file if plugin_format
	is bfd_plugin_unknown or bfd_plugin_yes_unused.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2024-08-15 03:54:11 -07:00
GDB Administrator
6dac711fa2 Automatic date update in version.in 2024-08-15 00:00:35 +00:00
Xi Ruoyao
d15180ebed LoongArch: Fix DT_RELR and relaxation interaction
Due to the way BFD implements DT_RELR as a part of relaxation, if in a
relax trip size_relative_relocs has changed the layout, when
relax_section runs only the vma of the section being relaxed is
guaranteed to be updated.  Then bad thing can happen.  For example, when
linking an auxilary program _freeze_module in the Python 3.12.4 building
system (with PGO + LTO), before sizing the .relr.dyn section, the vma of
.text is 30560 and the vma of .rodata is 2350944; in the final
executable the vma of .text is 36704 and the vma of .rodata is 2357024.
The vma increase is expected because .relr.dyn is squashed somewhere
before .text.  But size_relative_relocs may see the state in which .text
is at 36704 but .rodata "is" still at 2350944.  Thus the distance
between .text and .rodata can be under-estimated and overflowing
R_LARCH_PCREL20_S2 reloc can be created.

To avoid this issue, if size_relative_relocs is updating the size of
.relr.dyn, just supress the normal relaxation in this relax trip.  In
this situation size_relative_relocs should have been demending the next
relax trip, so the normal relaxation can happen in the next trip.

I tried to make a reduced test case but failed.

Signed-off-by: Xi Ruoyao <xry111@xry111.site>
2024-08-14 17:45:02 +08:00
Xi Ruoyao
91e0b46551 LoongArch: Fix assertion failure with DT_RELR
In the DT_RELR implementation I missed a code path emiting relative
reloc entries.  Then the already packed relative reloc entries will be
(unnecessarily) pushed into .rela.dyn but we've not allocated the space
for them, triggering an assertion failure.

Unfortunately I failed to notice the issue until profiled bootstrapping
GCC with LTO and -Wl,-z,pack-relative-relocs.  The failure can be easily
triggered by linking a "hello world" program with -fprofile-generate and
LTO:

    $ PATH=$HOME/ld-test:$PATH gcc hw.c -fprofile-generate -Wl,-z,pack-relative-relocs -flto
    /home/xry111/git-repos/binutils-build/TEST/ld: BFD (GNU Binutils) 2.43.50.20240802 assertion fail ../../binutils-gdb/bfd/elfnn-loongarch.c:2628
    /home/xry111/git-repos/binutils-build/TEST/ld: BFD (GNU Binutils) 2.43.50.20240802 assertion fail ../../binutils-gdb/bfd/elfnn-loongarch.c:2628
    collect2: error: ld returned 1 exit status

And the reduced test case is just incredibly simple (included in the
patch) so it seems I'm just stupid enough to fail to detect it before.
Let's fix it now anyway.

Signed-off-by: Xi Ruoyao <xry111@xry111.site>
2024-08-14 17:45:02 +08:00
GDB Administrator
ca25db0641 Automatic date update in version.in 2024-08-14 00:00:42 +00:00
H.J. Lu
549bc65f05 elf: Never set non_ir_ref_regular for debug reference
Never set non_ir_ref_regular for debug reference since references in
debug sections shouldn't impact LTO output.

	* elflink.c (elf_link_add_object_symbols): Don't check strip for
	references in debug sections when setting non_ir_ref_regular.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2024-08-13 15:43:05 -07:00
GDB Administrator
b935898fd1 Automatic date update in version.in 2024-08-13 00:00:35 +00:00
GDB Administrator
3338faa385 Automatic date update in version.in 2024-08-12 00:00:29 +00:00
GDB Administrator
3fa12f5bd6 Automatic date update in version.in 2024-08-11 00:00:36 +00:00
Alan Modra
ec8f5671b4 PR32067, ld -Wl,--oformat,binary crash in _bfd_elf_link_keep_memory
The direct fix for this segfault is to test for a non-NULL bed in
_bfd_elf_link_keep_memory, but also there isn't much point in running
code for LTO if the output is binary.

	PR 32067
	* elflink.c (_bfd_elf_link_keep_memory): Test for non-NULL bed.
	(elf_link_add_object_symbols): Don't run the loop setting
	non_ir_ref_regular if the output hash table is not ELF.
2024-08-10 10:28:32 +09:30
GDB Administrator
e34f53c5e6 Automatic date update in version.in 2024-08-10 00:00:30 +00:00
GDB Administrator
2fba6c8908 Automatic date update in version.in 2024-08-09 00:00:28 +00:00
GDB Administrator
5b84cbc35a Automatic date update in version.in 2024-08-08 00:00:35 +00:00
Alan Modra
b93dcd1cdd loongarch ld testsuite xpasses
Some tests started passing with commit 3a83f0342e.  However,
supporting a changed ld output format is not so simple, and the change
to the loongarch_elf_hash_table macro needs further changes to the
rest of the code.  It is true that some uses of
loongarch_elf_hash_table do not need to check the type of the hash
table, but others like loongarch_elf_relax_section do need to check.
bfd_relax_section is called in lang_size_sections using the input bfd,
not the output bfd.  If the input bfd may be of different type to the
output, then the hash table type must be checked before accessing
elements of the hash table.  This patch corrects
loongarch_elf_relax_section.  I haven't checked all the uses of the
hash table throughout the loongarch backend.

bfd/
	* elfnn-loongarch.c (loongarch_elf_relax_section): Don't relax
	unless the hash table is loongarch_elf_link_hash_table.
	Move variable declarations.  Formatting.
ld/
	* testsuite/ld-elf/pr21884.d: Don't xfail loongarach.
	* testsuite/ld-unique/pr21529.d: Likewise.
2024-08-07 09:37:12 +09:30
GDB Administrator
c42ee4a1ca Automatic date update in version.in 2024-08-07 00:00:28 +00:00
Mary Bennett
2f1739a348 RISC-V: Add support for XCvBitmanip extension in CV32E40P
Spec: https://docs.openhwgroup.org/projects/cv32e40p-user-manual/en/latest/instruction_set_extensions.html

Contributors:
  Mary Bennett <mary.bennett682@gmail.com>
  Nandni Jamnadas <nandni.jamnadas@embecosm.com>
  Pietra Ferreira <pietra.ferreira@embecosm.com>
  Charlie Keaney
  Jessica Mills
  Craig Blackmore <craig.blackmore@embecosm.com>
  Simon Cook <simon.cook@embecosm.com>
  Jeremy Bennett <jeremy.bennett@embecosm.com>
  Helene Chelin <helene.chelin@embecosm.com>

bfd/ChangeLog:
	* elfxx-riscv.c (riscv_multi_subset_supports): Add `xcvbitmanip`
	instruction class.
	(riscv_multi_subset_supports_ext): Likewise.

gas/ChangeLog:
	* config/tc-riscv.c (validate_riscv_insn): Add custom operands `Xc6` and `Xc7`.
	(riscv_ip): Likewise.
	* doc/c-riscv.texi: Note XCVbitmanip as an additional ISA extension
	for CORE-V.
	* testsuite/gas/riscv/march-help.l: Add xcvbitmanip.
	* testsuite/gas/riscv/x-cv-bitmanip-fail.d: New Test.
	* testsuite/gas/riscv/x-cv-bitmanip-fail.l: New Test.
	* testsuite/gas/riscv/x-cv-bitmanip-fail.s: New Test.
	* testsuite/gas/riscv/x-cv-bitmanip.d: New Test.
	* testsuite/gas/riscv/x-cv-bitmanip.s: New Test.

include/opcode/ChangeLog:
	* riscv-opc.h: Add corresponding MATCH and MASK macros for
	XCVbitmanip.
	* riscv.h: Add corresponding EXTRACT and ENCODE macros for
	XCVbitmanip.
	(enum riscv_insn_class): Add the XCVbitmanip instruction class.

opcodes/ChangeLog:
	* riscv-dis.c (print_insn_args): Add custom operands `Xc6` and `Xc7`.
	* riscv-opc.c: Add XCvBitmanip instructions.
2024-08-06 13:57:33 +08:00
Xiao Zeng
8a3ffa7194 RISC-V: Add support for Zcmop extension
This implements the Zcmop (Compressed Zimop) extension, as of version 1.0.

View detailed information in:
<https://github.com/riscv/riscv-isa-manual/blob/main/src/zimop.adoc>

The Zcmop extension requires the Zca extension.

bfd/ChangeLog:

	* elfxx-riscv.c (riscv_multi_subset_supports): Handle Zcmop.
	(riscv_multi_subset_supports_ext): Ditto.

gas/ChangeLog:

	* NEWS: Updated.
	* testsuite/gas/riscv/march-help.l: Ditto.
	* testsuite/gas/riscv/zcmop.d: New test.
	* testsuite/gas/riscv/zcmop.s: New test.

include/ChangeLog:

	* opcode/riscv-opc.h (DECLARE_INSN): New declarations for Zcmop.
	(MATCH_C_MOP_1, MATCH_C_MOP_3, MATCH_C_MOP_5, MATCH_C_MOP_7,
	MATCH_C_MOP_9, MATCH_C_MOP_11, MATCH_C_MOP_13, MATCH_C_MOP_15): Define.
	(MASK_C_MOP_1, MASK_C_MOP_3, MASK_C_MOP_5, MASK_C_MOP_7,
	MASK_C_MOP_9, MASK_C_MOP_11, MASK_C_MOP_13, MASK_C_MOP_15): Ditto.
	* opcode/riscv.h (enum riscv_insn_class): Add INSN_CLASS_ZCMOP.

opcodes/ChangeLog:

	* riscv-opc.c: Add Zcmop instructions.
2024-08-06 13:36:21 +08:00
Xiao Zeng
3ba06284d2 RISC-V: Add support for Zimop extension
This implements the Zimop (May-Be-Operations) extension, as of version 1.0.

View detailed information in:
<https://github.com/riscv/riscv-isa-manual/blob/main/src/zimop.adoc>

bfd/ChangeLog:

	* elfxx-riscv.c (riscv_multi_subset_supports): Handle Zimop
	(riscv_multi_subset_supports_ext): Ditto.

gas/ChangeLog:

	* NEWS: Updated.
	* testsuite/gas/riscv/march-help.l: Ditto.
	* testsuite/gas/riscv/zimop.d: New test.
	* testsuite/gas/riscv/zimop.s: New test.

include/ChangeLog:

	* opcode/riscv-opc.h (DECLARE_INSN): New declarations for Zimop.
	(MATCH_MOP_R_0, MATCH_MOP_R_1, MATCH_MOP_R_2, MATCH_MOP_R_3,
	MATCH_MOP_R_4, MATCH_MOP_R_5, MATCH_MOP_R_6, MATCH_MOP_R_7,
	MATCH_MOP_R_8, MATCH_MOP_R_9, MATCH_MOP_R_10, MATCH_MOP_R_11,
	MATCH_MOP_R_12, MATCH_MOP_R_13, MATCH_MOP_R_14, MATCH_MOP_R_15,
	MATCH_MOP_R_16, MATCH_MOP_R_17, MATCH_MOP_R_18, MATCH_MOP_R_19,
	MATCH_MOP_R_20, MATCH_MOP_R_21, MATCH_MOP_R_22, MATCH_MOP_R_23,
	MATCH_MOP_R_24, MATCH_MOP_R_25, MATCH_MOP_R_26, MATCH_MOP_R_27,
	MATCH_MOP_R_28, MATCH_MOP_R_29, MATCH_MOP_R_30, MATCH_MOP_R_31,
	MATCH_MOP_RR_0, MATCH_MOP_RR_1, MATCH_MOP_RR_2, MATCH_MOP_RR_3,
	MATCH_MOP_RR_4, MATCH_MOP_RR_5, MATCH_MOP_RR_6, MATCH_MOP_RR_7): Define.
	(MASK_MOP_R_0, MASK_MOP_R_1, MASK_MOP_R_2, MASK_MOP_R_3, MASK_MOP_R_4,
	MASK_MOP_R_5, MASK_MOP_R_6, MASK_MOP_R_7, MASK_MOP_R_8, MASK_MOP_R_9,
	MASK_MOP_R_10, MASK_MOP_R_11, MASK_MOP_R_12, MASK_MOP_R_13,
	MASK_MOP_R_14, MASK_MOP_R_15, MASK_MOP_R_16, MASK_MOP_R_17,
	MASK_MOP_R_18, MASK_MOP_R_19, MASK_MOP_R_20, MASK_MOP_R_21,
	MASK_MOP_R_22, MASK_MOP_R_23, MASK_MOP_R_24, MASK_MOP_R_25,
	MASK_MOP_R_26, MASK_MOP_R_27, MASK_MOP_R_28, MASK_MOP_R_29,
	MASK_MOP_R_30, MASK_MOP_R_31, MASK_MOP_RR_0, MASK_MOP_RR_1,
	MASK_MOP_RR_2, MASK_MOP_RR_3, MASK_MOP_RR_4, MASK_MOP_RR_5,
	MASK_MOP_RR_6, MASK_MOP_RR_7): Ditto.
	* opcode/riscv.h (enum riscv_insn_class): Add INSN_CLASS_ZIMOP.

opcodes/ChangeLog:

	* riscv-opc.c: Add Zimop instructions.
2024-08-06 13:10:31 +08:00
GDB Administrator
60d4fed4e3 Automatic date update in version.in 2024-08-06 00:00:29 +00:00
mengqinggang
3a83f0342e LoongArch: Add support for OUTPUT_FORMAT("binary")
In binary output format, loongarch_elf_hash_table return NULL and result
in segment fault.

When ld output binary file, it seems that elf related functions should
not be called. But loongarch_elf_relax_section be called and
loongarch_elf_hash_table cause segment fault.

Just redefined loongarch_elf_hash_table and always return
link_info->hash.

The tests of binutils, glibc and gcc is ok.

0  loongarch_elf_relax_section ()
1  0x000055555557ab28 in lang_size_sections_1 ()
2  0x000055555557a16c in lang_size_sections_1 ()
3  0x000055555557b0a8 in one_lang_size_sections_pass ()
4  0x000055555557b478 in lang_size_sections ()
5  0x000055555557e65c in lang_relax_sections ()
6  0x000055555559f9c8 in ldelf_map_segments ()
7  0x000055555559783c in gldelf64loongarch_after_allocation ()
8  0x000055555558dac0 in ldemul_after_allocation ()
9  0x000055555557f6c0 in lang_process ()
10 0x0000555555585314 in main ()
2024-08-05 17:38:49 +08:00
GDB Administrator
0c817e7c10 Automatic date update in version.in 2024-08-05 00:00:29 +00:00
GDB Administrator
ef2a5e0d07 Automatic date update in version.in 2024-08-04 00:00:28 +00:00
GDB Administrator
7ff899ed54 Automatic date update in version.in 2024-08-03 00:00:17 +00:00
GDB Administrator
b6e1210536 Automatic date update in version.in 2024-08-02 00:00:31 +00:00
GDB Administrator
c2e15bf519 Automatic date update in version.in 2024-08-01 00:00:43 +00:00
GDB Administrator
762f95fdc6 Automatic date update in version.in 2024-07-31 00:00:28 +00:00
GDB Administrator
548dbdb27f Automatic date update in version.in 2024-07-30 00:00:17 +00:00
Nick Clifton
8896efce13 Updated translations for the bfd, binutils, gas, ld and opcodes directories 2024-07-29 11:57:25 +01:00
GDB Administrator
2509e28c88 Automatic date update in version.in 2024-07-29 00:00:23 +00:00
GDB Administrator
64a565589c Automatic date update in version.in 2024-07-28 00:00:20 +00:00
GDB Administrator
ced7ecee43 Automatic date update in version.in 2024-07-27 00:00:23 +00:00
GDB Administrator
5a7f5aa29b Automatic date update in version.in 2024-07-26 00:00:25 +00:00
H.J. Lu
f73f5173fa x86: Add missing newlines in TLS transition error messages
Change TLS transition error messages from

a-argp-help.o(.text+0x12f): relocation R_X86_64_GOTTPOFF against `a' must be used in ADD or MOV onlyld: final link failed: bad value

to

a-argp-help.o(.text+0x12f): relocation R_X86_64_GOTTPOFF against `a' must be used in ADD or MOV only
ld: final link failed: bad value

	PR ld/32017
	* elfxx-x86.c (_bfd_x86_elf_link_report_tls_transition_error):
	Add missing newlines.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2024-07-25 13:03:19 -07:00
H.J. Lu
1d68a49ac5 x86: Improve TLS transition error check
Provide detailed TLS transition errors when unsupported instructions are
used.  Treat R_X86_64_CODE_4_GOTTPOFF and R_X86_64_CODE_6_GOTTPOFF as
R_X86_64_GOTTPOFF when performing TLS transition.

bfd/

	PR ld/32017
	* elf32-i386.c (elf_i386_check_tls_transition): Return different
	enums for different errors.
	(elf_i386_tls_transition): Change argument from r_symndx to sym.
	Call _bfd_x86_elf_link_report_tls_transition_error to report TLS
	transition errors.
	(elf_i386_scan_relocs): Pass isym instead of r_symndx to
	elf_i386_tls_transition.
	(elf_i386_relocate_section): Pass sym instead of r_symndx to
	elf_i386_tls_transition.
	* elf64-x86-64.c (elf_x86_64_check_tls_transition): Return
	different enums for different errors.
	(elf_x86_64_tls_transition): Change argument from r_symndx to sym.
	Treat R_X86_64_CODE_4_GOTTPOFF and R_X86_64_CODE_6_GOTTPOFF as
	R_X86_64_GOTTPOFF.  Call
	_bfd_x86_elf_link_report_tls_transition_error to report TLS
	transition errors.
	(elf_x86_64_scan_relocs): Pass isym instead of r_symndx to
	elf_x86_64_tls_transition.
	(elf_x86_64_relocate_section): Pass sym instead of r_symndx to
	elf_x86_64_tls_transition.
	* elfxx-x86.c (_bfd_x86_elf_link_report_tls_transition_error): New.
	* elfxx-x86.h (elf_x86_tls_error_type): Likewise.
	(_bfd_x86_elf_link_report_tls_transition_error): Likewise.

ld/

	PR ld/32017
	* testsuite/ld-i386/i386.exp: Run tlsgdesc1 and tlsgdesc2.
	* testsuite/ld-i386/tlsie2.d: Updated.
	* testsuite/ld-i386/tlsie3.d: Likewise.
	* testsuite/ld-i386/tlsie4.d: Likewise.
	* testsuite/ld-i386/tlsie5.d: Likewise.
	* testsuite/ld-x86-64/tlsie2.d: Likewise.
	* testsuite/ld-x86-64/tlsie3.d: Likewise.
	* testsuite/ld-i386/tlsgdesc1.d: New file.
	* testsuite/ld-i386/tlsgdesc1.s: Likewise.
	* testsuite/ld-i386/tlsgdesc2.d: Likewise.
	* testsuite/ld-i386/tlsgdesc2.s: Likewise.
	* testsuite/ld-x86-64/tlsdesc3.d: Likewise.
	* testsuite/ld-x86-64/tlsdesc3.s: Likewise.
	* testsuite/ld-x86-64/tlsdesc4.d: Likewise.
	* testsuite/ld-x86-64/tlsdesc4.s: Likewise.
	* testsuite/ld-x86-64/tlsie5.d: Likewise.
	* testsuite/ld-x86-64/tlsie5.s: Likewise.
	* testsuite/ld-x86-64/x86-64.exp: Run tlsie5, tlsdesc3 and
	tlsdesc4.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2024-07-25 12:40:19 -07:00
GDB Administrator
a93faed5d4 Automatic date update in version.in 2024-07-25 00:00:24 +00:00
Nick Clifton
88141209e2 BFD: Add .relro_padding to list of special sections 2024-07-24 14:47:51 +01:00
Nelson Chu
91a84aaf9a RISC-V: PR32001, Untranslated "internal:" prefix for error message.
bfd/
	PR 32001
	* elfxx-riscv.c (riscv_update_subset1): Fixed the untranslated
	"internal:" prefix for error message.
2024-07-24 13:07:17 +08:00
GDB Administrator
6f57c9823e Automatic date update in version.in 2024-07-24 00:00:21 +00:00
Pali Roh?r
91b999864f Improve objdump's display of PE header information.
PR 31953
2024-07-23 08:52:21 +01:00
GDB Administrator
85402ee9ed Automatic date update in version.in 2024-07-23 00:00:17 +00:00
GDB Administrator
5cbed9c77b Automatic date update in version.in 2024-07-22 00:00:11 +00:00
GDB Administrator
d2f8ed9019 Automatic date update in version.in 2024-07-21 00:00:24 +00:00