Commit Graph

17026 Commits

Author SHA1 Message Date
GDB Administrator
c6b8e53281 Automatic date update in version.in 2021-08-17 00:00:27 +00:00
GDB Administrator
70069e7823 Automatic date update in version.in 2021-08-16 00:00:28 +00:00
GDB Administrator
ec1e5afa89 Automatic date update in version.in 2021-08-15 00:00:44 +00:00
GDB Administrator
96ddc891f2 Automatic date update in version.in 2021-08-14 00:00:26 +00:00
Alan Modra
41ee6d14fd ns32k configury
Since ns32k-netbsd is as yet not removed, just marked obsolete,
the target should still be accepted with --enable-obsolete.

I also enabled ns32k-openbsd in ld since there doesn't seem to be a
good reason why that target is not supported there but is elsewhere.

bfd/
	* config.bfd: Allow ns32k-netbsd.
ld/
	* configure.tgt: Allow ns32k-openbsd.
2021-08-13 11:50:05 +09:30
GDB Administrator
c92d9b49ce Automatic date update in version.in 2021-08-13 00:00:31 +00:00
GDB Administrator
cf5671b146 Automatic date update in version.in 2021-08-12 00:00:34 +00:00
John Ericson
ab4f385b3c Deprecate a.out support for NetBSD targets.
As discussed previously, a.out support is now quite deprecated, and in
some cases removed, in both Binutils itself and NetBSD, so this legacy
default makes little sense. `netbsdelf*` and `netbsdaout*` still work
allowing the user to be explicit about there choice. Additionally, the
configure script warns about the change as Nick Clifton requested.

One possible concern was the status of NetBSD on NS32K, where only a.out
was supported. But per [1] NetBSD has removed support, and if it were to
come back, it would be with ELF. The binutils implementation is
therefore marked obsolete, per the instructions in the last message.

With that patch and this one applied, I have confirmed the following:

--target=i686-unknown-netbsd
--target=i686-unknown-netbsdelf
  builds completely

--target=i686-unknown-netbsdaout
  properly fails because target is deprecated.

--target=vax-unknown-netbsdaout builds completely except for gas, where
the target is deprecated.

[1]: https://mail-index.netbsd.org/tech-toolchain/2021/07/19/msg004025.html
---
 bfd/config.bfd                             | 43 +++++++++++++--------
 bfd/configure.ac                           |  5 +--
 binutils/testsuite/binutils-all/nm.exp     |  2 +-
 binutils/testsuite/lib/binutils-common.exp |  7 +---
 config/picflag.m4                          |  4 +-
 gas/configure.tgt                          |  9 +++--
 gas/testsuite/gas/arm/blx-bl-convert.d     |  2 +-
 gas/testsuite/gas/arm/blx-local-thumb.d    |  2 +-
 gas/testsuite/gas/sh/basic.exp             |  2 +-
 gdb/configure.host                         | 34 +++++++----------
 gdb/configure.tgt                          |  2 +-
 gdb/testsuite/gdb.asm/asm-source.exp       |  6 +--
 intl/configure                             |  2 +-
 ld/configure.tgt                           | 44 +++++++++++-----------
 ld/testsuite/ld-arm/arm-elf.exp            |  4 +-
 ld/testsuite/ld-elf/elf.exp                |  2 +-
 ld/testsuite/ld-elf/shared.exp             |  4 +-
 libiberty/configure                        |  4 +-
2021-08-11 13:17:54 +01:00
Alan Modra
2ad55ffca1 PR28163, Segment fault in function rl78_special_reloc
Relocation offset checks were completely missing in the rl78 backend,
allowing a relocation to write over memory anywhere.  This was true
for rl78_special_reloc, a function primarily used when applying debug
relocations, and in rl78_elf_relocate_section used by the linker.

This patch fixes those problems by correcting inaccuracies in the
relocation howtos, then uses those howtos to sanity check relocation
offsets before applying relocations.  In addition, the patch
implements overflow checking using the howto information rather than
the ad-hoc scheme implemented in relocate_section.  I implemented the
overflow checking in rl78_special_reloc too.

	* elf32-rl78.c (RL78REL, RL78_OP_REL): Add mask parameter.
	(rl78_elf_howto_table): Set destination masks.  Correct size and
	bitsize of DIR32_REV.  Correct complain_on_overflow for many relocs
	as per tests in relocate_section.  Add RH_SFR.  Correct bitsize
	for RH_SADDR.  Set size to 3 and bitsize to 0 for all OP relocs.
	(check_overflow): New function.
	(rl78_special_reloc): Check that reloc address is within section.
	Apply relocations using reloc howto.  Check for overflow.
	(RANGE): Delete.
	(rl78_elf_relocate_section): Sanity check r_offset.  Perform
	overflow checking using reloc howto.
2021-08-11 15:06:20 +09:30
GDB Administrator
c0e94211e1 Automatic date update in version.in 2021-08-11 00:00:27 +00:00
Nick Clifton
3ee0cd9e55 Updated Serbian and Russian translations for various sub-directories 2021-08-10 16:40:37 +01:00
GDB Administrator
d2a2c939f1 Automatic date update in version.in 2021-08-10 00:00:23 +00:00
GDB Administrator
b18bfc0946 Automatic date update in version.in 2021-08-09 00:00:35 +00:00
GDB Administrator
42ddfd0b7a Automatic date update in version.in 2021-08-08 00:00:29 +00:00
Alan Modra
182ad37589 PR28186, SEGV elf.c:7991:30 in _bfd_elf_fixup_group_sections
PR 28186
	* elf.c (_bfd_elf_fixup_group_sections): Don't segfault on
	objcopy/strip with NULL output_section.
2021-08-07 14:56:53 +09:30
Alan Modra
983cdaecc1 PR28176, rl78 complex reloc divide by zero
This is a bit more than just preventing the divide by zero.  Most of
the patch is tidying up error reporting, so that for example, linking
an object file with a reloc stack underflow produces a linker error
rather than just displaying a message that might be ignored.

	PR 28176
	* elf32-rl78.c (RL78_STACK_PUSH, RL78_STACK_POP): Delete.
	(rl78_stack_push, rl78_stack_pop): New inline functions.
	(rl78_compute_complex_reloc): Add status and error message params.
	Use new inline stack handling functions.  Report stack overflow
	or underflow, and divide by zero.
	(rl78_special_reloc): Return status and error message from
	rl78_compute_complex_reloc.
	(rl78_elf_relocate_section): Similarly.  Modernise reloc error
	reporting.  Delete unused bfd_reloc_other case.  Don't assume
	DIR24S_PCREL overflow is due to undefined function.
	(rl78_offset_for_reloc): Adjust to suit rl78_compute_complex_reloc.
2021-08-07 14:56:53 +09:30
GDB Administrator
0175375faa Automatic date update in version.in 2021-08-07 00:00:27 +00:00
Alan Modra
7eb7e4cdcc chew ubsan warning
It matters not at all if pc is incremented from its initial NULL
value, but avoid this silly runtime ubsan error.

	* doc/chew.c (perform): Avoid incrementing NULL pc.
2021-08-06 23:06:53 +09:30
Alan Modra
856c1545ce bfd_reloc_offset_in_range overflow
This patch is more about the style of bounds checking we ought to use,
rather than a real problem.  An overflow of "octet + reloc_size" can
only happen with huge sections which would certainly cause out of
memory errors.

	* reloc.c (bfd_reloc_offset_in_range): Avoid possible overflow.
2021-08-06 23:06:53 +09:30
Alan Modra
e039f7ed86 PR28175, Segment fault in coff-tic30.c reloc_processing
The obj_convert table shouldn't be accessed without first checking the
index against the table size.

	PR 28175
	* coff-tic30.c (reloc_processing): Sanity check reloc symbol index.
	* coff-z80.c (reloc_processing): Likewise.
	* coff-z8k.c (reloc_processing): Likewise.
2021-08-06 23:06:53 +09:30
Alan Modra
a379e7588c PR28173, nds32_elf_howto_table index out of bounds
Indexing the howto table was seriously broken by a missing entry, and
use of assertions about user input rather than testing the input.

	PR 28173
	* elf32-nds32.c (nds32_elf_howto_table): Add missing empty howto.
	(bfd_elf32_bfd_reloc_type_table_lookup): Replace assertions with
	range checks.  Return NULL if unsupported reloc type.  Remove
	dead code.  Take an unsigned int param.
	(nds32_info_to_howto_rel): Test for NULL howto or howto name
	return from lookup.  Remove assertion.
	(nds32_info_to_howto): Remove unnecessary ATTRIBUTE_UNUSED.
	Test for NULL howto or howto name return from lookup.
2021-08-06 23:06:40 +09:30
Alan Modra
352bd3aa1c PR28172, bfin_pcrel24_reloc heap-buffer-overflow
bfin pcrel24 relocs are weird, they apply to the reloc address minus
two.  That means reloc addresses of 0 and 1 are invalid.  Check that,
and fix other reloc range checking.

	PR 28172
	* elf32-bfin.c (bfin_pcrel24_reloc): Correct reloc range check.
	(bfin_imm16_reloc, bfin_byte4_reloc, bfin_bfd_reloc): Likewise.
	(bfin_final_link_relocate): Likewise.
2021-08-06 23:02:27 +09:30
GDB Administrator
8179e388b6 Automatic date update in version.in 2021-08-06 00:00:23 +00:00
Alan Modra
ddbe6976d5 PR28167, vms-alpha build_module_list
PR 28167
	* vms-alpha.c (build_module_list): Malloc and free section contents.
	Don't read past end of section.
2021-08-05 20:47:09 +09:30
Alan Modra
6ecfe4abfd PR28166, _bfd_elf_mips_get_relocated_section_contents
Some of the code paths unpacking mips relocs left arelent->sym_ptr_ptr
uninitialised.

	PR 28166
	* elf64-mips.c (mips_elf64_slurp_one_reloc_table): Don't leave
	sym_ptr_ptr uninitialised.
2021-08-05 20:47:09 +09:30
Alan Modra
4939c49d21 PR28165, buffer overflow in elf32-rx.c:rx_info_to_howto_rela
PR 28165
	* elf32-rx.c (rx_elf_howto_table): Add missing empty entries.
	(rx_info_to_howto_rela): Assert rx_elf_howto_table is correct size.
	Use actual size when sanity checking r_type.
2021-08-05 20:47:09 +09:30
GDB Administrator
12488b1767 Automatic date update in version.in 2021-08-05 00:00:29 +00:00
Alan Modra
0613c3306c PR28162, segment fault in mips_elf_assign_gp
For the testcase in the PR, _bfd_mips_elf32_gprel16_reloc is passed a
NULL output_bfd.  As expected for reloc special functions if called by
objdump or when final linking.  The function attempts to find the
output by
  output_bfd = symbol->section->output_section->owner;
That makes some sense, since when handling a gp-relative reloc we need
the relevant gp to which the symbol is relative.  Possibly the gp
value can be one for a shared library?  But that doesn't seem useful
or supported by the various abi docs and won't work as written.
Symbols defined in shared libraries have section->output_section
NULL, and what's more the code in mips_elf_assign_gp isn't set up to
look at shared library symbols.

Also, if the symbol is a SHN_ABS one the owner of *ABS* section is
NULL, which will result in the testcase segfault.  The only gp to
which an absolute symbol can be relative is the linker output bfd when
linking, or the input bfd when not.  This patch arranges to do that
for all gp-relative reloc symbols.

	* elf32-mips.c (_bfd_mips_elf32_gprel16_reloc): Don't use the
	section symbol to find the output bfd, use input_section.
	(mips_elf_gprel32_reloc, mips16_gprel_reloc): Likewise.
	* elf64-mips.c (mips_elf64_gprel16_reloc): Likewise.
	(mips_elf64_literal_reloc, mips_elf64_gprel32_reloc): Likewise.
	(mips16_gprel_reloc): Likewise.
2021-08-04 23:28:44 +09:30
H.J. Lu
f897689c88 elf: Treat undefined version as hidden
Since undefined version can't be used to resolve any references without
the original definition, treat it as hidden.

bfd/

	PR binutils/28158
	* elf.c (_bfd_elf_get_symbol_version_string): Treat undefined
	version as hidden.

ld/

	PR binutils/28158
	* testsuite/ld-elf/linux-x86.exp: Run PR binutils/28158 tests.
	* testsuite/ld-elf/pr28158-1.c: New file.
	* testsuite/ld-elf/pr28158-2.S: Likewise.
	* testsuite/ld-elf/pr28158.nd: Likewise.
	* testsuite/ld-elf/pr28158.rd: Likewise.
	* testsuite/ld-elf/pr28158.t: Likewise.
	* testsuite/ld-elfvers/vers2.dsym: Updated.
	* testsuite/ld-elfvers/vers3.dsym: Likewise.
	* testsuite/ld-elfvers/vers6.dsym: Likewise.
	* testsuite/ld-elfvers/vers19.dsym: Likewise.
	* testsuite/ld-elfvers/vers22.dsym: Likewise.
	* testsuite/ld-elfvers/vers23.dsym: Likewise.
	* testsuite/ld-elfvers/vers23d.dsym: Likewise.
	* testsuite/ld-elfvers/vers27d4.dsym: Likewise.
	* testsuite/ld-elfvers/vers28c.dsym: Likewise.
2021-08-04 05:07:42 -07:00
Alan Modra
29daccc9f3 revise PE IMAGE_SCN_LNK_NRELOC_OVFL test
* coffcode.h (coff_set_alignment_hook): Test that the resulting
	reloc count is not less than 0xffff.
2021-08-04 12:34:52 +09:30
GDB Administrator
814be17cf9 Automatic date update in version.in 2021-08-04 00:00:29 +00:00
GDB Administrator
cee6789e1b Automatic date update in version.in 2021-08-03 00:00:24 +00:00
GDB Administrator
7d315ef225 Automatic date update in version.in 2021-08-02 00:00:28 +00:00
GDB Administrator
426260d246 Automatic date update in version.in 2021-08-01 00:00:29 +00:00
GDB Administrator
7d0aa7cbd4 Automatic date update in version.in 2021-07-31 00:00:24 +00:00
Clément Chigot
8ba4f8f6c2 bfd: ensure that symbols targeted by DWARF relocations are kept in XCOFF
This patch improves XCOFF garbage collector pass, in order to keep
symbols being referenced only by special sections like DWARF sections.

bfd/
	* xcofflink.c (xcoff_mark): Replace SEC_MARK by gc_mark.
	Look through relocations even if xcoff_section_data is NULL.
	(xcoff_sweep): Check if any sections of a file is kept before
	adding its special sections.
	Call xcoff_mark for special sessions being kept instead of just
	marking them.
	(SEC_MARK): Remove
	(xcoff_mark_symbol): Replace SEC_MARK by gc_mark.
	(xcoff_keep_symbol_p): Likewise.
	(bfd_xcoff_size_dynamic_sections): Likewise.
	(xcoff_find_tc0): Likewise.
2021-07-30 08:38:14 +02:00
Clément Chigot
1417c84842 bfd: avoid a crash when debug_section isn't created in XCOFF
bfd/
	* xcofflink.c (bfd_xcoff_size_dynamic_sections):
	Add check to know if debug_section is initialized.
2021-07-30 08:37:15 +02:00
Alan Modra
5cfe19e51e reloc_upper_bound size calculations
Section reloc_count is an unsigned int.  Adding one for a NULL
terminator to an array of arelent pointers can wrap the count to
zero.  Avoid that by doing the addition as longs.

	* coffgen.c (coff_get_reloc_upper_bound): Don't overflow unsigned
	int expression.
	* elf.c (_bfd_elf_get_reloc_upper_bound): Likewise.
	* elf64-sparc.c (elf64_sparc_get_reloc_upper_bound): Likewise.
	* mach-o.c (bfd_mach_o_get_reloc_upper_bound): Likewise.
	* vms-alpha.c (alpha_vms_get_reloc_upper_bound): Likewise.
2021-07-30 15:08:55 +09:30
Alan Modra
472dd8b357 Sanity check _bfd_coff_read_string_table
* coffgen.c (_bfd_coff_read_string_table): Catch overflows
	when calculating string table file location.
2021-07-30 15:06:56 +09:30
Alan Modra
6329d1e13e IMAGE_SCN_LNK_NRELOC_OVFL
From microsoft docs: It is an error if IMAGE_SCN_LNK_NRELOC_OVFL is
set and there are fewer than 0xffff relocations in the section.

	* coffcode.h (coff_set_alignment_hook): Sanity check overflow
	reloc count.
2021-07-30 13:15:58 +09:30
GDB Administrator
bbf1c6a237 Automatic date update in version.in 2021-07-30 00:00:24 +00:00
Clément Chigot
cd026728f3 gas: improve C_BSTAT and C_STSYM symbols handling on XCOFF
A C_BSTAT debug symbol specifies the beginning of a static block.
Its n_value is the index of the csect containing static symbols.
A C_STSYM debug symbol represents the stabstring of a statically
allocated symbol. Its n_value is the offset in the csect pointed
by the containing C_BSTAT.

These two special n_value were not correctly handled both when
generating object files with gas or when reading them with objdump.
This patch tries to improve that and, above all, to allow gas-generated
object files with such symbols to be accepted by AIX ld.

bfd/
	* coff-bfd.c (bfd_coff_get_syment): Adjust n_value of symbols
	having fix_value = 1 in order to be an index and not a memory
	offset.
	* coffgen.c (coff_get_symbol_info): Likewize.
	(coff_print_symbol): Likewize.

gas/
	* config/tc-ppc.c (ppc_frob_label): Don't change within if
	already set.
	(ppc_stabx): Remove workaround changing exp.X_add_symbol's
	within.
	* config/tc-ppc.h (struct ppc_tc_sy): Update comments.
	* symbols.c (resolve_symbol_value): Remove symbol update
	when final_val is 0 and it's an AIX debug symbol.
	* testsuite/gas/ppc/aix.exp: Add new tests.
	* testsuite/gas/ppc/xcoff-stsym-32.d: New test.
	* testsuite/gas/ppc/xcoff-stsym-64.d: New test.
	* testsuite/gas/ppc/xcoff-stsym.s: New test.
2021-07-29 10:55:22 +02:00
GDB Administrator
588f5af532 Automatic date update in version.in 2021-07-29 00:00:23 +00:00
H.J. Lu
5a98fb7513 bfd: Close the file descriptor if there is no archive fd
Close the file descriptor if there is no archive plugin file descriptor
to avoid running out of file descriptors on thin archives with many
archive members.

bfd/

	PR ld/28138
	* plugin.c (bfd_plugin_close_file_descriptor): Close the file
	descriptor there is no archive plugin file descriptor.

ld/

	PR ld/28138
	* testsuite/ld-plugin/lto.exp: Run ld/28138 tests.
	* testsuite/ld-plugin/pr28138.c: New file.
	* testsuite/ld-plugin/pr28138-1.c: Likewise.
	* testsuite/ld-plugin/pr28138-2.c: Likewise.
	* testsuite/ld-plugin/pr28138-3.c: Likewise.
	* testsuite/ld-plugin/pr28138-4.c: Likewise.
	* testsuite/ld-plugin/pr28138-5.c: Likewise.
	* testsuite/ld-plugin/pr28138-6.c: Likewise.
	* testsuite/ld-plugin/pr28138-7.c: Likewise.
2021-07-28 06:01:32 -07:00
will schmidt
254db2f336 Externalize the _bfd_set_gp_value function
This change adds an external-visible wrapper for the _bfd_set_gp_value
function.  This is a prerequisite for some gdb patches that better
handle powerpc64le relocations against ".TOC.".

	* bfd.c (bfd_set_gp_value): New externally visible wrapper
	for _bfd_set_gp_value.
	* bfd-in2.h: Regenerate.
2021-07-28 13:36:58 +09:30
GDB Administrator
b30049f188 Automatic date update in version.in 2021-07-28 00:00:27 +00:00
GDB Administrator
7122377642 Automatic date update in version.in 2021-07-27 00:00:23 +00:00
H.J. Lu
5b37a5ca1d bfd: Set error to bfd_error_malformed_archive only if unset
When reading an archive member, set error to bfd_error_malformed_archive
on open_nested_file failure only if the error is unset.

	PR ld/28138
	* archive.c (_bfd_get_elt_at_filepos): Don't set error to
	bfd_error_malformed_archive if it has been set.
2021-07-26 16:21:47 -07:00
GDB Administrator
b924d9bad5 Automatic date update in version.in 2021-07-26 00:00:27 +00:00
GDB Administrator
60a5fb48d1 Automatic date update in version.in 2021-07-25 00:00:20 +00:00