Commit Graph

19386 Commits

Author SHA1 Message Date
GDB Administrator
d9589324ff Automatic date update in version.in 2024-09-27 00:00:10 +00:00
Andreas Schwab
d31c9cf54a Fix -Wstringop-overflow warning in ecoff_link_hash_newfunc
* ecoff.c (ecoff_link_hash_newfunc): Don't call memset if ret is
	NULL.
2024-09-26 13:56:44 +02:00
GDB Administrator
c9cfe943aa Automatic date update in version.in 2024-09-26 00:00:14 +00:00
Jiawei
f0bdf8c169 RISC-V: Add Smrnmi extension csrs.
This patch support Smrnmi extension[1],
The csrs address can be find in[2].

[1] 35eb3948bf
[2] https://github.com/riscv/riscv-isa-manual/blob/smrnmi-1.0/src/priv-csrs.adoc

bfd/ChangeLog:

	* elfxx-riscv.c: New extension.

gas/ChangeLog:

	* NEWS: Add Smrnmi extension support.
	* config/tc-riscv.c (enum riscv_csr_class): New extension class.
	(riscv_csr_address): Ditto.
	* testsuite/gas/riscv/csr-version-1p10.d: New csrs.
	* testsuite/gas/riscv/csr-version-1p10.l: Ditto.
	* testsuite/gas/riscv/csr-version-1p11.d: Ditto.
	* testsuite/gas/riscv/csr-version-1p11.l: Ditto.
	* testsuite/gas/riscv/csr-version-1p12.d: Ditto.
	* testsuite/gas/riscv/csr-version-1p12.l: Ditto.
	* testsuite/gas/riscv/csr.s:  Ditto.
	* testsuite/gas/riscv/march-help.l: New extension.

include/ChangeLog:

	* opcode/riscv-opc.h (CSR_MNSCRATCH): New csr.
	(CSR_MNEPC): Ditto.
	(CSR_MNCAUSE): Ditto.
	(CSR_MNSTATUS): Ditto.
	(DECLARE_CSR): New csr declarations.
2024-09-25 09:28:27 +08:00
GDB Administrator
85536552c1 Automatic date update in version.in 2024-09-25 00:00:11 +00:00
GDB Administrator
05ff7a4dfe Automatic date update in version.in 2024-09-24 00:00:35 +00:00
GDB Administrator
f844c8f242 Automatic date update in version.in 2024-09-23 00:00:12 +00:00
GDB Administrator
104ee50245 Automatic date update in version.in 2024-09-22 00:00:09 +00:00
GDB Administrator
dfc2e69ba4 Automatic date update in version.in 2024-09-21 00:00:11 +00:00
GDB Administrator
c0f2499785 Automatic date update in version.in 2024-09-20 00:00:09 +00:00
GDB Administrator
5ea2e0f74e Automatic date update in version.in 2024-09-19 00:00:12 +00:00
Xin Wang
28489a70d4 LoongArch: Add elfNN_loongarch_mkobject to initialize LoongArch tdata
LoongArch: Add elfNN_loongarch_mkobject to initialize LoongArch tdata.
2024-09-18 15:04:27 +08:00
GDB Administrator
e5856db331 Automatic date update in version.in 2024-09-18 00:00:11 +00:00
GDB Administrator
1794b3a18d Automatic date update in version.in 2024-09-17 00:00:12 +00:00
GDB Administrator
3073d684c1 Automatic date update in version.in 2024-09-16 00:00:09 +00:00
GDB Administrator
a86253944d Automatic date update in version.in 2024-09-15 00:00:23 +00:00
GDB Administrator
37fc1b20cf Automatic date update in version.in 2024-09-14 00:00:07 +00:00
GDB Administrator
40422bbae1 Automatic date update in version.in 2024-09-13 00:00:11 +00:00
GDB Administrator
4290b2c07e Automatic date update in version.in 2024-09-12 00:00:10 +00:00
Christophe Lyon
a77ccc8129 arm: Handle undefweak with ST_BRANCH_UNKNOWN
A previous patch made ld fail early on Thumb-only where branch_type is
ST_BRANCH_UNKNOWN.

However, this fails erroneously when the target is undefweak: in that
case the branch should be replaced by a branch to the next instruction
(or nop.w on thumb2).  This patch accepts this case and restores the
previous behaviour in such cases.

This was reported by failures in the GCC testsuite, where we fail to
link executables because __deregister_frame_info is undefweak:

(__deregister_frame_info): Unknown destination type (ARM/Thumb) in ...crtbegin.o
crtbegin.o: in function `__do_global_dtors_aux':
crtstuff.c:(.text+0x52): dangerous relocation: unsupported relocation
2024-09-11 15:34:32 +00:00
GDB Administrator
80b48e0afd Automatic date update in version.in 2024-09-11 00:00:10 +00:00
H.J. Lu
c839a44c39 bfd: Pass true to ld_plugin_object_p
Since linker calls bfd_plugin_object_p, which calls ld_plugin_object_p,
only for command-line input objects, pass true to ld_plugin_object_p so
that the same input IR file won't be included twice if the new LTO hook,
LDPT_REGISTER_CLAIM_FILE_HOOK_V2 isn't used.

	PR ld/32153
	* plugin.c (bfd_plugin_object_p): Pass true to ld_plugin_object_p.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2024-09-09 19:16:17 -07:00
GDB Administrator
f66673c62e Automatic date update in version.in 2024-09-10 00:00:10 +00:00
GDB Administrator
4bc828f876 Automatic date update in version.in 2024-09-09 00:00:13 +00:00
GDB Administrator
7e4f57dc1b Automatic date update in version.in 2024-09-08 00:00:12 +00:00
Xin Wang
9a33a0b9c6 Not append rela for absolute symbol
LoongArch: Not append rela for absolute symbol

Use la.global to get absolute symbol like la.abs.
la.global put address of a global symbol into a got
entry and append a rela for it, which will be used
to relocate by dynamic linker. Dynamic linker should
not relocate for got entry of absolute symbol as it
stores symval not symbol's address.
2024-09-07 10:07:13 +08:00
Xin Wang
2bbe107902 Add macros to get opcode of instructions approriately
LoongArch: Add macros to get opcode and register of instructions appropriately

Currently, we get opcode of an instruction by manipulate the binary with
it's mask, it's a bit of a pain. Now a macro is defined to do this and a
macro to get the RD and RJ registers which is applicable to most instructions
of LoongArch are added.
2024-09-07 10:06:03 +08:00
GDB Administrator
4723415cda Automatic date update in version.in 2024-09-07 00:00:27 +00:00
Shahab Vahedi
237df762d7 bfd: Fix GCC warning when CFLAGS="-Og" is used
This patch initializes the "op" variable in skip_cfa_op() function
of bfd/elf-eh-frame.c to "0" at its declaration point to avoid the
"maybe-uninitialized" warning.

Building binutils on a system with GCC version 13.2.0 and a configure
command that sets the optimization level to "-Og" leads to a build
failure because of a warning being treated as an error:
---------------------------------------------------------------------
$ ./configure CFLAGS="-Og"
$ make
  ...
  CC       elf-eh-frame.lo
  /src/gdb/bfd/elf-eh-frame.c: In function 'skip_cfa_op':
  /src/gdb/bfd/elf-eh-frame.c:354:33: error: 'op' may be used
    uninitialized [-Werror=maybe-uninitialized]
  354 |   switch (op & 0xc0 ? op & 0xc0 : op)
      |           ~~~~~~~~~~~~~~~~~~~~~~^~~~
  /src/gdb/bfd/elf-eh-frame.c:348:12: note: 'op' was declared here
  348 |   bfd_byte op;
      |            ^~
  cc1: all warnings being treated as errors
  ...
---------------------------------------------------------------------

The relevant code snippet related to this warning looks like:
---------------------------------------------------------------------
  static inline bool
  read_byte (bfd_byte **iter, bfd_byte *end, unsigned char *result)
  {
    if (*iter >= end)
      return false;
    *result = *((*iter)++);
    return true;
  }

  static bool
  skip_cfa_op (bfd_byte **iter, bfd_byte *end,...)
  {
    bfd_byte op;

    if (!read_byte (iter, end, &op))
      return false;

    switch (op & 0xc0 ? op & 0xc0 : op)
    ...
  }
---------------------------------------------------------------------

This warning probably happens because "-Og" results in GCC not
inlining the "read_byte()" function. Therefore, GCC treats its
invocation inside "skip_cfa_op()" like a black box and that ends
in the aforementioned warning.

Acknowledgement:
  Lancelot Six -- for coming with the idea behind this fix.
  Jan Beulich  -- for reviewing.

bfd/ChangeLog:
	* elf-eh-frame.c (skip_cfa_op): Initialize the "op" variable.
2024-09-06 08:36:32 +02:00
Jan Beulich
a844415db8 bfd/PE: correct SizeOfImage calculation
We don't really want to align the last section's size to object
alignment (when that section may itself not be aligned as much), we want
image size to be a multiple thereof.
2024-09-06 08:34:24 +02:00
GDB Administrator
9772824e0e Automatic date update in version.in 2024-09-06 00:00:15 +00:00
Mark Harmstone
897a57a126 bfd/pdb: fix -Wmaybe-uninitialized warning
Initialize stream0_start to fix spurious -Wmaybe-uninitialized warning
on some versions of gcc.
2024-09-05 09:58:47 +01:00
Alan Modra
8a72d8924a PR32136, Use-of-uninitialized-memory in evax_bfd_print_image
PR 32136
	 * vms-alpha.c (evax_bfd_print_image): Sanity check various string
	 lengths.
2024-09-05 16:14:03 +09:30
Lulu Cai
88327cbcd0 LoongArch: Fixed ABI v1.00 TLS dynamic relocation generation bug
Commit "b67a17aa7c0c478a" modified the logic of allocating dynamic
relocation space for TLS GD/IE, but only modified the logic of
generation dynamic relocations for TLS GD/IE in ABI v2.00. When
linking an object file of ABI v1.00 with bfd ld of ABI v2.00, it
will cause an assertion failure.

Modified the dynamic relocation generation logic of TLS GD/IE
in ABI v1.00 to be consistent with ABI v2.00.
2024-09-05 11:48:44 +08:00
GDB Administrator
9adad97491 Automatic date update in version.in 2024-09-05 00:00:11 +00:00
Christophe Lyon
31ed3a9d69 arm: Do not insert stubs needing Arm code on Thumb-only cores.
We recently fixed a bug in libgcc
(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115360)
where a symbol was missing a %function .type decoration.

This meant the linker would silently pick the wrong type of 'farcall
stub', involving Arm-mode instructions on Thumb-only CPUs.

This patch emits an error instead, and warns in some other cases, to
encourage users to add the missing '.type foo,%function' directive.

In practice: in arm_type_of_stub() we no longer try to infer which
stub to use if the destination is of unknown type and the CPU is
Thumb-only; so we won't lie to elf32_arm_size_stubs() which does not
check branch_type.

If branch_type is ST_BRANCH_TO_ARM but the CPU is Thumb-only, we now
convert it to ST_BRANCH_TO_THUMB only if the destination is of
absolute type.  This is to support the case where the destination of
the branch is defined by the linker script (see thumb-b-lks-sym.s and
thumb-bl-lks-sym.s testcases for instance).

The motivating case is covered by the new farcall-missing-type
testcase, where we now emit an error message.  We do not emit an error
when branch_type is ST_BRANCH_UNKNOWN and the CPU supports Arm-mode: a
lot of legacy code (e.g. newlib's crt0.S) lacks the corresponding
'.type foo, %function' directives and even a (too verbose) warning
could be perceived as a nuisance.

Existing testcases where such a warning would trigger:
arm-static-app.s (app_func, app_func2)
arm-rel32.s (foo)
arm-app.s (app_func)
rel32-reject.s () main)
fix-arm1176.s (func_to_branch_to)
but this list is not exhaustive.

For the sake of clarity, the patch replaces occurrences of
sym.st_target_internal = 0; with
sym.st_target_internal = ST_BRANCH_TO_ARM;

enum arm_st_branch_type is defined in include/elf/arm.h, and relies on
ST_BRANCH_TO_ARM==0, as sym.st_target_internal is also initialized to
0 in other target-independent parts of BFD code.  (For instance,
swapping the ST_BRANCH_TO_ARM and ST_BRANCH_TO_THUMB entries in the
enum definition leads to 'interesting' results...)

Regarding the testsuite:
* new expected warning for thumb-b-lks-sym and thumb-bl-lks-sym
* new testcase farcall-missing-type to check the new error case
* attr-merge-arch-2b.s, branch-futures (and bfs-1.s) updated to avoid
  a diagnostic

Tested on arm-eabi and arm-pe with no regression.
2024-09-04 13:35:10 +00:00
Mark Harmstone
b281480b26 bfd/pdb: fix bitmap generation in pdb_write_bitmap
MSVC 2022 is more pedantic than MSVC 2019 when it comes to loading PDB
files in readonly mode, and was rejecting PDB files generated by binutils
because of their invalid free-space bitmaps. It's unknown what would
have happened if you tried to use MS tools to modify a PDB created by
binutils, but it probably would have led to a corrupted file.

This patch fixes pdb_write_bitmap so we generate files that MSVC will accept.

Specifically there were three things we were doing wrong:

- We weren't including the superblock (block 0)

- We were setting bits in bytes backwards (MSB to LSB, rather than LSB to MSB)

- We should have been marking the contents of stream 0 as free. This is
  because, as the comment says, it's intended to be used for the
  directory for the previous write, to allow atomic updates.
2024-09-04 02:24:37 +01:00
GDB Administrator
6225a4d33a Automatic date update in version.in 2024-09-04 00:00:13 +00:00
Mary Bennett
a6ecb18b79 RISC-V: Add support for XCVsimd 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 `xcvsimd`
	instruction class.
	(riscv_multi_subset_supports_ext): Likewise.

gas/ChangeLog:
	* NEWS: Updated.
	* config/tc-riscv.c (validate_riscv_insn): Add custom operands.
	(riscv_ip): Likewise.
	* doc/c-riscv.texi: Note XCVsimd as an additional ISA extension
	for CORE-V.
	* testsuite/gas/riscv/march-help.l: Add xcvsimd.
	* testsuite/gas/riscv/x-cv-simd.d: New test.
	* testsuite/gas/riscv/x-cv-simd.s: New test.
	* testsuite/gas/riscv/x-cv-simd-fail.d: New test.
	* testsuite/gas/riscv/x-cv-simd-fail.l: New test.
	* testsuite/gas/riscv/x-cv-simd-fail.s: New test.

include/ChangeLog:

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

opcodes/ChangeLog:

	* riscv-dis.c (print_insn_args): Add custom operands.
	* riscv-opc.c: Add XCVsimd instructions.
2024-09-03 12:02:28 +08:00
GDB Administrator
cf52562182 Automatic date update in version.in 2024-09-03 00:00:29 +00:00
GDB Administrator
073e508b61 Automatic date update in version.in 2024-09-02 00:00:12 +00:00
GDB Administrator
95dac28352 Automatic date update in version.in 2024-09-01 00:00:09 +00:00
H.J. Lu
5a655b5291 x86: Fix comment typos in TLS relocation check
R_386_TLS_IE is used only in

	movl foo@indntpoff, %eax
	movl foo@indntpoff, %reg
	addl foo@indntpoff, %reg

R_386_TLS_DESC_CALL and R_X86_64_TLSDESC_CALL are used only in

	call *x@tlscall(%[er]ax)

	* elf32-i386.c (elf_i386_check_tls_transition): Use foo@indntpoff
	in comments for R_386_TLS_IE check.
	(elf_i386_tls_transition): Use @tlscall in comments for
	R_386_TLS_DESC_CALL check.
	* elf64-x86-64.c (elf_x86_64_tls_transition): Use @tlscall in
	comments for R_X86_64_TLSDESC_CALL check.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2024-08-31 05:07:19 -07:00
GDB Administrator
d5de35fb07 Automatic date update in version.in 2024-08-31 00:00:08 +00:00
H.J. Lu
67e30b1521 x86: Check invalid TLS descriptor call
TLS descriptor call,

call *x@tlsdesc(%rax)

or

call *x@tlsdesc(%eax)

calls _dl_tlsdesc_return which expects that RAX/EAX points to the TLS
descriptor.  Update x86 linker to issue an error with or without TLS
transition.

bfd/

	PR ld/32123
	* elf32-i386.c (elf_i386_check_tls_transition): Move
	R_386_TLS_DESC_CALL to ...
	(elf_i386_tls_transition): Here.
	* elf64-x86-64.c (elf_x86_64_check_tls_transition): Move.
	R_X86_64_TLSDESC_CALL check to ...
	(elf_x86_64_tls_transition): Here.

ld/

	PR ld/32123
	* testsuite/ld-i386/i386.exp: Run tlsgdesc3.
	* testsuite/ld-i386/tlsgdesc3.d: New file.
	* testsuite/ld-x86-64/tlsdesc5.d: Likewise.
	* testsuite/ld-x86-64/x86-64.exp: Run tlsdesc5.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2024-08-30 05:18:10 -07:00
GDB Administrator
2e9df7573a Automatic date update in version.in 2024-08-30 00:00:09 +00:00
GDB Administrator
5cca20f614 Automatic date update in version.in 2024-08-29 00:00:14 +00:00
H.J. Lu
c9652a062f x86: Report expected register for elf_x86_tls_error_indirect_call
Since R_386_TLS_DESC_CALL can only be used with

	call	*variable@TLSCALL(%eax)

and R_X86_64_TLSDESC_CALL can only be used with

	call	*variable@TLSCALL(%rax)

update TLS transition error report to display the expected register in
indirect CALL.

bfd/

	PR ld/32017
	* elfxx-x86.c (_bfd_x86_elf_link_hash_table_create): Initialize
	the ax_register field.
	(_bfd_x86_elf_link_report_tls_transition_error): Report the
	expected register in elf_x86_tls_error_indirect_call error.
	* elfxx-x86.h (elf_x86_link_hash_table): Add ax_register.

ld/

	PR ld/32017
	* testsuite/ld-i386/tlsgdesc2.d: Updated.
	* testsuite/ld-i386/tlsgdesc2.s: Change jmp to call via ECX.
	* testsuite/ld-x86-64/tlsdesc4.d: Updated.
	* testsuite/ld-x86-64/tlsdesc4.s: Change jmp to call via RCX.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2024-08-28 05:56:25 -07:00
GDB Administrator
934fcc7c91 Automatic date update in version.in 2024-08-28 00:00:09 +00:00
GDB Administrator
47649afc96 Automatic date update in version.in 2024-08-27 00:00:09 +00:00