Commit Graph

18677 Commits

Author SHA1 Message Date
GDB Administrator
5d69d9edc4 Automatic date update in version.in 2023-09-19 00:00:41 +00:00
GDB Administrator
8b8050d46d Automatic date update in version.in 2023-09-18 00:00:37 +00:00
GDB Administrator
518eb2b451 Automatic date update in version.in 2023-09-17 00:00:26 +00:00
GDB Administrator
cbabd45022 Automatic date update in version.in 2023-09-16 00:00:27 +00:00
Claudiu Zissulescu
0a43fbaa23 arc: Fix alignment of the TLS Translation Control Block
The R_ARC_TLS_LE_32 is defined as S + A + TLS_TBSS - TLS_REL, where

  -  S is the base address of the symbol in the memory
  -  A is the symbol addendum
  -  TLS_TBSS is the TLS Translation Control Block size (aligned)
  -  TLS_REL is the base of the TLS section

Given the next code snip:

__thread int data_var = 12;
__attribute__((__aligned__(128))) __thread int data_var_128 = 128;
__thread int bss_var;
__attribute__((__aligned__(256))) __thread int bss_var_256;

int __start(void)
{
	return data_var + data_var_128 + bss_var + bss_var_256;
}

The current code returns different TLS_TBSS values for .tdata and
.tbss. This patch fixes this by using the linker provided tls_sec.

bfd/

	* elf32-arc.c (TLS_REL): Clean up.
	(TLS_TBSS): Use tls_sec alignment.
	(arc_do_relocation): Check if we have valid tls_sec.

Signed-off-by: Claudiu Zissulescu <claziss@gmail.com>
2023-09-15 12:57:22 +03:00
GDB Administrator
95fc47d5c6 Automatic date update in version.in 2023-09-15 00:00:31 +00:00
GDB Administrator
5c83c7600e Automatic date update in version.in 2023-09-14 00:00:44 +00:00
Jacob Navia
38cc67cc00 Fix: "Missing NULL check"
* elf.c (_bfd_elf_init_reloc_shdr): Don't segfault on alloc fail.
2023-09-13 11:41:03 +01:00
Alan Modra
452855278a Fix: "Possible Memory leak in bed hash.c"
* elf-strtab.c (_bfd_elf_strtab_init): In the event of memory allocation failure, make sure that the hash table is freed.
2023-09-13 11:38:33 +01:00
GDB Administrator
bc92a20a84 Automatic date update in version.in 2023-09-13 00:00:32 +00:00
GDB Administrator
318d3bda5c Automatic date update in version.in 2023-09-12 00:00:27 +00:00
GDB Administrator
4bd620d10d Automatic date update in version.in 2023-09-11 00:00:24 +00:00
GDB Administrator
8a51670e8e Automatic date update in version.in 2023-09-10 00:00:27 +00:00
GDB Administrator
38a984fa44 Automatic date update in version.in 2023-09-09 00:00:28 +00:00
GDB Administrator
8cde0346f2 Automatic date update in version.in 2023-09-08 00:00:28 +00:00
Nelson Chu
6de11ff67a RISC-V: Clarify the naming rules of vendor operands.
The vendor operands should be named starting with `X', and preferably the
second letter (or multiple following letters) is enough to differentiate
them from other vendors.

Therefore, added letter `t' after `X' for t-head operands, to differentiate
from future different vendor's operands.

bfd/
	* elfxx-riscv.c (riscv_supported_vendor_x_ext): Removed the vendor
	document link since it should already be recorded in the
	gas/doc/c-riscv.texi.
gas/
	* config/tc-riscv.c (validate_riscv_insn): Added `t' after `X' for
	t-head operands.  Minor updates for indents and comments.
	(riscv_ip): Likewise.
	* doc/c-riscv.texi: Minor updates.
opcodes/
	* riscv-dis.c (print_insn_args): Added `t' after `X' for t-head
	operands.  Minor updates for indents and comments.
	* riscv-opc.c (riscv_opcode): Likewise.
2023-09-07 11:45:01 +08:00
GDB Administrator
33a0b29105 Automatic date update in version.in 2023-09-07 00:00:48 +00:00
GDB Administrator
84522284a5 Automatic date update in version.in 2023-09-06 00:00:50 +00:00
Tsukasa OI
404def8928 RISC-V: Add stub support for the 'Svadu' extension
This commit implements support for 'Svadu' extension.  Because it does not
add any instructions or CSRs (but adds bits to existing CSRs), this commit
only adds extension name support and implication to the 'Zicsr' extension.

This is based on the "Hardware Updating of PTE A/D Bits (Svadu)"
specification, version 1.0-rc1 (Frozen):
<https://github.com/riscv/riscv-svadu/releases/tag/v1.0-rc1>

bfd/ChangeLog:

	* elfxx-riscv.c (riscv_implicit_subsets): Add implication from
	'Svadu' to 'Zicsr'.  (riscv_supported_std_s_ext) Add 'Svadu'.
2023-09-05 04:57:09 +00:00
Tsukasa OI
a303646f17 RISC-V: Add 'Smcntrpmf' extension and its CSRs
This commit adds now stable and approved 'Smcntrpmf' extension defined by
the RISC-V Cycle and Instret Privilege Mode Filtering specification.

Note that, because mcyclecfg and minstretcfg CSRs conflict with the
privileged specification version 1.9.1, CSRs for this extension are only
enabled on the privileged specification version 1.10 or later.

By checking the base privileged specification, we no longer need to change
the design of base CSR handling.

This is based on the specification version v1.0_rc1 (Frozen):
<32b752c40d>

bfd/ChangeLog:

	* elfxx-riscv.c (riscv_implicit_subsets): Add implication rule from
	the new 'Smcntrpmf' extension.  (riscv_supported_std_s_ext): Add
	'Smcntrpmf' to the supported S extension list.

gas/ChangeLog:

	* config/tc-riscv.c (enum riscv_csr_class): Add new CSR classes
	CSR_CLASS_SMCNTRPMF and CSR_CLASS_SMCNTRPMF_32.
	(riscv_csr_address): Add handling for new CSR classes.
	* testsuite/gas/riscv/csr-dw-regnums.s: Add new CSRs.  Move
	"mscounteren" and "mhcounteren" CSRs and note that they are now
	aliases.
	* testsuite/gas/riscv/csr-dw-regnums.d: Reflect the change.
	* testsuite/gas/riscv/csr.s: Add new CSRs.  Move "mscounteren"
	and "mhcounteren" CSRs and note that they are now reused for
	the 'Smcntrpmf' extension.
	* testsuite/gas/riscv/csr-version-1p9p1.d: Reflect the changes of
	csr.s.
	* testsuite/gas/riscv/csr-version-1p9p1.l: Likewise.
	* testsuite/gas/riscv/csr-version-1p10.d: Likewise.
	* testsuite/gas/riscv/csr-version-1p10.l: Likewise.
	* testsuite/gas/riscv/csr-version-1p11.d: Likewise.
	* testsuite/gas/riscv/csr-version-1p11.l: Likewise.
	* testsuite/gas/riscv/csr-version-1p12.d: Likewise.
	* testsuite/gas/riscv/csr-version-1p12.l: Likewise.

include/ChangeLog:

	* opcode/riscv-opc.h: Add new CSRs noting that this extension is
	incompatible with the privileged specification version 1.9.1.
	Move "mscounteren" and "mhcounteren" CSRs, make them aliases and
	reuse the CSR numbers from the 'Smcntrpmf' extension.
	(CSR_MSCOUNTEREN, CSR_MHCOUNTEREN) Remove as "mscounteren" and
	"mhcounteren" are now aliases and new CSR macros are used instead.
	(CSR_MCYCLECFG, CSR_MINSTRETCFG, CSR_MCYCLECFGH, CSR_MINSTRETCFGH):
	New CSR macros.
2023-09-05 03:09:30 +00:00
Tsukasa OI
9294a13008 RISC-V: Prohibit combination of 'E' and 'H'
According to the ratified privileged specification (version 20211203),
it says:

> The hypervisor extension depends on an "I" base integer ISA with 32 x
> registers (RV32I or RV64I), not RV32E, which has only 16 x registers.

Also in the latest draft, it also prohibits RV64E with the 'H' extension.
This commit prohibits the combination of 'E' and 'H' extensions.

bfd/ChangeLog:

	* elfxx-riscv.c (riscv_parse_check_conflicts): Prohibit 'E' and
	'H' combinations.

gas/ChangeLog:

	* testsuite/gas/riscv/march-fail-rv32eh.d: New failure test to
	make sure that RV32E + 'H' is prohibited.
	* testsuite/gas/riscv/march-fail-rv32eh.l: Likewise.
2023-09-05 03:05:11 +00:00
GDB Administrator
292273af37 Automatic date update in version.in 2023-09-05 00:00:39 +00:00
Christophe Lyon
b3a1e48614 arm: Make 'conflicting CPU architectures' error message more user-friendly
Error messages such as "conflicting CPU architectures 10/16" are not
very to understand, so this patch replaces the numbers with the
description they actually mean:
"conflicting CPU architectures ARM v7E-M vs Pre v4"

2023-09-01  Christophe Lyon  <christophe.lyon@linaro.org>

	bfd/
	* elf32-arm.c (tag_cpu_arch_combine): Add name_table parameter and
	use it.
	(elf32_arm_merge_eabi_attributes): Update call to
	tag_cpu_arch_combine.

	ld/
	* testsuite/ld-arm/attr-merge-9.out: Update expected error
	message.
	* testsuite/ld-arm/attr-merge-arch-2.d: Likewise.
2023-09-04 12:34:30 +00:00
GDB Administrator
0f020d9ced Automatic date update in version.in 2023-09-04 00:00:24 +00:00
GDB Administrator
a496e1a71e Automatic date update in version.in 2023-09-03 00:00:22 +00:00
GDB Administrator
06ef187668 Automatic date update in version.in 2023-09-02 00:00:38 +00:00
GDB Administrator
9e2dda428d Automatic date update in version.in 2023-09-01 00:00:45 +00:00
Nicolas Boulenguez
eb5b52158f PR30806, CPPFLAGS are missing for bfd/chew, syslex_wrap and sysinfo
PR 30806
bfd/
	* doc/local.mk (doc/chew.stamp): Add CPPFLAGS_FOR_BUILD.
	* Makefile.in: Regenerate.
binutils/
	* Makefile.am (syslex_wrap.@OBJEXT@): Add CPPFLAGS_FOR_BUILD.
	(sysinfo.@OBJEXT@): Likewise.
	* Makefile.in: Regenerate.
2023-09-01 09:18:05 +09:30
Tom Tromey
3b23b03a86 Revert "Simplify @node use in BFD documentation"
This reverts commit 8bb23cdbb4.

My earlier patch to simplifify the @node uses in the BFD manual didn't
take into account (1) that BFD doesn't use the ordinary texinfo
sectioning commands, and (2) that some users are stuck on very ancient
versions of makeinfo.

This patch reverts the change.

I went through the entire manual using the spacebar, trying to find
the original problem I reported in the change, but couldn't.  I don't
know why.  Anyway, all this means is that, with this reversion,
editing the node structure will be slightly less convenient.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30703

2023-08-30  Tom Tromey  <tom@tromey.com>

	PR binutils/30703
	* doc/webassembly.texi, doc/bfd.texi: Revert 8bb23cdb, adding
	parameters back to @node.
2023-08-31 07:27:01 -06:00
Alan Modra
ad4ee59eb7 vms-alpha: Free memory on failure path
* vms-alpha.c (evax_bfd_print_eobj): Free rec on failure.
2023-08-31 21:35:39 +09:30
H.J. Lu
bac5753ca2 elf: Check DT_SYMTAB only on non-IR object
Check DT_SYMTAB only on non-IR object of archive member to avoid crash
on LLVM IR object with NULL elf_tdata.

	PR ld/30811
	* elflink.c (elf_link_is_defined_archive_symbol): Check
	DT_SYMTAB only on non-IR object.
2023-08-30 17:17:31 -07:00
GDB Administrator
48abc08d13 Automatic date update in version.in 2023-08-31 00:00:44 +00:00
Alan Modra
00aea11f40 libbfd.texi zero size
Pattern rules in doc/local.mk exist that specify how to make
libbfd.texi from libfd.h or libbfd.c.  Since both files exist and the
libbfd.h rule is first, libbfd.h is used.  libbfd.h doesn't contain
the documentation..

	* doc/local.mk (doc/%stamp): Put rule making this from %.c
	before %.h rule.
	* Makefile.in: Regenerate.
	* libbfd.c (Byte swapping routines): Don't omit description.
2023-08-31 08:57:31 +09:30
Alan Modra
d7d4e91155 DEFAULT_BUFFERSIZE
There isn't any reason to think that a particular buffer size is
ideal in bfd, so let's just not define it.

	* libbfd-in.h (DEFAULT_BUFFERSIZE): Don't define.
	* libbfd.h: Regenerate.
	* archive.c (AR_WRITE_BUFFERSIZE): Substitute value.
	* vms-lib.c (_bfd_vms_lib_write_archive_contents): Likewise.
	* coff-rs6000.c (do_copy): Likewise, and use sizeof.
2023-08-31 07:48:16 +09:30
Maciej W. Rozycki
c1a5464809 Revert "MIPS: Use 64-bit a ABI by default for `mipsisa64*-*-linux*' targets"
This reverts commit 025e84f935.  It was
applied unapproved.
2023-08-30 18:45:14 +01:00
GDB Administrator
0637da3c73 Automatic date update in version.in 2023-08-30 00:00:41 +00:00
GDB Administrator
c58d51c612 Automatic date update in version.in 2023-08-29 00:00:37 +00:00
Alan Modra
daafebb58d COFF swap_aux_in
A low level function like coff_swap_aux_in really has no business
concatenating multiple auxents for the old PE multi-aux scheme of
handling long file names.  In doing so, it assumes multiple internal
auxent buffers are available, which they are not in most calls to
bfd_coff_swap_aux_in, both inside BFD and outside, eg. GDB.  Buffer
overflow fun.  Concatenating multiple auxents belongs at a higher
level.

This required some changes to coff_get_normalized_symtab, which now
uses the external auxents to access the concatenated file name.
(Internal auxents are larger than the x_fname array, so the pieces of
the file name are not adjacent as they are in the external auxents.)

	* coffswap.h (coff_swap_aux_in): Do not write more than one
	internal auxent.
	* coffcode.h (coff_bigobj_swap_aux_in): Likewise.
	* coffgen.c (coff_get_normalized_symtab): Normalize strings
	after swapping in each symbol so that external auxents are
	available.  Use external auxents for multi-aux long file
	names.  Formatting.  Wrap long lines.  Remove excess parens
	and unnecessary casts.  Don't zalloc when only the string
	terminator needs zeroing, and memcpy rather than strncpy.
	Delete unnecessary sanity check with unsigned _n_offset.
	Return with failure if debug section can't be read, to avoid
	trying to read it multiple times.  Correct sanity check
	against debug section size.
2023-08-28 23:10:57 +09:30
Alan Modra
54d57acf61 Re: comdat_hash memory leaks
I missed another field that needs freeing.  Also, oss-fuzz found a
case with a C_FILE sym using multiple auxents for a long file name
which overflowed the single auxent buffer.  I'm going to fix that
problem in swap_aux_in too, but we may as well avoid it here too,
saving unnecessary work.

	* coffcode.h (comdat_delf): Free comdat_name.
	(fill_comdat_hash): Only look at symbols with one auxent.
2023-08-28 22:05:29 +09:30
YunQiang Su
025e84f935 MIPS: Use 64-bit a ABI by default for `mipsisa64*-*-linux*' targets
Following the arrangement in GCC select a 64-bit ABI by default, either
n32 or n64, rather than o32 for `mipsisa64*-*-linux*' targets, just as
with the corresponding `mips64*-*-linux*' targets.
2023-08-27 23:43:30 -04:00
GDB Administrator
8b075babf5 Automatic date update in version.in 2023-08-28 00:00:32 +00:00
Alan Modra
6785fd72d5 PE dos_message
I was looking at dos_message and wondering why we have H_PUT_32
in _bfd_XXi_only_swap_filehdr_out but no H_GET_32 in pe_bfd_object_p.
On a big-endian machine this would result in scrambling the code and
strings constained in dos_message.  Rather than fix the lack of
H_GET_32 in pe_bfd_object_p, I decided it doesn't make sense to store
dos_message internally as an array of ints.

include/
	* coff/internal.h (struct internal_extra_pe_filehdr): Make
	dos_message a char array.
	* coff/msdos.h (struct external_DOS_hdr): Flatten dos_message.
	* coff/pe.h (struct external_PEI_filehdr): Likewise.
bfd/
	* libcoff-in.h (struct pe_tdata): Make dos_message a char array.
	* libcoff.h: Regenerate.
	* peXXigen.c (_bfd_XXi_only_swap_filehdr_out): memcpy dos_message
	to output.
	* peicode.h (pe_mkobject): Don't memset already zeroed pe_opthdr.
	Tidy allocation of tdata.pe_obj_data.  Set up dos_message from..
	(default_dos_message): ..this.  New static array.
2023-08-27 21:21:38 +09:30
Alan Modra
8606b47e94 comdat_hash memory leaks
Entries added to the hash table with bfd_malloc ought to be freed when
the hash table is deleted.  This patch adds the necessary del_f to the
htab_create call, and delays creating the table until an
IMAGE_SCN_LNK_COMDAT symbol is read.

	* peicode.h (pe_mkobject): Move comdat_hash creation..
	(htab_hash_flags, htab_eq_flags): ..and these support functions..
	* coffcode.h (handle_COMDAT): ..to here, renaming support to
	(comdat_hashf, comdat_eqf): ..this and adding..
	(comdat_delf): ..this new function.
2023-08-27 13:57:42 +09:30
Alan Modra
26d0081b52 Confusion in coff_object_cleanup
A bfd_cleanup function needs to run when only tdata is correct for the
bfd.  The xvec may have changed during bfd_check_format and thus the
flavour may be incorrect.  The format won't have changed but checking
is superfluous.  (In contrast to _bfd_free_cached_info or
_close_and_cleanup where we do need to check things.)

Not getting this correct leaked comdat_hash.

Also, pe_ILF_cleanup ought to call coff_object_cleanup as do all PE
files.

	* coffgen.c (coff_object_cleanup): Don't check bfd flavour or
	format.
	* peicode.h (pe_ILF_cleanup): Call coff_object_cleanup.
2023-08-27 13:57:42 +09:30
Alan Modra
398f1ddf5e sanity check n_numaux
Sanity check aux entries used by PE to extend a C_FILE name.  See
coffswap.h:coff_swap_aux_in.  The existing check only catered for
n_numaux == 1.

	* coffcode.h (fill_comdat_hash): Properly sanity check n_numaux.
	Formatting.
	(handle_COMDAT): Formatting.
2023-08-27 13:57:41 +09:30
GDB Administrator
c6b80f2a92 Automatic date update in version.in 2023-08-27 00:00:24 +00:00
GDB Administrator
7b1fdf17d5 Automatic date update in version.in 2023-08-26 00:00:37 +00:00
Jan Beulich
67694446f7 bfd: correct relocation handling for objcopy COFF -> ELF
While documented to not be reliable, it is still odd for objcopy to
silently produce bad output when converting COFF/PE object files to ELF
ones. The issue there is that relocation addends all are screwed up by
subtracting the symbol's section offset. In the COFF/PE world, to my
knowledge, section contents stores the addends alone, not the result of
symbol value plus addend. Hence the compensation talked about in a
comment ahead of the sole use site of CALC_ADDEND() may need to account
for the VMA (which is always zero for object files anyway), but not for
the symbol value.

The coff-sh.c adjustment is based upon guessing that behavior there is
the same. Note also how coff-aarch64.c short-circuits CALC_ADDEND()
altogether, which may suggest that a much simpler macro might do for the
COFF_WITH_PE case in the three arch-specific files touched here.

For (at least) Arm/WinCE this actually results in more appropriate
objdump output as well, as can be seen in the one testcase which has its
expectations adjusted (the generated binary doesn't change).
2023-08-25 14:56:44 +02:00
Alan Modra
b73ffa23bf som: buffer overflow writing strings
Code in som_write_symbol_strings neglected to allow for padding, which
can result in a buffer overflow.  It also used xrealloc, which we're
not supposed to use in libbfd because libbfd isn't supposed to call
exit.  Also a realloc is perhaps not a good idea when none of the
buffer contents are needed, so replace with free, bfd_malloc.  There
were three copies of the string handling code, so rather than fix them
all I've extracted them to a function.  This necessitated making one
of the fields in struct som_symbol unsigned.

	* som.c (add_string): New function.
	(som_write_space_strings, som_write_symbol_strings): Use it.
	* som.h (som_symbol_type <stringtab_offset>): Make unsigned.
2023-08-25 15:55:25 +09:30
GDB Administrator
cbbeee21a2 Automatic date update in version.in 2023-08-25 00:00:22 +00:00