Commit Graph

4669 Commits

Author SHA1 Message Date
Nick Clifton
0251080cb8 Add note to check that all changes have been pushed before creating the source tarballs 2023-08-01 10:41:58 +01:00
Jose E. Marchesi
1e18ffc991 bpf: include, bfd, opcodes: add EF_BPF_CPUVER ELF header flags
This patch adds support for EF_BPF_CPUVER bits in the ELF
machine-dependent header flags.  These bits encode the BPF CPU
version for which the object file has been compiled for.

The BPF assembler is updated so it annotates the object files it
generates with these bits.

The BPF disassembler is updated so it honors EF_BPF_CPUVER to use the
appropriate ISA version if the user didn't specify an explicit ISA
version in the command line.  Note that a value of zero in
EF_BPF_CPUVER is interpreted by the disassembler as "use the later
supported version" (the BPF CPU versions start with v1.)

The readelf utility is updated to pretty print EF_BPF_CPUVER when it
prints out the ELF header:

   $ readelf -h a.out
   ELF Header:
     ...
     Flags:                             0x4, CPU Version: 4

Tested in bpf-unknown-none.

include/ChangeLog:

2023-07-30  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* elf/bpf.h (EF_BPF_CPUVER): Define.
	* opcode/bpf.h (BPF_XBPF): Change from 0xf to 0xff so it fits in
	EF_BPF_CPUVER.

binutils/ChangeLog:

2023-07-30  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* readelf.c (get_machine_flags): Recognize and pretty print BPF
	machine flags.

opcodes/ChangeLog:

2023-07-30  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* bpf-dis.c: Initialize asm_bpf_version to -1.
	(print_insn_bpf): Set BPF ISA version from the cpu version ELF
	header flags if no explicit version set in the command line.
	* disassemble.c (disassemble_init_for_target): Remove unused code.

gas/ChangeLog:

2023-07-30  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* config/tc-bpf.h (elf_tc_final_processing): Define.
	* config/tc-bpf.c (bpf_elf_final_processing): New function.
2023-07-30 22:39:30 +02:00
Nick Clifton
82be476a08 Update how to make a release document after the 2.41 release 2023-07-30 16:07:09 +01:00
YunQiang Su
29c108c961 MIPS: Support `-gnuabi64' target triplet suffix for 64-bit Linux targets
Make the n64 ABI the default for 64-bit Linux targets specified with
`-gnuabi64' suffix included in the target triplet, for configurations
such as the Debian mips64el and mips64r6el ports.  Adjust testsuite
configuration accordingly.

There are the following regressions with the new target triplet:

mips64-linux-gnuabi64  +FAIL: readelf -S bintest
mips64-linux-gnuabi64  +FAIL: MIPS reloc estimation 1
mips64el-linux-gnuabi64  +FAIL: readelf -S bintest
mips64el-linux-gnuabi64  +FAIL: MIPS reloc estimation 1

The `readelf' issue comes from a difference in section headers produced
that the `binutils/testsuite/binutils-all/readelf.s-64' pattern template
does not match.  While there has been a precedent it does not appear to
me that there is a clear advantage from adding more and more variations
to the template rather than forking the existing template into multiple
ones for a more exact match.  So this is best deferred to a separate
discussion.

The MIPS reloc estimation issue is an actual bug in `objdump', which
discards a number of trailing entries from output here for n64 composed
relocations:

DYNAMIC RELOCATION RECORDS
OFFSET           TYPE              VALUE
0000000000000000 R_MIPS_NONE       *ABS*
0000000000000000 R_MIPS_NONE       *ABS*

and consequently `ld/testsuite/ld-mips-elf/reloc-estimate-1.d' does not
match even though ELF output produced is correct according to `readelf':

Relocation section '.rel.dyn' at offset 0x10400 contains 2 entries:
  Offset          Info           Type           Sym. Value    Sym. Name
000000000000  000000000000 R_MIPS_NONE
                    Type2: R_MIPS_NONE
                    Type3: R_MIPS_NONE
000000010000  000300001203 R_MIPS_REL32      0000000000010010 foo@@V2
                    Type2: R_MIPS_64
                    Type3: R_MIPS_NONE

As a genuine bug this has to be handled separately.

Co-Authored by: Maciej W. Rozycki <macro@orcam.me.uk>

	bfd/
	* config.bfd: Add `mips64*el-*-linux*-gnuabi64' and
	`mips64*-*-linux*-gnuabi64' targets.

	binutils/
	* testsuite/binutils-all/mips/mips.exp: Handle `*-*-*-gnuabi64'
	targets.
	* testsuite/binutils-all/objcopy.exp: Handle
	`mips64*-*-*-gnuabi64' targets.
	* testsuite/binutils-all/remove-relocs-01.d: Likewise.
	* testsuite/binutils-all/remove-relocs-04.d: Likewise.
	* testsuite/binutils-all/remove-relocs-05.d: Likewise.
	* testsuite/binutils-all/remove-relocs-06.d: Likewise.

	gas/
	* configure.ac: Handle `mips64*-linux-gnuabi64' targets.
	* configure: Regenerate.
	* testsuite/gas/mips/compact-eh-eb-7.d: Handle
	`mips64*-*-*-gnuabi64' targets.
	* testsuite/gas/mips/compact-eh-el-7.d: Likewise.

	ld/
	* configure.tgt: Add `mips64*el-*-linux-gnuabi64' and
	`mips64*-*-linux-gnuabi64' targets.
	* testsuite/ld-undefined/undefined.exp: Handle
	`mips64*-*-*-gnuabi64' targets.
	* testsuite/ld-mips-elf/attr-gnu-4-10.d: Likewise.
	* testsuite/ld-mips-elf/compact-eh6.d: Likewise.
	* testsuite/ld-mips-elf/mips-elf.exp: Handle `*-*-*-gnuabi64'
	targets.
2023-07-28 06:00:37 +01:00
YunQiang Su
ed4dca900c testsuite: Handle composed R_MIPS_NONE relocations
MIPS n64 ABI has a peculiarity where all relocations are composed of
three, with subsequent relocation types set to R_MIPS_NONE if further
calculation is not required.  Example output produced by `readelf' and
`objdump' for such relocations is:

  Offset          Info           Type           Sym. Value    Sym. Name + Addend
000000000000  000800000002 R_MIPS_32         0000000000000000 foo + 0
                    Type2: R_MIPS_NONE
                    Type3: R_MIPS_NONE

and:

OFFSET           TYPE              VALUE
0000000000000000 R_MIPS_32         foo
0000000000000000 R_MIPS_NONE       *ABS*
0000000000000000 R_MIPS_NONE       *ABS*

respectively.  The presence of these extra R_MIPS_NONE entries is not
relevant for generic or even some MIPS tests, so optionally match them
with the respective dump patterns, also discarding `xfail' annotation
for MIPS/OpenBSD targets from gas/elf/missing-build-notes.d, removing
these regressions:

mips64-openbsd  -FAIL: readelf -r bintest
mips64-openbsd  -FAIL: forward expression
mips64-openbsd  -FAIL: assignment tests
mips64-openbsd  -FAIL: gas/all/none
mips64-openbsd  -XFAIL: gas/elf/missing-build-notes
mips64-openbsd  -FAIL: macro test 2
mips64-openbsd  -FAIL: macro irp
mips64-openbsd  -FAIL: macro rept
mips64-openbsd  -FAIL: nested irp/irpc/rept
mips64-openbsd  -FAIL: macro vararg
mips64-openbsd  -FAIL: mips jalx
mips64-openbsd  -FAIL: ST Microelectronics Loongson-2F workarounds of Jump Instruction issue
mips64el-openbsd  -FAIL: readelf -r bintest
mips64el-openbsd  -FAIL: forward expression
mips64el-openbsd  -FAIL: assignment tests
mips64el-openbsd  -FAIL: gas/all/none
mips64el-openbsd  -XFAIL: gas/elf/missing-build-notes
mips64el-openbsd  -FAIL: macro test 2
mips64el-openbsd  -FAIL: macro irp
mips64el-openbsd  -FAIL: macro rept
mips64el-openbsd  -FAIL: nested irp/irpc/rept
mips64el-openbsd  -FAIL: macro vararg
mips64el-openbsd  -FAIL: mips jalx
mips64el-openbsd  -FAIL: ST Microelectronics Loongson-2F workarounds of Jump Instruction issue

Co-Authored-By: Maciej W. Rozycki <macro@orcam.me.uk>

	binutils/
	* testsuite/binutils-all/readelf.r-64: Optionally match extra
	R_MIPS_NONE pairs.

	gas/
	* testsuite/gas/all/assign.d: Optionally match extra
	R_MIPS_NONE pairs.
	* testsuite/gas/all/fwdexp.d: Likewise.
	* testsuite/gas/all/none.d: Likewise.
	* testsuite/gas/macros/irp.d: Likewise.
	* testsuite/gas/macros/repeat.d: Likewise.
	* testsuite/gas/macros/rept.d: Likewise.
	* testsuite/gas/macros/test2.d: Likewise.
	* testsuite/gas/macros/vararg.d: Likewise.
	* testsuite/gas/mips/compact-eh-eb-1.d: Likewise.
	* testsuite/gas/mips/compact-eh-eb-2.d: Likewise.
	* testsuite/gas/mips/compact-eh-eb-3.d: Likewise.
	* testsuite/gas/mips/compact-eh-eb-4.d: Likewise.
	* testsuite/gas/mips/compact-eh-eb-5.d: Likewise.
	* testsuite/gas/mips/compact-eh-eb-6.d: Likewise.
	* testsuite/gas/mips/compact-eh-el-1.d: Likewise.
	* testsuite/gas/mips/compact-eh-el-2.d: Likewise.
	* testsuite/gas/mips/compact-eh-el-3.d: Likewise.
	* testsuite/gas/mips/compact-eh-el-4.d: Likewise.
	* testsuite/gas/mips/compact-eh-el-5.d: Likewise.
	* testsuite/gas/mips/compact-eh-el-6.d: Likewise.
	* testsuite/gas/mips/loongson-2f-3.d: Likewise.
	* testsuite/gas/mips/mips-jalx.d: Likewise.
	* testsuite/gas/elf/missing-build-notes.d: Likewise.  Remove
	the `xfail' tag.

	ld/
	* testsuite/ld-mips-elf/reloc-estimate-1.d: Optionally match
	extra R_MIPS_NONE pairs.
2023-07-28 06:00:36 +01:00
YunQiang Su
60ec8306db testsuite: Also discard the `.MIPS.options' section
Also discard the `.MIPS.options' section, used with n64 MIPS binaries,
along with similar other MIPS sections (`.reginfo', `.MIPS.abiflags')
not relevant for the test cases concerned, fixing these regressions:

mips64-openbsd  -FAIL: ld-elf/group3a
mips64-openbsd  -FAIL: ld-elf/group3b
mips64-openbsd  -FAIL: Place orphan sections (map file check)
mips64-openbsd  -FAIL: ld-elf/orphan-region
mips64-openbsd  -FAIL: ld-elf/orphan
mips64-openbsd  -FAIL: overlay size (map file check)
mips64-openbsd  -FAIL: overlay size
mips64el-openbsd  -FAIL: ld-elf/group3a
mips64el-openbsd  -FAIL: ld-elf/group3b
mips64el-openbsd  -FAIL: Place orphan sections (map file check)
mips64el-openbsd  -FAIL: ld-elf/orphan-region
mips64el-openbsd  -FAIL: ld-elf/orphan
mips64el-openbsd  -FAIL: overlay size (map file check)
mips64el-openbsd  -FAIL: overlay size

Co-Authored-By: Maciej W. Rozycki <macro@orcam.me.uk>

	binutils/
	* testsuite/binutils-all/strip-3.d: Add `-R .MIPS.options' to
	the `strip' tag.

	ld/
	* testsuite/ld-elf/group.ld: Also discard `.MIPS.options'.
	* testsuite/ld-elf/orphan-region.ld: Likewise.
	* testsuite/ld-elf/orphan.ld: Likewise.
	* testsuite/ld-mips-elf/got-page-1.ld: Likewise.
	* testsuite/ld-scripts/overlay-size.t: Likewise.
2023-07-28 06:00:36 +01:00
Maciej W. Rozycki
cc66ad2d2a Revert "MIPS: support mips*64 as CPU and gnuabi64 as ABI"
This reverts commit 32f1c80375.  It had
two unrelated changes lumped together, one of which changed the meaning
of the `mipsisa64*-*-linux*' target triplets, which was not properly
evaluated.
2023-07-28 06:00:36 +01:00
Alan Modra
41c8b9f097 coff/pe/xcoff and --extract-symbols
This fixes failure of the "extract symbols" test for rs6000, where
--extract-symbols generates a non-zero sized .text.  By the look of
coffcode.h the same problem might occur for coff/pe too, but doesn't
happen to trigger a test failure.

bfd/
	* coffcode.h (coff_compute_section_file_positions): Don't
	adjust size of !SEC_LOAD sections.
binutils/
	* objcopy.c (setup_section): Clear SEC_LOAD for --extract-symbol.
2023-07-28 14:11:27 +09:30
Johannes Schauer Marin Rodrigues
6badd1020f objcopy embeds the current time and ignores SOURCE_DATE_EPOCH making the output unreproducible.
bfd
  * peXXigen.c (_bfd_XXi_only_swap_filehdr_out): If inserting a timestamp, use the value held in the SOURCE_DATE_EPOCH environment variable, if it is defined.
binutils
  * doc/binutils.texi (objcopy): Document change in behaviour of objcopy's --preserve-dates command line option.
ld
  * pe-dll.c (fill_edata): If inserting a timestamp, use the value held in the SOURCE_DATE_EPOCH environment variable, if it is defined.
  * ld.texi (--insert-timestamp): Document change in behaviour.
2023-07-24 16:59:19 +01:00
Alan Modra
b7bf7f1b8f Tidy binutils configure
Separate out some of the defines from the block handling windows
support, so they don't get lost.  Delete an unused variable.
2023-07-19 11:06:22 +09:30
Alan Modra
eb84343a1d Build all the objdump extensions with --enable-targets=all
Only the xcoff and pe extensions were enabled.  Build the lot, and fix
some more printf format problems when the host is 32-bit.

	* configure.ac (od_vectors): Set up for --enable-targets=all.
	* configure: Regenerate.
	* od-elf32_avr.c (elf32_avr_dump_mem_usage): Correct format
	specifier vs. arg mismatch.
	(elf32_avr_dump_avr_prop): Likewise.
2023-07-19 10:46:59 +09:30
Nick Clifton
fdc60e8cf6 Updated Swedish translation for the binutils subdirectory 2023-07-18 17:12:25 +01:00
Alan Modra
6d872a1a80 More tidies to objcopy archive handling
This makes sure copy_archive exits with ibfd and obfd closed.  Error
paths didn't do that, leading to memory leaks.  None of this matters
very much.

	* objcopy.c (copy_archive): bfd_close ibfd and obfd on error
	return paths.  Remove braces around "list" free.
	(copy_file): Don't close invalid file descriptor.
2023-07-14 11:53:48 +09:30
Alan Modra
1052fb3ecb Re: Keeping track of rs6000-coff archive element pointers
bfd/
	* coff-rs6000.c (add_range): Revise comment, noting possible fail.
	(_bfd_xcoff_openr_next_archived_file): Start with clean ranges.
binutils/
	* bfdtest1.c: Enhance to catch errors on second scan.
2023-07-12 09:31:40 +09:30
Fangrui Song
5e24da908d PR30592 objcopy: allow --set-section-flags to add or remove SHF_X86_64_LARGE
For example, objcopy --set-section-flags .data=alloc,large will add
SHF_X86_64_LARGE to the .data section.  Omitting "large" will drop the
SHF_X86_64_LARGE flag.

The bfd_section flag is named generically, SEC_ELF_LARGE, in case other
processors want to follow SHF_X86_64_LARGE.  SEC_ELF_LARGE has the same
value as SEC_TIC54X_BLOCK used by coff.

bfd/
    * section.c: Define SEC_ELF_LARGE.
    * bfd-in2.h: Regenerate.
    * elf64-x86-64.c (elf_x86_64_section_flags, elf_x86_64_fake_sections,
    elf_x86_64_copy_private_section_data): New.

binutils/
    * NEWS: Mention the new feature for objcopy.
    * doc/binutils.texi: Mention "large".
    * objcopy.c (parse_flags): Parse "large".
    (check_new_section_flags): Error if "large" is used with a
    non-x86-64 ELF target.
    * testsuite/binutils-all/x86-64/large-sections.d: New.
    * testsuite/binutils-all/x86-64/large-sections.s: New.
    * testsuite/binutils-all/x86-64/large-sections-i386.d: New.
    * testsuite/binutils-all/x86-64/large-sections-2.d: New.
    * testsuite/binutils-all/x86-64/large-sections-2-x32.d: New.
2023-07-09 10:57:19 -07:00
Claudiu Zissulescu
13aa307c9a arc: Update/Add ARCv3 support.
The ARC HS5x and ARC HS6x processors are based on the new ARCv3 ISA
that implements a full range of 32-bit and 64-bit instructions.  These
processors feature a high-speed 10-stage, dual-issue pipeline that
offers increased utilization of functional units with a limited
increase in power and area.  The HS5x processors feature a 32-bit
pipeline that can execute all ARCv3 32-bit instructions, while the
HS6x processors feature a full 64-bit pipeline and register file that
can execute both 32-bit and 64-bit instructions.  In addition, the ARC
HS6x supports 64-bit virtual and 52-bit physical address spaces to
enable direct addressing of current and future large memories, as well
as 128-bit loads and stores for efficient data movement.

This readelf patch updates/adds Synopsys ARCv3 machine name fileds and
supported relocations.

Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com>
2023-07-07 13:08:04 +03:00
Nick Clifton
3baacfd61d Udated Freach and Romainian translations for various sub-directories 2023-07-07 09:40:20 +01:00
Nick Clifton
dd78c0a824 Minor updates to release readme 2023-07-07 09:39:16 +01:00
Nick Clifton
a34339a82f Updated Ukranian, Romanian and German translations for various sub-directories 2023-07-04 11:55:27 +01:00
Nick Clifton
0d368ae540 Update after creating 2.41 branch 2023-07-03 13:41:02 +01:00
Nick Clifton
87485f5349 Change version number to 2.41.50 and regenerate files 2023-07-03 11:54:06 +01:00
Nick Clifton
d501d38488 Add markers for the 2.41 branch 2023-07-03 11:12:15 +01:00
WANG Xuerui
0ed3ac2f4a binutils: NEWS: Announce LoongArch changes in the 2.41 cycle
binutils/ChangeLog:

	* NEWS: Mention LoongArch changes for 2.41.

Signed-off-by: WANG Xuerui <git@xen0n.name>
2023-07-03 09:00:48 +08:00
Christoph Müllner
9fdc1b157b binutils: NEWS: Announce new RISC-V vector crypto extensions
This commit adds the recently added support of the RISC-V vector crypto
extensions to the NEWS file.

binutils/ChangeLog:

	* NEWS: Announce new RISC-V vector crypto extensions.

Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
2023-07-01 07:32:20 -06:00
Philipp Tomsich
e507570754 binutils: NEWS: announce new RISC-V extensions
We picked up support for a few new extensions over the last weeks
(this may need further updating prior to the next release), list them
in the NEWS file.

binutils/ChangeLog:

	* binutils/NEWS: announce suuport for the new RISC-V
          extensions (Zicond, Zfa, XVentanaCondOps).

Signed-off-by: Philipp Tomsich <philipp.tomsich@vrull.eu>
2023-06-30 16:02:17 +02:00
Nick Clifton
3713e829be strings: Improve code to detect excessively large minimum string lengths.
PR 30598
  * strings.c (set_string_min): New function. (main): Use it. (print_unicode_stream): Calculate buffer size using a size_t.
2023-06-30 13:54:03 +01:00
Nick Clifton
0d1cd7d978 Prevent an illegal memory access when running the strings program with an excessively lerge minimum string length.
PR 30595
  * strings.c (main): Check for an excessively large minimum string length.
2023-06-30 11:18:42 +01:00
Indu Bhagat
a47cd2a1cd binutils/NEWS: announce SFrame version 2 as the new default 2023-06-29 16:32:26 -07:00
H.J. Lu
1ad1b8865c binutils: Add a --strip-section-headers test
PR ld/25617
	* testsuite/binutils-all/objcopy.exp: Run strip-section-headers-1.
	* testsuite/binutils-all/strip-section-headers-1.d: New file.
2023-06-29 10:29:47 -07:00
H.J. Lu
02c1ba6c94 ELF: Discard non-alloc sections without section header
Discard non-alloc sections when section headers are stripped.

bfd/

	PR ld/25617
	* elf.c (_bfd_elf_assign_file_positions_for_non_load): Skip
	non-load sections without section header.
	(_bfd_elf_write_object_contents): Don't set the sh_name field
	without section header.  Write out the .shstrtab section only
	if its sh_offset field isn't -1.

binutils/

	PR ld/25617
	* objcopy.c (is_strip_section_1): Remove non-alloc sections for
	--strip-section-headers.

ld/

	PR ld/25617
	* ldlang.c (lang_discard_section_p): Discard non-alloc sections
	if we are stripping section headers.
2023-06-29 10:29:47 -07:00
Kaylee Blake
96cc7918c1 ELF: Strip section header in ELF objects
Section header isn't mandatory on ELF executable nor shared library.
This patch adds a new linker option, -z nosectionheader, to omit ELF
section header, a new objcopy and strip option, --strip-section-headers,
to remove ELF section headers.

bfd/

2023-06-06  H.J. Lu  <hongjiu.lu@intel.com>
	    Kaylee Blake  <klkblake@gmail.com>

	PR ld/25617
	* bfd.c (BFD_NO_SECTION_HEADER): New.
	(BFD_FLAGS_SAVED): Add BFD_NO_SECTION_HEADER.
	(BFD_FLAGS_FOR_BFD_USE_MASK): Likewise.
	* elfcode.h (elf_swap_ehdr_out): Omit section header with
	BFD_NO_SECTION_HEADER.
	(elf_write_shdrs_and_ehdr): Likewise.
	* elfxx-target.h (TARGET_BIG_SYM): Add BFD_NO_SECTION_HEADER
	to object_flags.
	(TARGET_LITTLE_SYM): Likewise.
	* bfd-in2.h: Regenerated.

binutils/

2023-06-06  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/25617
	* NEWS: Mention --strip-section-headers for objcopy and strip.
	* objcopy.c (strip_section_headers): New.
	(command_line_switch): Add OPTION_STRIP_SECTION_HEADERS.
	(strip_options): Add --strip-section-headers.
	(copy_options): Likewise.
	(copy_usage): Add --strip-section-headers.
	(strip_usage): Likewise.
	(copy_object): Handle --strip-section-headers for ELF files.
	(strip_main): Handle OPTION_STRIP_SECTION_HEADERS.
	(copy_main): Likewise.
	* doc/binutils.texi: Document --strip-section-headers for objcopy
	and strip.

ld/

2023-06-06  H.J. Lu  <hongjiu.lu@intel.com>
	    Kaylee Blake  <klkblake@gmail.com>

	PR ld/25617
	* NEWS: Mention -z nosectionheader.
	* emultempl/elf.em: Support -z sectionheader and
	-z nosectionheader.
	* ld.h (ld_config_type): Add no_section_header.
	* ld.texi: Document -z sectionheader and -z nosectionheader.
	* ldlang.c (ldlang_open_output): Handle
	config.no_section_header.
	* lexsup.c (parse_args): Enable --strip-all with
	-z nosectionheader.  Disallow -r with -z nosectionheader.
	(elf_static_list_options): Add -z sectionheader and
	-z nosectionheader.
2023-06-29 10:29:46 -07:00
Matthias Klose
fa2b501cdc Ignore --prefix-file-map compiler option whist running testsuite. 2023-06-29 14:44:52 +01:00
Matthias Klose
96127db593 ignore lto-wrapper warnings for lto builds.
I see these warnings from time to time, when configuring a build with  --enable-pgo-build=lto, I haven't yet found out why I see these sometime, and  why not. E.g. https://gcc.gnu.org/PR109241. Just ignore these when they appear  in test cases. lto-wrapper: warning: using serial compilation of N LTRANS jobs
2023-06-29 14:30:55 +01:00
Indu Bhagat
fa3d73ebf3 binutils/NEWS: add note about upcoming libsframe changes
Some of these changes update the ABI in an incompatible way.
2023-06-27 12:01:56 -07:00
Nick Clifton
15d842846d Add note about adding ChangeLog.git to src-release.sh 2023-06-27 10:15:51 +01:00
Nick Clifton
340640f710 Prune linker warnings about an executable stack being created with the -z execstack option.
* testsuite/lib/binutils-common.exp (prune_warnings_extra): Prune warnings about -z execstack creating an executable stack.
2023-06-21 12:10:03 +01:00
Maciej W. Rozycki
9012d7819c binutils/NEWS: Mention Sony Allegrex MIPS CPU support
Mention the addition of Sony Allegrex processor support to the MIPS port.

	binutils/
	* NEWS: Mention Sony Allegrex MIPS CPU support.
2023-06-15 15:17:38 +01:00
David Guillen Fandos
df18f71b56 Add MIPS Allegrex CPU as a MIPS2-based CPU
The Allegrex CPU was created by Sony Interactive Entertainment to power
their portable console, the PlayStation Portable.
The pspdev organization maintains all sorts of tools to create software
for said device including documentation.

Signed-off-by: David Guillen Fandos <david@davidgf.net>
2023-06-15 04:45:03 +01:00
Maciej W. Rozycki
13527d85af Revert "MIPS: fix r6 testsuites"
This reverts commit ffc528aed5.  It was
applied unapproved.
2023-06-15 04:45:03 +01:00
Maciej W. Rozycki
3c0afdb789 Revert "MIPS: fix -gnuabi64 testsuite"
This reverts commit cb81e84c72.  It was
applied unapproved.
2023-06-15 04:45:03 +01:00
Alan Modra
ca5321d49a readelf/objdump remember_state memory leaks
* dwarf.c (display_debug_frames <DW_CFA_restore_state>): Do free
	invalid remember_state.
2023-06-09 12:56:12 +09:30
Alan Modra
f5c0d77088 objcopy memory leaks after errors
These aren't important at all, but tidy them in case they obscure
other more important leaks.

	* objcopy (copy_file): Close input bfd after errors.
2023-06-07 11:05:11 +09:30
Alan Modra
d3f340763b Re: loongarch readelf support
Commit 89c70cd358 apparently results in a bogus "value may be used
uninitialized" warning with some combination of compiler and
optimisation options.

	* readelf.c (target_specific_reloc_handling): Init value.
2023-06-06 20:09:39 +09:30
YunQiang Su
cb81e84c72 MIPS: fix -gnuabi64 testsuite
Test on:
	mips64-linux-gnuabi64
	mips64el-linux-gnuabi64
	mipsisa64-linux-gnuabi64
	mipsisa64el-linux-gnuabi64
	mipsisa64r2-linux-gnuabi64
	mipsisa64r2el-linux-gnuabi64
	mipsisa64r6-linux-gnuabi64
	mipsisa64r6el-linux-gnuabi64
2023-06-05 11:00:15 +08:00
YunQiang Su
ffc528aed5 MIPS: fix r6 testsuites
Introduce
	run_dump_test_o32l
	run_dump_test_n32l
	run_dump_test_n64l
Which use `-march=from-abi` for pre-R6 testcases,
like micromips/mips16e etc.

For cases doesn't use run_dump_test_*, we use
	-mips32r2 for micromips32
	-mips1 for mips16-32
	-march=from-abi for testcases to o32/n32/n64 both/all.

Replace `addi` with `addiu` for some cases for both r6 and pre-R6.

Introduce some new testcases for r6 with FPXX/FP64.
Introduce new testcase: comdat-reloc-r6.

Skip `default` in mips_arch_list_matching if triple is mipsisa*, due to:
  1)it will cannot match mipsr6@*.d: since mips32rN/mips64rN
    will always be used, it won't be a problem.
  2)some test think -march=mips64rN will alway true for mipsisa64rN,
    which is not true now.

This patch fix testsuite for all r6-default gnu triples:
  mipsisa32r6-linux-gnu
  mipsisa32r6el-linux-gnu
  mips-img-linux-gnu
  mipsel-img-linux-gnu
  mipsisa64r6-linux-gnu
  mipsisa64r6el-linux-gnu
2023-06-05 11:00:14 +08:00
Alan Modra
89c70cd358 Re: loongarch readelf support
Another segfault.

	* readelf.c (target_specific_reloc_handling): Sanity check
	loongarch reloc r_offset.
2023-06-03 17:17:57 +09:30
Alan Modra
74a965d8e0 loongarch readelf support
This fixes two buffer overflows found by fuzzers.

	* readelf.c (target_specific_reloc_handling): Sanity check
	loongarch reloc symbol index.  Don't apply reloc after errors.
	Reduce translation work of "invalid symbol index" error message.
2023-06-02 09:41:49 +09:30
Alan Modra
56e4ccc924 Minor objcopy optimisation for copy_relocations_in_section
* objcopy (copy_relocations_in_section): Don't read the relocs
	for STRIP_ALL if keep_specific_htab is empty.
2023-06-02 09:41:49 +09:30
Nick Clifton
10d6a2b1a0 Improve header information displayed with objdump -P for PE binaries.
* od-pe.c (targ_info): New array.
  (get_target_specific_info): New function.
  (decode_machine_number): Retire.  Use get_target_specific_info instead.
  (is_pe_object_magic): Likewise.
  (dump_pe_file_header): Display more information.
  Rework layout to be similar to that from 'objdump -p'.
  Add code to handle larger than normnal AOUT headers.
2023-05-30 15:43:24 +01:00
mengqinggang
7624446235 LoongArch: binutils: Add support for linker relaxation.
Add support for relocs related to relax to readelf.

binutils/ChangeLog:

	* readelf.c (target_specific_reloc_handling): Handle ULEB128 reloc.
	(is_32bit_inplace_add_reloc): Handle new reloc.
	(is_32bit_inplace_sub_reloc): Likewise.
	(is_64bit_inplace_add_reloc): Likewise.
	(is_64bit_inplace_sub_reloc): Likewise.
	(is_16bit_inplace_add_reloc): Likewise.
	(is_16bit_inplace_sub_reloc): Likewise.
	(is_8bit_inplace_add_reloc): Likewise.
	(is_8bit_inplace_sub_reloc): Likewise.
	(is_6bit_inplace_sub_reloc): Likewise.
	(is_6bit_inplace_add_reloc): New function.
	(apply_relocations): Handle new reloc.
	* testsuite/binutils-all/readelf.exp: Add -mno-relax option
	for LoongArch.
2023-05-30 19:56:45 +08:00
Nick Clifton
7b9e7db083 Add support for an ARMMAGIC value of 0xa00 to the PE dumper. 2023-05-30 11:42:16 +01:00
Alan Modra
796029320e arm-pe objdump -P
arm-pe looks to be a very old PE implementation, incompatible with
current arm-wince-pe.  arm-pe has different relocations and uses
ARMMAGIC which has this comment: "I just made this up".  Well, OK, I
don't know the history but it was probably before Microsoft "just made
up" their constants for ARM windows CE.

This patch supports objdump -P for arm-pe, and another magic constant
that may appear in object files.  (I don't think binutils generates
files using ARMV7PEMAGIC aka IMAGE_FILE_MACHINE_ARMNT.)

	* od-pe.c (is_pe_object_magic): Handle IMAGE_FILE_MACHINE_ARMNT
	and ARMMAGIC.
2023-05-30 12:59:55 +09:30
Alan Modra
9fa2b95974 Regen binutils POTFILES.in
for od-pe.c
2023-05-30 12:51:07 +09:30
Nick Clifton
45b8517aae Enhance objdump's --private option so that it can display the contents of PE format files.
* od-pe.c: New file: Dumps fields in PE format headers.
  * configure.ac (od_vectors): Add objdump_private_desc_pe for PE format targets. (od_files): Add od-pe for PE format targets.
  * configure: Regenerate.
  * Makefile.am (CFILES): Add od-pe.c (EXTRA_objdump_SOURCE): Likewise.
  * Makefile.in: Generate.
  * NEWS: Mention the new feature.
  * doc/binutils.texi: Document the new support.
  * objdump.c (wide_output): Change from local to global.
  * objdump.h (wide_output): Prototype. (objdump_private_desc_pe): Prototype.
  * testsuite/binutils-all/objdump.exp: Add a test of the new feature.
2023-05-26 15:41:20 +01:00
Alan Modra
7529ff1fcd PR29189, dlltool delaylibs corrupt float/double arguments
PR 29189
	* dlltool.c (i386_x64_trampoline): Save and restore xmm0-5.  Make
	use of parameter save area for integer arg regs.  Comment.
2023-05-25 16:57:16 +09:30
Alan Modra
bc227f4ccb Re: readelf: Support SHT_RELR/DT_RELR for -r
Revert value of DT_ENCODING to as it was before commit a7fd118627, and
adjust readelf.

include/
	* elf/common.h (DT_ENCODING): Set back to 32.
binutils/
	* readelf.c (struct filedata): Don't size dynamic_info array
	using DT_ENCODING.
2023-05-22 17:25:36 +09:30
Kuan-Lin Chen
f1cd8b94e7 RISC-V: Support subtraction of .uleb128.
96d6e190e9

There are some known limitations for now,

* Do not shrink the length of the uleb128 value, even if the value is reduced
after relaxations.  Also reports error if the length grows up.

* The R_RISCV_SET_ULEB128 needs to be paired with and be placed before the
R_RISCV_SUB_ULEB128.

bfd/
	* bfd-in2.h: Regenerated.
	* elfnn-riscv.c (perform_relocation): Perform R_RISCV_SUB_ULEB128 and
	R_RISCV_SET_ULEB128 relocations.  Do not shrink the length of the
	uleb128 value, and report error if the length grows up.  Called the
	generic functions, _bfd_read_unsigned_leb128 and _bfd_write_unsigned_leb128,
	to encode the uleb128 into the section contents.
	(riscv_elf_relocate_section): Make sure that the R_RISCV_SET_ULEB128
	must be paired with and be placed before the R_RISCV_SUB_ULEB128.
	* elfxx-riscv.c (howto_table): Added R_RISCV_SUB_ULEB128 and
	R_RISCV_SET_ULEB128.
	(riscv_reloc_map): Likewise.
	(riscv_elf_ignore_reloc): New function.
	* libbfd.h: Regenerated.
	* reloc.c (BFD_RELOC_RISCV_SET_ULEB128, BFD_RELOC_RISCV_SUB_ULEB128):
	New relocations to support .uleb128 subtraction.
gas/
	* config/tc-riscv.c (md_apply_fix): Added BFD_RELOC_RISCV_SET_ULEB128
	and BFD_RELOC_RISCV_SUB_ULEB128.
	(s_riscv_leb128): Updated to allow uleb128 subtraction.
	(riscv_insert_uleb128_fixes): New function, scan uleb128 subtraction
	expressions and insert fixups for them.
	(riscv_md_finish): Called riscv_insert_uleb128_fixes for all sections.
include/
	* elf/riscv.h ((R_RISCV_SET_ULEB128, (R_RISCV_SUB_ULEB128): Defined.
ld/
	* testsuite/ld-riscv-elf/ld-riscv-elf.exp: Updated.
	* testsuite/ld-riscv-elf/uleb128*: New testcase for uleb128 subtraction.
binutils/
	* testsuite/binutils-all/nm.exp: Updated since RISCV supports .uleb128.
2023-05-19 16:24:10 +08:00
Alan Modra
6109320673 Re: stack overflow in debug_write_type
Apparently u.kindirect->slot can point at a NULL.

	* debug.c (debug_write_type): Don't segfault on NULL indirect.
2023-05-10 23:10:19 +09:30
Enze Li
d9cc4b060d Correct a spelling mistake in the binutils README file. 2023-05-09 11:44:22 +01:00
Alan Modra
55a75aae9d stack overflow in debug_write_type
Another fuzzer attack.  This one was a "set" with elements using an
indirect type pointing back at the set.  The existing recursion check
only prevented simple recursion.

	* debug.c (struct debug_type_s): Add mark.
	(debug_write_type): Set mark and check before recursing into
	indirect types.
2023-05-09 17:11:46 +09:30
Nick Clifton
b545d4239b Remove Dimity Diky as MSP430 maintainer. 2023-05-02 13:33:53 +01:00
Alan Modra
4a8635cbec binutils runtest $CC
I noticed in the binutile Makefile that runtest is being invoked with
CC, CC_FOR_BUILD and other compiler related flags in the environment.
That doesn't work.  Those variables ought to be passed on the runtest
command line.

After fixing that I had some fails due to binutils testprog.c now
being compiled with the default "-g -O2" picked up in
CFLAGS_FOR_TARGET.  Hack around that by passing -O0.

Also, with the binutils testsuite now taking notice of CC_FOR_TARGET,
I found a couple of debuginfod.exp fails with one of my compilers that
happened to be built without --debug-id being enabled by default.

	* Makefile.am (check-DEJAGNU): Pass $CC and other variable on
	the runtest command line rather than futilely in the
	environment.  Add -O0 to CFLAGS_FOR_TARGET.
	* Makefile.in: Regenerate.
	* testsuite/binutils-all/debuginfod.exp: Compile testprog.c
	with -Wl,--build-id.
2023-04-26 10:32:07 +09:30
Alan Modra
c1eb3cd205 objcopy of archives tidy
This makes sure the input element bfd is closed before exiting the
loop copying elements.

	* objcopy.c (copy_archive): Rename output_bfd to output_element.
	Localise last_element.  Close this_element in more error cases.
2023-04-24 20:59:38 +09:30
YunQiang Su
32f1c80375 MIPS: support mips*64 as CPU and gnuabi64 as ABI
For MIPS64r6 ports, Debian as an example, `mipsisa64r6el` is
used as the cpu name in triple.
Let's recognize them by `mips*64*(el)`.

For 64bit Ports, like Debian's mips64el and mips64r6el ports,
`gnuabi64` is used as the abi section.
Let's use N64 abi by default for the triple with gnuabi64.
2023-04-23 14:32:43 +08:00
Nick Clifton
8e7785b4bd Add a SECURITY.txt file describing the GNU Binutils' project's stance on security related bugs. 2023-04-20 16:52:11 +01:00
Alan Modra
329dd2b6fc ubsan: signed integer overflow in display_debug_lines_raw
This one was caused by me unnecessarily promoting an "int adv" to
"int64_t adv".  The expression overflowing was 4259 + 9223372036854775807
with the left number being unsigned int.

	* dwarf.h (DWARF2_Internal_LineInfo): Replace unsigned short
	with uint16_t and unsigned char with uint8_t.  Make li_line_base
	an int8_t.
	* dwarf.c (display_debug_lines_raw): Revert "adv" back to an int.
2023-04-20 09:03:53 +09:30
Nick Clifton
28ab94f51d Fix: readelf: loc_offset XX too big
PR 30355
  * dwarf.c (read_and_display_attr_value): Correctly handle DW_loclistx attributes that index a version 5 .debug_loclists section.
2023-04-19 11:48:24 +01:00
Alan Modra
341eba4f9d objdump use of uninitialised value in pr_string_field
PR 30365
	* rdcoff.c (parse_coff_struct_type): Leave bitsize zero when no
	auxents.
2023-04-18 10:24:41 +09:30
Alan Modra
34d63622f6 objdump buffer overflow in fetch_indexed_string
PR 30361
	* dwarf.c (fetch_indexed_string): Sanity check string index.
2023-04-18 10:24:40 +09:30
Nick Clifton
c53c6186c8 Make the .rsrc section read only.
PR 30142
  * peXXigen.c (_bfd_XXi_swap_scnhdr_out): Do not force the .rsrc section to be writeable.
  * rescoff.c (write_coff_file): Add the SEC_READONLY flag to the .rsrc section.
2023-04-17 17:19:21 +01:00
Nick Clifton
7bb9e56c6a Replace an assertion in the dwarf code with a warning message.
PR 30327
  * dwarf.c (read_and_display_attr_value): Warn if the number of views is greater than the number of locations.
2023-04-11 17:24:09 +01:00
Nick Clifton
9f1c612b7c Fix an attempt to allocate an excessive amount of memory when parsing a corrupt DWARF file.
PR 30313
  * dwarf.c (display_debug_lines_decoded): Check for an overlarge number of files or directories.
2023-04-11 16:14:23 +01:00
Nick Clifton
688fe114cd Fix a potential illegal memory access when displaying corrupt DWARF information.
PR 30312
  * dwarf.c (prealloc_cu_tu_list): Always allocate at least one entry.
2023-04-11 15:59:07 +01:00
Nick Clifton
45f5fe468b Fix an attempt to allocate an overlarge amount of memory when decoding a corrupt ELF format file.
PR 30311
  * readelf.c (uncompress_section_contents): Check for a suspiciously large uncompressed size.
2023-04-11 15:30:02 +01:00
Alan Modra
11aa9f628e Re: objcopy write_debugging_info memory leaks
Oops, tried to free too much

	* wrstabs.c (write_stabs_in_sections_debugging_info): Don't
	free strings.
2023-04-06 21:27:54 +09:30
Alan Modra
a5f3ca4823 objdump print_debugging_info memory leaks
Fix memory leaks and do a general tidy of the code for printing coff
and stabs debug.

	* prdbg.c: Delete unnneeded forward function declarations.
	Delete unnecessary casts throughout.  Free all strings
	returned from pop_type throughout file.
	(struct pr_stack): Delete "num_parents".  Replace tests for
	"num_parents" non-zero with tests of "parents" non-NULL
	throughout.  Free "parents" before assigning, and set to NULL
	after freeing.  Remove const from "method".  Always strdup
	strings assigned to method, and free before assigning.
	(print_debugging_info): Free info.stack and info.filename.
2023-04-06 09:52:17 +09:30
Alan Modra
ff93c7b1a2 objdump -g on gcc COFF/PE files
objdump -g can't be used much.  Trying to dump PE files invariably
seems to run into "debug_name_type: no current file" or similar
errors, because parse_coff expects a C_FILE symbol to be the first
symbol.  Dumping -gstabs output works since the N_SO stab is present.
Pre-setting the file name won't hurt stabs dumping.

	* rddbg.c (read_debugging_info): Call debug_set_filename.
2023-04-06 09:51:38 +09:30
Alan Modra
41e6ffcecb objcopy write_debugging_info memory leaks
The old stabs code didn't bother too much about freeing memory.
This patch corrects that and avoids some dubious copying of strings.

	* objcopy.c (write_debugging_info): Free both strings and
	syms on failure to create sections.
	* wrstabs.c: Delete unnecessary forward declarations and casts
	throughout file.
	(stab_write_symbol_and_free): New function.  Use it
	throughout, simplifying return paths.
	(stab_push_string): Don't strdup string.  Use it thoughout
	for malloced strings.
	(stab_push_string_dup): New function.  Use it throughout for
	strings in auto buffers.
	(write_stabs_in_sections_debugging_info): Free malloced memory.
	(stab_enum_type): Increase buffer sizing for worst case.
	(stab_range_type, stab_array_type): Reduce buffer size.
	(stab_set_type): Likewise.
	(stab_method_type): Free args on error return.  Correct
	buffer size.
	(stab_struct_field): Fix memory leaks.
	(stab_class_static_member, stab_class_baseclass): Likewise.
	(stab_start_class_type): Likewise.  Correct buffer size.
	(stab_class_start_method): Correct buffer size.
	(stab_class_method_var): Free memory on error return.
	(stab_start_function): Fix "rettype" memory leak.
2023-04-06 09:51:38 +09:30
Alan Modra
19cacf6729 Use bfd_alloc memory for read_debugging_info storage
Trying to free malloc'd memory used by the stabs and coff debug info
parsers is complicated, and traversing the trees generated requires a
lot of code.  It's better to bfd_alloc the memory which allows it all
to be freed without fuss when the bfd is closed.  In the process of
doing this I reverted most of commit a633691333.

Some of the stabs handling code grows arrays of pointers with realloc,
to deal with arbitrary numbers of fields, function args, etc.  The
code still does that but copies over to bfd_alloc memory when
finished.  The alternative is to parse twice, once to size, then again
to populate the arrays.  I think that complication is unwarranted.

Note that there is a greater than zero chance this patch breaks
something, eg. that I missed an attempt to free obj_alloc memory.
Also it seems there are no tests in the binutils testsuite aimed at
exercising objdump --debugging.

	* budbg.h (finish_stab, parse_stab): Update prototypes
	* debug.c: Include bucomm.h.
	(struct debug_handle): Add "abfd" field.
	(debug_init): Add "abfd" param.  bfd_alloc handle.
	(debug_xalloc, debug_xzalloc): New functions.  Use throughout
	in place of xmalloc and memset.
	(debug_start_source): Remove "name_used" param.
	* debug.h (debug_init, debug_start_source): Update prototypes.
	(debug_xalloc, debug_xzalloc): Declare.
	* objcopy.c (copy_object): Don't free dhandle.
	* objdump.c (dump_bfd): Likewise.
	* rdcoff.c (coff_get_slot): Add dhandle arg.  debug_xzalloc
	memory in place of xcalloc.  Update callers.
	(parse_coff_struct_type): Don't leak on error return.  Copy
	fields over to debug_xalloc memory.
	(parse_coff_enum_type): Copy names and vals over the
	debug_xalloc memory.
	* rddbg.c (read_debugging_info): Adjust debug_init call.
	Don't free dhandle.
	(read_section_stabs_debugging_info): Don't free shandle.
	Adjust parse_stab call.  Call finish_stab on error return.
	(read_symbol_stabs_debugging_info): Similarly.
	* stabs.c (savestring): Delete unnecessary forward declaration.
	Add dhandle param.  debug_xalloc memory.  Update callers.
	(start_stab): Delete unnecessary casts.
	(finish_stab): Add "emit" param.  Free file_types, so_string,
	and stabs handle.
	(parse_stab): Delete string_used param.  Revert code dealing
	with string_used.  Copy so_string passed to debug_set_filename
	and stored as main_filename to debug_xalloc memory.  Similarly
	for string passed to debug_start_source and push_bincl.  Copy
	args to debug_xalloc memory.  Don't leak args.
	(parse_stab_enum_type): Copy names and values to debug_xalloc
	memory.  Don't free name.
	(parse_stab_struct_type): Don't free fields.
	(parse_stab_baseclasses): Delete unnecessary cast.
	(parse_stab_struct_fields): Return debug_xalloc fields.
	(parse_stab_cpp_abbrev): Use debug_xalloc for _vb$ type name.
	(parse_stab_one_struct_field): Don't free name.
	(parse_stab_members): Copy variants and methods to
	debug_xalloc memory.  Don't free name or argtypes.
	(parse_stab_argtypes): Use debug_xalloc memory for physname
	and args.
	(push_bincl): Add dhandle param.  Use debug_xalloc memory.
	(stab_record_variable): Use debug_xalloc memory.
	(stab_emit_pending_vars): Don't free var list.
	(stab_find_slot): Add dhandle param.  Use debug_xzalloc
	memory.  Update all callers.
	(stab_find_tagged_type): Don't free name.  Use debug_xzalloc.
	(stab_demangle_qualified): Don't free name.
	(stab_demangle_template): Don't free s1.
	(stab_demangle_args): Tidy pvarargs refs.  Copy *pargs on
	success to debug_xalloc memory, free on failure.
	(stab_demangle_fund_type): Don't free name.
	(stab_demangle_v3_arglist): Copy args to debug_xalloc memory.
	Don't free dt.
2023-04-04 12:47:56 +09:30
Alan Modra
a633691333 rddbg.c stabs FIXMEs
This should sort out some very old FIXMEs in code handling stabs
debug info.  Necessary if we are to fuss over freeing up memory before
objdump and objcopy exit.  It is of course better from a user
viewpoint to *not* free memory, which takes some time, and leave that
to process exit.  The only reason to do so is that having many memory
leaks in binutils/ code tends to hide leaks in bfd/ or opcodes/, which
we should care about.

	* budbg.h (parse_stab): Update prototype.
	* debug.h (debug_start_source): Update prototype.
	* debug.c (debug_start_source): Add name_used.  Set if stashed.
	* rddbg.c (read_symbol_stabs_debugging_info): Always malloc
	stab string passed to parse_stab.  Free stab string when
	unreferenced.
	(read_section_stabs_debugging_info): Likewise, and strings
	section contents.
	* stabs.c (parse_stab): Add string_used param.  Set if string
	stashed.  Pass to debug_start_source.  Realloc file_types
	array rather that using malloc.  Clarify comment about
	debug_make_indirect_type.
2023-04-03 07:29:35 +09:30
Alan Modra
31991eaaee Memory leak in process_abbrev_set
We may have added some abbrevs to the list before hitting an error.
Free the list elements too.  free_abbrev_list returns list->next so we
need to init it earlier to avoid an uninitialised memory access.

	* dwarf.c (process_abbrev_set): Call free_abbrev_list on errors.
	Set list->next earlier.
2023-04-03 07:29:01 +09:30
Nick Clifton
8d17c53b8d Fix an illegal memory access triggered by parsing corrupt DWARF info.
PR 30284
  * dwarf.c (read_and_display_attr_value): Detect and ignore negative base values.
2023-03-30 11:04:53 +01:00
Alan Modra
45fec14c02 Tidy leaked objcopy memory
* objcopy.c (delete_symbol_htabs): Also free symbols.
	(write_debugging_info): Free strings and syms once written.
	* wrstabs.c (write_stabs_in_sections_debugging_info): memset
	entire info struct.  Free hash tables before returning.  Free
	syms on error return.
2023-03-30 15:18:02 +10:30
Alan Modra
a2276a6d67 Tidy memory on addr2line failures
* addr2line.c (process_file): Close bfd on error paths.
2023-03-30 15:18:02 +10:30
Alan Modra
a2c7ca15a5 Use stdint types in coff internal_auxent
long is a poor choice of type to store 32-bit values read from
objects files by H_GET_32.  H_GET_32 doesn't sign extend so tests like
that in gdb/coffread.c for "negative" values won't work if long is
larger than 32 bits.  If long is 32-bit then code needs to be careful
to not accidentally index negative array elements.  (I'd rather see a
segfault on an unmapped 4G array index than silently reading bogus
data.)  long is also a poor choice for x_sect.s_scnlen, which might
have 64-bit values.  It's better to use unsigned exact width types to
avoid surprises.

I decided to change the field names too, which makes most of this
patch simply renaming.  Besides that there are a few places where
casts are no longer needed, and where printf format strings or tests
need adjusting.

include/
	* coff/internal.h (union internal_auxent): Use unsigned stdint
	types.  Rename l fields to u32 and u64 as appropriate.
bfd/
	* coff-bfd.c,
	* coff-rs6000.c,
	* coff64-rs6000.c,
	* coffcode.h,
	* coffgen.c,
	* cofflink.c,
	* coffswap.h,
	* peXXigen.c,
	* xcofflink.c: Adjust to suit internal_auxent changes.
binutils/
	* rdcoff.c: Adjust to suit internal_auxent changes.
gas/
	* config/obj-coff.h,
	* config/tc-ppc.c: Adjust to suit internal_auxent changes.
gdb/
	* coffread.c,
	* xcoffread.c: Adjust to suit internal_auxent changes.
ld/
	* pe-dll.c: Adjust to suit internal_auxent changes.
2023-03-27 21:58:46 +10:30
Alan Modra
695c322803 coffgrok access of u.auxent.x_sym.x_tagndx.p
u.auxent.x_sym.x_tagndx is a union.  The p field is only valid when
fix_tag is set.  This patch fixes code in coffgrok.c that accessed the
field without first checking fix_tag, and removes a whole lot of code
validating bogus pointers to prevent segfaults (which no longer
happen, I checked the referenced PR 17512 testcases).  The patch also
documents this in the fix_tag comment, makes is_sym a bitfield, and
sorts the selecter fields a little.

bfd/
	* coffcode.h (combined_entry_type): Make is_sym a bitfield.
	Sort and comment on union selectors.
	* libcoff.h: Regenerate.
binutils/
	* coffgrok.c (do_type): Make aux a combined_entry_type.  Test
	fix_tag before accessing u.auxent.x_sym.x_tagndx.p.  Remove
	now unnecessary pointer bounds checking.
2023-03-27 21:58:46 +10:30
Frederic Cambus
80251d4185 Add support to readelf for the PT_OPENBSD_MUTABLE segment type.
binutils * readelf.c (get_segment_type): Handle PT_OPENBSD_MUTABLE segment type.
include  * elf/common.h (PT_OPENBSD_MUTABLE): Define.
2023-03-23 15:19:38 +00:00
Alan Modra
75831f18a0 Another sanity check for read_section_stabs_debugging_info
* rddbg.c (read_section_stabs_debugging_info): Ignore invalid
	stab sections with size less than 12 bytes.
2023-03-19 22:19:19 +10:30
Clément Chigot
e263a66b01 readelf: add support for QNT_STACK note subsections
QNX provides some .note subsections. QNT_STACK is the one controling
the stack allocation.

bfd/ChangeLog:

	* elf.c (BFD_QNT_CORE_INFO): Delete.
	(BFD_QNT_CORE_STATUS): Likewise.
	(BFD_QNT_CORE_GREG): Likewise.
	(BFD_QNT_CORE_FPREG): Likewise.
	(elfcore_grok_nto_note): Replace BFD_QNT_* by QNT_*.

binutils/ChangeLog:

	* readelf.c (get_qnx_elfcore_note_type): New function.
	(print_qnx_note): New function.
	(process_note): Add support for QNX support.

include/ChangeLog:

	* elf/common.h (QNT_DEBUG_FULLPATH): New define.
	(QNT_DEBUG_RELOC): New define.
	(QNT_STACK): New define.
	(QNT_GENERATOR): New define.
	(QNT_DEFAULT_LIB): New define.
	(QNT_CORE_SYSINFO): New define.
	(QNT_CORE_INFO): New define.
	(QNT_CORE_STATUS): New define.
	(QNT_CORE_GREG): New define.
	(QNT_CORE_FPREG): New define.
	(QNT_LINK_MAP): New define.
2023-03-16 15:01:05 +01:00
Alan Modra
d56e433a79 Re: Sanity check read_section_stabs_debugging_info
* rddbg.c (read_section_stabs_debugging_info): Don't segfault on
	zero size string section.
2023-03-16 11:11:44 +10:30
Nick Clifton
97b75c421f Prevent an over large memory allocation in readelf when parsing a corrupt DWARF file.
PR 30227
  * dwarf.c (process_cu_tu_index): Prevent excessive memory allocation when nused is large and ncols is zero.
2023-03-14 13:15:12 +00:00
Nick Clifton
7506fc9bf1 Adjust the decoded line output to fit into 80 columns.
PR 30216
  * dwarf.c (display_debug_lines_decoded): Reduce space for filenames.
  * testsuite/binutils-all/dw5.W: Adjust expected output.
  * testsuite/binutils-all/objdump.WL: Adjust expected output.
2023-03-14 12:21:13 +00:00
Alan Modra
c8b3d02c49 objdump segfault after symbol table error
This memcpy segfaults if symcount is -1 (=> syms is NULL).
      memcpy (sorted_syms, symcount ? syms : dynsyms,
	      sorted_symcount * sizeof (asymbol *));

	* objdump.c (slurp_symtab): Don't leave symcount as -1 after
	an error.
	(slurp_dynamic_symtab): Likewise for dynsymcount.
2023-03-14 12:19:28 +10:30
Alan Modra
746598e07f Sanity check read_section_stabs_debugging_info
* rddbg.c (read_section_stabs_debugging_info): Exclude sections
	without contents.  Use bfd_malloc_and_get_section.  Don't alloc
	one extra for strings.
2023-03-14 12:19:09 +10:30
Alan Modra
093b56776f objdump: report no section contents
objdump's read_section is never used for bss-style sections, so to
plug a hole that fuzzers have found, exclude sections without
SEC_HAS_CONTENTS.

	* objdump.c (read_section): Report and return an error on
	a no contents section.
2023-03-09 22:48:06 +10:30
Alan Modra
160f200778 Re: Move nm.c cached line number info to bfd usrdata
Commit e3f450f393 resulted in a nm -l segfault on object files
without undefined symbols.  Fix that, and be paranoid about bfd
section count changing.

	* nm.c (struct lineno_cache): Add seccount.
	(free_lineno_cache): Don't segfault on NULL lc->relocs.
	(print_symbol): Stash section count when creating arrays.
2023-03-08 11:24:55 +10:30
Alan Modra
ffdfc835dd Downgrade objdump fatal errors to non-fatal
* objdump.c (slurp_symtab): Replace bfd_fatal calls with calls
	to my_bfd_nonfatal.
	(slurp_dynamic_symtab, disassemble_section): Likewise.
	(disassemble_data): Replace fatal call with non_fatal call, and
	set exit_status.  Don't error on non-existent dynamic relocs.
	Don't call bfd_fatal on bfd_canonicalize_dynamic_reloc error.
	(dump_ctf, dump_section_sframe): Replace bfd_fatal calls with
	calls to my_bfd_nonfatal and clean up memory.
	(dump_relocs_in_section): Don't call bfd_fatal on errors.
	(dump_dynamic_relocs): Likewise.
	(display_any_bfd): Make archive nesting too depp non_fatal.
2023-03-06 13:11:22 +10:30
Alan Modra
5db0367e1b Downgrade addr2line fatal errors to non-fatal
* addr2line.c (slurp_symtab): Don't exit on errors.
	(process_file): Likewise.
2023-03-06 13:11:22 +10:30
Alan Modra
86a2562b09 Downgrade nm fatal errors to non-fatal
Many of the fatal errors in nm ought to be recoverable.  This patch
downgrades most of them.  The ones that are left are most likely due
to memory allocation failures.

	* nm.c (print_symdef_entry): Don't bomb with a fatal error
	on a corrupted archive symbol table.
	(filter_symbols): Silently omit symbols that return NULL
	from bfd_minisymbol_to_symbol rather than giving a fatal
	error.
	(display_rel_file): Don't give a fatal error on
	bfd_read_minisymbols returning an error, or on not being able
	to read dynamic symbols for synth syms.
	(display_archive): Downgrade bfd_openr_next_archived_file
	error.
	(display_file): Don't bomb on a bfd_close failure.
2023-03-06 13:11:10 +10:30
Alan Modra
e3f450f393 Move nm.c cached line number info to bfd usrdata
Replace the static variables used by nm to cache line number info
with a struct attached to the bfd.  Cleaner, and it avoids any concern
that lineno_cache_bfd is somehow left pointing at memory for a closed
bfd and that memory is later reused for another bfd, not that I think
this is possible.  Also don't bomb via bfd_fatal on errors getting
the line number info, just omit the line numbers.

	* nm.c (struct lineno_cache): Rename from get_relocs_info.
	Add symcount.
	(lineno_cache_bfd, lineno_cache_rel_bfd): Delete.
	(get_relocs): Adjust for struct rename.  Don't call bfd_fatal
	on errors.
	(free_lineno_cache): New function.
	(print_symbol): Use lineno_cache in place of statics.  Don't
	call bfd_fatal on errors reading symbols, just omit the line
	info.
	(display_archive, display_file): Call free_lineno_cache.
2023-03-06 10:42:36 +10:30
Alan Modra
a734d906cc Correct objdump command line error handling
bfd_nonfatal is used when a bfd error is to be printed.  That's not
the case for command line errors.

	* objdump.c (nonfatal): Rename to my_bfd_nonfatal.
	(main): Use non_fatal and call usage on unrecognized arg errors.
	Don't set exit_status when calling usage.
2023-03-06 10:42:22 +10:30
Alan Modra
945efa5c53 Tidy type handling in binutils/rdcoff.c
There isn't really any good reason for code in rdcoff.c to distinguish
between "basic" types and any other type.  This patch dispenses with
the array reserved for basic types and instead handles all types using
coff_get_slot, simplifying the code.

	* rdcoff.c (struct coff_types, coff_slots): Merge.  Delete
	coff_slots.
	(T_MAX): Delete.
	(parse_coff_base_type): Use coff_get_slot to store baseic types.
	(coff_get_slot, parse_coff_type, parse_coff_base_type),
	(parse_coff_struct_type, parse_coff_enum_type),
	(parse_coff_symbol, parse_coff): Pass types as coff_types**.
2023-03-03 12:31:24 +10:30
Alan Modra
de357ff4e4 binutils coff type list
As for commit 72d225ef9c, handle type numbers starting anywhere.

	PR 17512
	* rdcoff.c (struct coff_slots): Add base_index.
	(coff_get_slot): Delete pr17512 excessively large slot check.
	Don't allocate entire array from 0 to type number, allocate a
	sparse array.
2023-03-03 10:35:54 +10:30
Clément Chigot
2b69325792 testsuite: prune DOS drive letter in test outputs
On DOS systems, absolute paths start with the drive letter. This can
trigger failures in the regexp from dump tests, especially for those
checking for warnings or errors. They are usually skipping everything
before the first ":" as it has to be the file path.
  | [^:]*: warning: ...

In order to avoid modifying many regexps to allow such drive letters,
prune them from all the outputs if they are found at the beginning of
a line.

binutils/ChangeLog:

	* testsuite/lib/binutils-common.exp (prune_dump_output): New
	(run_dump_test): Use it.

ld/ChangeLog:

	* testsuite/ld-elf/noinit-sections-2.l: Remove DOS drive letter
	handler.
2023-02-24 14:35:10 +01:00
Alan Modra
5e39600a69 set bfd_error on make_tempname or make_tempdir failure
* bucomm.c (make_tempname, make_tempdir): Set bfd_error on error.
2023-02-22 12:04:07 +10:30
Alan Modra
c65f94a07a Re: objdump read_section_stabs
Also fix ubsan "applying zero offset to null pointer".

	* objdump.c (print_section_stabs): Avoid ubsan warning.
2023-02-22 10:01:10 +10:30
Alan Modra
45b36294d6 Re: objdump read_section_stabs
Commit f9c36cc995 changed (and renamed) read_section_stabs with one
difference in overall behaviour.  Previously read_section_stabs would
return a NULL for an empty section, which was then treated the same as
a missing section.  Now an empty section is recognized and dumped.
This leads to NULL stabp and stabs_end in print_section_stabs.  Since
stabs_end - STABSIZE is then a pointer to a very large address, the
test "stabp < stabs_end - STABSIZE" succeeds.

	* objdump.c (print_section_stabs): Correct STABSIZE comparison.
2023-02-22 09:18:25 +10:30
Alan Modra
5f497256be ld test asciz and ascii fails
Fix these fails:
alpha-dec-vms  +FAIL: ld-scripts/asciz
alpha-dec-vms  +FAIL: ld-scripts/ascii
i386-go32  +FAIL: ld-scripts/asciz
sh-coff  +FAIL: ld-scripts/asciz

It's better to positively select targets for .section support than to
try to exclude all targets that don't.  Make a new is_coff_format so
we can easily select such.

binutils/
	* testsuite/lib/binutils-common.exp (is_coff_format): New.
ld/
	* testsuite/ld-scripts/ascii.d: Use is_elf_format and
	is_coff_format to select targets, exclude ti coff.
	* testsuite/ld-scripts/asciz.d: Likewise.  Accept trailing zeros.
2023-02-17 15:19:47 +10:30
Alan Modra
7ed4ad59e9 Delete PROGRESS macros
I don't see much point in cluttering the source with the PROGRESS
macros, which of course do nothing at all with the definitions in
progress.h.  progress.h is unchanged apart from the copyright comment
since commit d4d4c53c68 in 1994.

binutils/
	* ar.c: Don't include progress.h, or invoke PROGRESS macros.
	* nm.c: Likewise.
	* objcopy.c: Likewise.
	* objdump.c: Likewise.
gas/
	* as.h: Don't include progress.h.
	* as.c: Don't invoke PROGRESS macros.
	* write.c: Likewise.
include/
	* progress.h: Delete.
ld/
	* ldmain.c: Don't include progress.h, or invoke PROGRESS macros.
2023-02-16 21:00:50 +10:30
Alan Modra
f9c36cc995 objdump read_section_stabs
This function is used to read sections other than stabs, and there is
now another version of it that extracts different info from the bfd
section.  Rename it and return the bfd section instead of assorted
fields of the bfd section.

	* objcopy.c (read_section): Renamed from read_section_stabs.
	Delete size_ptr and entsize_ptr params, add contents param.
	Return asection pointer.  Don't unnecessarily free contents on
	failure from bfd_malloc_and_get_section.
	(find_stabs_section): Use read_section.
	(dump_ctf, dump_section_sframe): Likewise.
	(read_section_sframe): Delete.
2023-02-15 22:03:30 +10:30
Alan Modra
11066c2aab objdump -G memory leak
* objdump.c (find_stabs_section): Free stabs.
2023-02-15 22:03:30 +10:30
Alan Modra
72d225ef9c binutils stabs type list
Fuzzers have found that specifying a large stab type number results in
lots of memory being requested, as the list is extended with a 16
element array at a time until we reach the given stab type.  It also
takes a long time.  Of course normal sane stab types use small
positive integers, but it's not hard to modify the code to handle type
numbers starting anyhere.

	* stabs.c (struct stab_types): Add base_index.
	(stab_find_slot): Simplify filenum check.  Delete type number
	check.  Don't allocate entire array from 0 to type number,
	allocate a sparse array.
2023-02-15 13:05:28 +10:30
Andrew Burgess
77be725744 opcodes/mips: disassemble unknown micromips instructions as two shorts
Before commit:

  commit 2438b771ee
  Date:   Wed Nov 2 15:53:43 2022 +0000

      opcodes/mips: use .word/.short for undefined instructions

unknown 32-bit microMIPS instructions were disassembled as a raw
32-bit number with no '.word' directive.  The above commit changed
this and added a '.word' directive before the 32-bit number.

It was pointed out on the mailing list, that for microMIPS it would be
better to display such 32-bit instructions using a '.short' directive
followed by two 16-bit values.

This commit updates the mips disassembler to do this, and adds a new
test that validates this output.
2023-02-13 12:05:32 +00:00
Alan Modra
3eef3b2c2d objcopy memory leaks
This fixes some objcopy memory leaks.  commit 450da4bd38 used
xatexit to tidy most of the hash table memory, but of course that's
ineffective without a call to xexit.  The other major memory leak
happens if there is an error of some sort writing the output file, due
to not closing the input file and thus not freeing memory attached to
the bfd.

	* objcopy.c (copy_file): Don't return when bfd_close of output
	gives an error, always bfd_close input too.
	(main): Call xexit.
2023-02-13 12:53:31 +10:30
Alan Modra
0a3137ce4c objdump -D of bss sections and -s with -j
There is some inconsistency between the behaviour of objdump -D and
objdump -s, both supposedly operating on all sections by default.
objdump -s ignores bss sections, while objdump -D dissassembles the
zeros.  Fix this by making objdump -D ignore bss sections too.

Furthermore, "objdump -s -j .bss" doesn't dump .bss as it should,
since the user is specifically asking to look at all those zeros.

This change does find some tests that used objdump -D with expected
output in bss-style sections.  I've updated all the msp430 tests that
just wanted to find a non-empty section to look at section headers
instead, making the tests slightly more stringent.  The ppc xcoff and
spu tests are fixed by adding -j options to objdump, which makes the
tests somewhat more lenient.

binutils/
	* objdump.c (disassemble_section): Ignore sections without
	contents, unless overridden by -j.
	(dump_section): Allow -j to override the default of not
	displaying sections without contents.
	* doc/binutils.texi (objdump options): Update -D, -s and -j
	description.
gas/
	* testsuite/gas/ppc/xcoff-tls-32.d: Select wanted objdump
	sections with -j.
	* testsuite/gas/ppc/xcoff-tls-64.d: Likewise.
ld/
	* testsuite/ld-msp430-elf/main-bss-lower.d,
	* testsuite/ld-msp430-elf/main-bss-upper.d,
	* testsuite/ld-msp430-elf/main-const-lower.d,
	* testsuite/ld-msp430-elf/main-const-upper.d,
	* testsuite/ld-msp430-elf/main-text-lower.d,
	* testsuite/ld-msp430-elf/main-text-upper.d,
	* testsuite/ld-msp430-elf/main-var-lower.d,
	* testsuite/ld-msp430-elf/main-var-upper.d: Expect -wh output.
	* testsuite/ld-msp430-elf/msp430-elf.exp: Use objdump -wh
	rather than objdump -D or objdump -d with tests checking for
	non-empty given sections.
	* testsuite/ld-spu/ear.d,
	* testsuite/ld-spu/icache1.d,
	* testsuite/ld-spu/ovl.d,
	* testsuite/ld-spu/ovl2.d: Select wanted objdump sections.
2023-02-11 16:43:54 +10:30
Tom Tromey
93c8054387 Add full display feature to dwarf-mode.el
I've found that I often use dwarf-mode with relatively small test
files.  In this situation, it's handy to be able to expand all the
DWARF, rather than moving to each "..." separately and using C-u C-m.

This patch implements this feature.  It also makes a couple of other
minor changes:

* I removed a stale FIXME from dwarf-mode.  In practice I find I often
  use "g" to restore the buffer to a pristine state; checking the file
  mtime would work against this.

* I tightened the regexp in dwarf-insert-substructure.  This prevents
  the C-m binding from trying to re-read a DIE which has already been
  expanded.

* Finally, I've bumped the dwarf-mode version number so that this
  version can easily be installed using package.el.

2023-02-09  Tom Tromey  <tromey@adacore.com>

	* dwarf-mode.el: Bump version to 1.8.
	(dwarf-insert-substructure): Tighten regexp.
	(dwarf-refresh-all): New defun.
	(dwarf-mode-map): Bind "A" to dwarf-refresh-all.
	(dwarf-mode): Remove old FIXME.
2023-02-09 13:50:21 -07:00
Alan Modra
87d206578e Clear cached file size when bfd changed to BFD_IN_MEMORY
If file size is calculated by bfd_get_file_size, as it is by
_bfd_alloc_and_read calls in coff_object_p, then it is cached and when
pe_ILF_build_a_bfd converts an archive entry over to BFD_IN_MEMORY,
the file size is no longer valid.  Found when attempting objdump -t on
a very small (27 bytes) ILF file and hitting the pr24707 fix (commit
781152ec18).  So, clear file size when setting BFD_IN_MEMORY on bfds
that may have been read.  (It's not necessary in writable bfds,
because caching is ignored by bfd_get_size when bfd_write_p.)

I also think the PR 24707 fix is no longer neeeded.  All of the
testcases in that PR and in PR24712 are caught earlier by file size
checks when reading the symbols from file.  So I'm reverting that fix,
which just compared the size of an array of symbol pointers against
file size.  That's only valid if on-disk symbols are larger than a
host pointer, so the test is better done in format-specific code.

bfd/
	* coff-alpha.c (alpha_ecoff_get_elt_at_filepos): Clear cached
	file size when making a BFD_IN_MEMORY bfd.
	* opncls.c (bfd_make_readable): Likewise.
	* peicode.h (pe_ILF_build_a_bfd): Likewise.
binutils/
	PR 24707
	* objdump.c (slurp_symtab): Revert PR24707 fix.  Tidy.
	(slurp_dynamic_symtab): Tidy.
2023-02-09 09:39:45 +10:30
Nick Clifton
3a8be578d6 Fix documentation of the 'n' symbol type displayed by nm.
PR 30080 * doc/binutils.texi (nm): Update description of the 'n' symbol type.
2023-02-07 11:41:28 +00:00
Jan Beulich
0655669b86 RISC-V: don't disassemble unrecognized insns as .byte
Insn width granularity being 16 bits, producing byte granular output
isn't very useful. With there being a way to specific otherwise
unknown insns to the assembler, use that same representation (to be
precise: its <length>,<encoding> flavor) for disassembly.
2023-02-03 08:20:32 +01:00
Nick Clifton
be527f283a Updated Swedish translation for the binutils sub-directory 2023-01-31 13:02:20 +00:00
Alan Modra
6296342ec4 PR 30060, ASAN error in bfd_cache_close
After bfd_close nothing should access bfd memory.  Now that bfd_close
always tidies up even after an error, attempting to tidy the cached
bfd list by calling bfd_cache_close is wrong and not needed.

	PR 30060
	* ar.c (remove_output): Don't call bfd_cache_close.
	(output_bfd): Delete.
	* arsup.c (ar_end): Call bfd_close_all_done, not bfd_cache_close.
2023-01-31 15:18:04 +10:30
Alan Modra
9884676d9d testsuite XPASSes
This adjusts the testsuite to get rid of a number of XPASSes that have
appeared.  Someone might like to look into a better patch for the s390
change.

aarch64-pe  XPASS: weak symbols
arm-nacl  XPASS: rgn-over8
mcore-pe  XPASS: ld-scripts/provide-8
mips64-linux-gnuabi64  XPASS: vers4
mips64-linux-gnuabi64  XPASS: vers4b
mips-linux-gnu  XPASS: vers4
mips-linux-gnu  XPASS: vers4b
s390-linux-gnu  XPASS: undefined line
sh4-linux-gnu  XPASS: --gc-sections with __start_SECTIONNAME
sh-coff  XPASS: objcopy object (simple copy)
sh-coff  XPASS: objcopy executable (pr25662)

binutils/
	* testsuite/binutils-all/objcopy.exp: Don't xfail "simple
	copy" and "pr25662" on sh-*-coff.  Remove all non-ELF xfails
	on "ELF unknown section type" test.
ld/
	* testsuite/ld-elfvers/vers.exp (vers4, vers4b): Don't xfail
	all mips, just xfail mips irix.
	* testsuite/ld-gc/pr19161.d: Don't xfail sh.
	* testsuite/ld-scripts/rgn-over8-ok.d: Don't xfail nacl.
	* testsuite/ld-scripts/weak.exp: Don't xfail aarch64-pe.
	* testsuite/ld-undefined/undefined.exp: Conditionally xfail
	"undefined line" depending on gcc version for s390.
2023-01-31 15:18:04 +10:30
Nick Clifton
b960c86c1e Updated Swedish translation for the binutils sub-directory 2023-01-23 10:53:12 +00:00
Vladislav Khmelevsky
7e538762c2 Fix objdump --reloc for specific symbol
If objdump is used with both --disassemble=symbol and --reloc options
skip relocations that have addresses before the symbol, so that they
are not displayed.
2023-01-23 12:51:10 +10:30
Indu Bhagat
57ffc61c6d Upload SFrame spec files as well
binutils/
	* README-how-to-make-a-release: Include sframe-spec html and pdf
	files.
2023-01-20 11:14:11 -08:00
Nick Clifton
94e76498c3 Speed up objcopy's note merging.
PR 29993
  * objcopy.c (merge_gnu_build_notes): Remember the last non-deleted note in order to speed up the scan for matching notes.
2023-01-18 11:32:21 +00:00
Nick Clifton
f75c8fc014 Update release making howto 2023-01-16 11:31:39 +00:00
Nick Clifton
69373ba164 Updated translations for the gas and binutils sub-directories 2023-01-16 10:45:38 +00:00
Nick Clifton
311578da0f Update how-to-make-a-release file now that the 2.40 release is out 2023-01-14 15:37:20 +00:00
Alan Modra
2070fc67ba Remove myself as hppa32 maintainer
Reflects the reality that I haven't done much on hppa32 for years.
2023-01-12 17:20:21 +10:30
Mark Harmstone
16fea92ccd Add aarch64-w64-mingw32 target
This adds a mingw target for aarch64, including windres and dlltool.

Note that the old value of jmp_aarch64_bytes was wrong, and this does
the same thing as MSVC does.
2023-01-10 23:30:49 +00:00
Nick Clifton
4004cf8331 Updated transaltions for the gprof and binutils sub-directories 2023-01-09 10:24:13 +00:00
Alan Modra
02da71ee20 PR29972, inconsistent format specification in singular form
PR 29972
	* readelf.c (process_dynamic_section): Correct format string.
2023-01-08 13:10:16 +10:30
Alan Modra
22a95e1a37 Make coff backend data read-only
The bfd_coff_backend_data struct should be read-only, the only thing
preventing this is that objcopy writes to one of the fields,
_bfd_coff_long_section_names.  This patch creates a copy of the field
in bfd coff_obj_tdata, which makes more sense anyway.  When enabling
long section names the intent is to do so for a particular bfd, not
for all bfds that might happen to be using the target xvec.

bfd/
	* coffcode.h: Update coff long section name comment.
	(bfd_coff_set_long_section_names_allowed): Use macro accessor
	to set flag.
	(bfd_coff_set_long_section_names_disallowed): Tidy.
	(coff_backend_info): Return a const pointer.
	(bfd_coff_std_swap_table, ticoff0_swap_table, ticoff1_swap_table),
	(bigobj_swap_table): Make const.
	(bfd_coff_long_section_names): Use tdata copy.
	(coff_mkobject): Set long_section_names from coff_backend_info.
	* coff-go32.c (_bfd_go32_mkobject): Likewise.
	* peicode.h (pe_mkobject): Likewise.
	* coff-sh.c (bfd_coff_small_swap_table): Make const.
	* libcoff-in.h (struct coff_tdata): Add long_section_names,
	reorder fields.
	* libcoff.h: Regenerate.
binutils/
	* objcopy.c (set_long_section_mode): Move earlier in file.
	(copy_object): Call set_long_section_mode here, after setting
	output format.
	(copy_file): Don't call set_long_section_mode.
2023-01-06 21:06:15 +10:30
Nick Clifton
c362d5978e Remove Stephen Casner as the PDP11 maintainer. 2023-01-05 14:40:16 +00:00
Indu Bhagat
aa036eccf0 MAINTAINERS: add myself as maintainer of libsframe
binutils/
	* MAINTAINERS: Add myself as maintainer of libsframe.
2023-01-04 11:42:11 -08:00
Alan Modra
fa19218f8b objcopy fuzzed pe out of memory
This occurs when attempting to read back a section from the output
file in _bfd_XX_bfd_copy_private_bfd_data_common.  The copy of the
section failed size sanity checking, thus it won't be written.

	* objcopy.c (copy_object): Return false if copy_section or
	copy_relocations_in_section fails.
2023-01-04 23:52:26 +10:30
Alan Modra
3bba9d9329 fuzzed file timeout
objcopy of archive, element containing an object with a fuzzed section
size far exceeding the element size.  copy_section detects this, but
the temp file is laid out for the large section.  It can take a long
time to write terabytes of sparse file, a waste of time when it will
be deleted.

	* objcopy.c (copy_archive): Don't write element contents after
	bad status result from copy_object.
2023-01-04 23:52:26 +10:30
Nick Clifton
11982f9f8b Updated translations for various languages and sub-directories 2023-01-03 11:32:42 +00:00
Luis Machado
a8f175d9d0 Add new NT_ARM_ZA and NT_ARM_SSVE register set constants. 2023-01-03 11:15:26 +00:00
Alan Modra
3002e78a7d obsolete target tidy
Delete a few files only used for obsolete targets, and tidy config,
xfails and other pieces of support specific to those targets.  And
since I was editing target triplets in test files, fix the nm
alpha-linuxecoff fails.
2023-01-02 14:03:22 +10:30
Alan Modra
d87bef3a7b 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-01 21:50:11 +10:30
Nick Clifton
d41af08c0b Update version numbers in howto-make-a-release document 2022-12-31 13:01:40 +00:00
Nick Clifton
96e786d198 Update version number and regenerate files 2022-12-31 12:23:00 +00:00
Nick Clifton
a72b07181d Add markers for 2.40 branch 2022-12-31 12:05:28 +00:00
Nick Clifton
826eed8027 Updated Romanian translation for the binutils sub-directory 2022-12-31 08:55:31 +00:00
Alan Modra
a984f112b0 PR29948, heap-buffer-overflow in display_debug_lines_decoded
This fixes a couple of places in display_debug_lines_decoded that were
off by one in checking DWARF5 .debug_line directory indices.  It also
displays the DWARF5 entry 0 for the program current directory rather
than "." as is done for pre-DWARF5.  I decided against displaying
DW_AT_comp_dir for pre-DWARF5 since I figure it is better for readelf
to minimally interpret debug info.

binutils/
	PR 29948
	* dwarf.c (display_debug_lines_decoded): Display the given
	directory entry 0 for DWARF5.  Properly check directory index
	against number of entries in the table.  Revert to using
	unsigned int for n_directories and associated variables.
	Correct warning messages.
gas/
	* testsuite/gas/elf/dwarf-5-loc0.d: Update.
2022-12-30 21:31:19 +10:30
Nick Clifton
75393a2d54 Fix an attempt to allocate an unreasonably large amount of memory when parsing a corrupt ELF file.
PR  29924
	* objdump.c (load_specific_debug_section): Check for excessively
	large sections.
2022-12-21 11:51:23 +00:00
Tom Tromey
0d120726bd Avoid compiler warning in dwarf-do-refresh
The Emacs 28 compiler warns about dwarf-mode.el:

Warning (comp): dwarf-mode.el:180:32: Warning: Unused lexical argument `ignore'

This is easily fixed by prepending "_" to the parameter's name.

binutils/ChangeLog
2022-12-19  Tom Tromey  <tromey@adacore.com>

	* dwarf-mode.el (dwarf-do-refresh): Avoid compiler warning.
2022-12-19 09:46:54 -07:00
Alan Modra
956bc7a29f Tidy PR29893 and PR29908 fix
PR 29893
	PR 29908
	* dwarf.c (display_debug_addr): Combine dwarf5 unit_length checks.
	Delete dead code.
2022-12-19 22:30:36 +10:30
Nick Clifton
42f39fdedc Fix potential illegal memory accesses when parsing corrupt DWARF data.
PR 29914
	* dwarf.c (fetch_indexed_value): Fail if the section is not big
	enough to contain a header size field.
	(display_debug_addr): Fail if the computed address size is too big
	or too small.
2022-12-19 11:13:46 +00:00
Nick Clifton
c7ce51d8c8 Fix previous delta to allow for compilation on 32-bit systems 2022-12-16 15:44:55 +00:00
Nick Clifton
fa501b6930 Fix a potential illegal memory access when parsing corrupt DWARF information.
PR 29908
	* dwarf.c (display_debug_addr): Check for corrupt header lengths.
2022-12-16 12:06:43 +00:00
Alan Modra
d0517d6e33 asan: signed integer overflow in display_debug_frames
* dwarf.c (struct Frame_Chunk): Make col_offset an int64_t.
	Adjust all places allocating col_offset and col_type to use
	the size of the array element rather than the size of a type.
	(frame_display_row): Adjust printing of col_offset.
	(display_debug_frames): Factor out multiplication by
	code_factor and data_factor.  Avoid signed overflow.  Use
	64-bit variables.
2022-12-14 13:07:43 +10:30
Alan Modra
bd5efa5930 Don't access freed memory printing objcopy warning
abfd->filename will be freed if bfd_close gets far enough to delete
the bfd.  It's possible to have an error from fclose at this point.

	* objcopy.c (copy_archive): Dup filename before closing bfd for
	potential use in bfd_nonfatal_message.
2022-12-14 13:07:43 +10:30
Alan Modra
c8628c770b PR29893, buffer overflow in display_debug_addr
PR 29893
	* dwarf.c (display_debug_addr): Sanity check dwarf5 unit_length
	field.  Don't read past end.
2022-12-13 00:36:08 +10:30
Alan Modra
b1f1cefd58 PR29872, uninitialised value in display_debug_lines_decoded dwarf.c:5413
Plus segvs if the C-library doesn't handle printf %s of NULL.

	PR 29872
	* dwarf.c (null_name): New function.
	(process_debug_info): Use it here..
	(display_debug_lines_raw): ..and here..
	(display_debug_lines_decoded): ..and here.  xcalloc directory_table.
	Simplify xcalloc of file_table.
2022-12-12 19:25:19 +10:30
Alan Modra
f2f58a399c PR29870, objdump SEGV in display_debug_lines_decoded dwarf.c:5524
DWARF5 directory and file table allow more opportunity for fuzzers
to break things.  There are likely other places in dwarf.c that should
be fixed too.

	PR 29870
	* dwarf.c (display_debug_lines_decoded): Handle NULL file_table
	name entry.
2022-12-11 14:47:57 +10:30
Indu Bhagat
ed38cbc331 objdump: sframe: fix memory leaks
ChangeLog:

	* binutils/objdump.c (dump_section_sframe): free up contents and
	SFrame decoder context on exit.
2022-12-09 10:25:46 -08:00
Alan Modra
c3620d6d56 Compression tidy and fixes
Tidies:
- Move stuff from bfd-in.h and libbfd.c to compress.c
- Delete COMPRESS_DEBUG from enum compressed_debug_section_type
- Move compress_debug field out of link_info to ld_config.
Fixes:
- Correct test in bfd_convert_section_setup to use obfd flags,
  not ibfd.
- Apply bfd_applicable_file_flags to compression bfd flags added
  by gas and ld to the output bfd.

bfd/
	* bfd-in.h (enum compressed_debug_section_type),
	(struct compressed_type_tuple),
	(bfd_get_compression_algorithm),
	(bfd_get_compression_algorithm_name),
	* libbfd.c (compressed_debug_section_names),
	(bfd_get_compression_algorithm),
	(bfd_get_compression_algorithm_name): Move..
	* compress.c: ..to here, deleting COMPRESS_DEBUG from
	enum compressed_debug_section_type.
	(bfd_convert_section_setup): Test obfd flags not ibfd for
	compression flags.
	* elf.c (elf_fake_sections): Replace link_info->compress_debug
	test with abfd->flags test.
	* bfd-in2.h: Regenerate.
binutils/
	* objcopy.c (copy_file): Tidy setting of bfd compress flags.
	Expand comment.
gas/
	* write.c (compress_debug): Test bfd compress flags rather than
	flag_compress_debug.
	(write_object_file): Apply bfd_applicable_file_flags to compress
	debug flags added to output bfd.
include/
	* bfdlink.h (struct bfd_link_info): Delete compress_debug.
ld/
	* ld.h (ld_config_type): Add compress_debug.
	* emultempl/elf.em: Replace references to link_info.compress_debug
	with config.compress_debug.
	* lexsup.c (elf_static_list_options): Likewise.
	* ldmain.c (main): Likewise.  Apply bfd_applicable_file_flags
	to compress debug flags added to output bfd.
2022-12-07 13:15:29 +10:30
Alan Modra
7b5f66a118 Get rid of SEC_ELF_RENAME
SEC_ELF_RENAME is a flag used to effect section name changes when
compressing/decompressing zlib-gnu debug sections.  This can be
accomplished more directly in one of the objcopy specific bfd
functions.  Renaming for ld input is simplified too.  Ld input object
files always have BFD_DECOMPRESS set.

bfd/
	* compress.c (bfd_convert_section_size): Rename to..
	(bfd_convert_section_setup): ..this.  Handle objcopy renaming
	of compressed/decompressed debug sections.
	* elf.c (_bfd_elf_make_section_from_shdr): Only rename zdebug
	input for linker.
	(elf_fake_sections): Don't handle renaming of debug sections for
	objcopy here.
	* section.c (SEC_ELF_RENAME): Delete.
	* bfd-in2.h: Regenerate.
binutils/
	* objcopy.c (setup_section): Call bfd_convert_section_setup.
	Don't call bfd_convert_section_size.
2022-12-06 14:40:10 +10:30
Alan Modra
89dbeac746 Compression header enum
Define an enum instead of using ELFCOMPRESS_ZLIB and ELFCOMPRESS_ZSTD
in bfd and binutils, and move some functions from bfd.c to compress.c.
When looking at the COFF/PE debug compression support, I wondered
about extending it to support zstd.  I likely won't do that, but
the compression header ch_type field isn't just ELF specific if these
headers are to be used in COFF/PE too.

bfd/
	* bfd.c (bfd_update_compression_header),
	(bfd_check_compression_header, bfd_get_compression_header_size),
	(bfd_convert_section_size, bfd_convert_section_contents): Move to..
	* compress.c: ..here.
	(enum compression_type): New.  Use it throughout file.
	* elf.c (_bfd_elf_make_section_from_shdr): Replace uses of
	ELFCOMPRESS_ZLIB and ELFCOMPRESS_ZSTD with ch_compress_zlib and
	ch_compress_zstd.
	* bfd-in2.h: Regenerate.
binutils/
	* readelf.c (process_section_headers, dump_section_as_strings),
	(dump_section_as_bytes, load_specific_debug_section): Replace
	uses of ELFCOMPRESS_ZLIB and ELFCOMPRESS_ZSTD with
	ch_compress_zlib and ch_compress_zstd.
2022-12-06 12:11:28 +10:30
Martin Liska
76a2bcc6b8 testsuite: support mold linker
Mold linker demotes symbols like main to be local and the patch
adjusts expected output from nm.

Moreover, simplify the regex patterns.
2022-12-05 15:52:51 +01:00
Jan Beulich
07aeb917c4 Arm: .noinit and .persistent are not supported for Linux targets
Respective tests being run means guaranteed failures.
2022-12-05 13:50:07 +01:00
Andrew Burgess
2438b771ee opcodes/mips: use .word/.short for undefined instructions
While working on disassembler styling for MIPS, I noticed that
undefined instructions are printed by the disassembler as raw number
with no assembler directive prefix (e.g. without .word or .short).

I think adding something like .word, or .short, helps to make it
clearer the size of the value that is being displayed, and is inline
with what many of the other libopcode disassemblers do.

In this commit I've added the .word and .short directives, and updated
all the tests that I spotted that failed as a result.
2022-12-05 10:05:45 +00:00
Alan Modra
3d3af4ba39 PR29846, segmentation fault in objdump.c compare_symbols
Fixes a fuzzed object file problem where plt relocs were manipulated
in such a way that two synthetic symbols were generated at the same
plt location.  Won't occur in real object files.

	PR 29846
	PR 20337
	* objdump.c (compare_symbols): Test symbol flags to exclude
	section and synthetic symbols before attempting to check flavour.
2022-12-04 22:32:20 +10:30
Nick Clifton
ac57bf5547 Add Jan Beulich as an x86_64 maintainer. 2022-12-02 10:08:39 +00:00
Clément Chigot
de3b40320c binutils: improve holes detection in .debug_loclists.
The previous warnings about holes in .debug_loclists sections don't
take into account the headers of each CU and could include the locviews
if they precede the loclist.

The following warning can be triggered between two CU.
    ... <previous CU views> ...
    0000001d <End of list>

    0000002a v000000000000000 v000000000000000 location view pair
    0000002c v000000000000000 v000000000000000 location view pair

readelf: Warning: There is a hole [0x1e - 0x2e] in .debug_loclists section.
    0000002e v000000000000000 v000000000000000 views at 0000002a for:
    ...

But [0x1e - 0x2a] corresponds to the CU header and  [0x2a - 0x2e] are
the locviews.  Thus there is no hole here.

binutils/ChangeLog:

	* dwarf.c (display_debug_loc): Adjust holes detections for
	headers and locviews.
2022-12-01 15:49:03 +01: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
Alan Modra
b8d7a9572d PR10368, ISO 8859 mentioned as 7bit encoding in strings documentation
PR 10368
	* doc/binutils.texi (strings): Delete example of 7-bit encoding.
2022-11-28 20:16:59 +10:30
Martin Liska
8654c01f08 Revert "readelf: Do not require EI_OSABI for IFUNC."
This reverts commit ffbbab0b3a.
2022-11-25 14:00:26 +01:00
Martin Liska
ffbbab0b3a readelf: Do not require EI_OSABI for IFUNC.
PR 29718

binutils/ChangeLog:

	* readelf.c (get_symbol_type): Consider STT_GNU_IFUNC as
	reserved name.
2022-11-24 13:18:36 +01:00
Alan Modra
bde9f9d7e9 Tidy objdump printing of section size
* objdump.c (load_specific_debug_section): Use PRIx64 format.
2022-11-24 17:45:52 +10:30
Alan Modra
5ee755fabb Constify nm format array
* nm.c (formats, format): Make const.
2022-11-24 17:45:52 +10:30
Alan Modra
e6b6fad2fe PR22509 - Null pointer dereference on coff_slurp_reloc_table
This extends the commit 4581a1c7d3 fix to more targets, which
hardens BFD a little.  I think the real underlying problem was the
bfd_canonicalize_reloc call in load_specific_debug_section which
passed a NULL for "symbols".  Fix that too.

	PR 22509
bfd/
	* aoutx.h (swap_ext_reloc_out): Gracefully handle NULL symbols.
	* i386lynx.c (swap_ext_reloc_out): Likewise.
	* pdp11.c (pdp11_aout_swap_reloc_out): Likewise.
	* coff-tic30.c (reloc_processing): Likewise.
	* coff-tic4x.c (tic4x_reloc_processing): Likewise.
	* coff-tic54x.c (tic54x_reloc_processing): Likewise.
	* coff-z80.c (reloc_processing): Likewise.
	* coff-z8k.c (reloc_processing): Likewise.
	* ecoff.c (ecoff_slurp_reloc_table): Likewise.
	* som.c (som_set_reloc_info): Likewise.
binutils/
	* objdump.c (load_specific_debug_section): Pass syms to
	bfd_canonicalize_reloc.
2022-11-23 22:38:48 +10:30
Alan Modra
26c527e62e Don't use "long" in readelf for file offsets
The aim here is to improve readelf handling of large 64-bit object
files on LLP64 hosts (Windows) where long is only 32 bits.  The patch
changes more than just file offsets.  Addresses and sizes are also
changed to avoid "long".  Most places get to use uint64_t even where
size_t may be more appropriate, because that allows some overflow
checks to be implemented easily (*alloc changes).

	* dwarf.c (cmalloc, xcmalloc, xcrealloc, xcalloc2): Make nmemb
	parameter uint64_t.
	* dwarf.h: Update prototypes.
	(struct dwarf_section): Make num_relocs uint64_t.
	* elfcomm.c (setup_archive): Update error format.
	* elfcomm.h (struct archive_info): Make sym_size, longnames_size,
	nested_member_origin, next_arhdr_offset uint64_t.
	* readelf.c (struct filedata): Make archive_file_offset,
	archive_file_size, string_table_length, dynamic_addr,
	dynamic_nent, dynamic_strings_length, num_dynamic_syms,
	dynamic_syminfo_offset uint64_t.
	(many functions): Replace uses of "unsigned long" with
	"uint64_t" or "size_t".
2022-11-23 07:53:13 +10:30
Alan Modra
63cf857e24 Re: readelf: use fseeko64 or fseeko if possible
Replace the macros with a small wrapper function that verifies the fseek
offset arg isn't overlarge.

	* readelf.c (FSEEK_FUNC): Delete, replace uses with..
	(fseek64): ..this new function.
	(process_program_headers): Don't cast p_offset to long.
2022-11-23 07:51:41 +10:30
Michael Matz
d7229d6a56 binutils/configure.ac: integrate last change
Integrate back checks for fseeko{,64} into configure.ac, so
that regeneration works.

binutils/
	* configure.ac: Add fseeko, fseeko64 checks.
	* configure: Regenerate.
2022-11-22 14:39:39 +01:00
Brett Werling
d82e33decc readelf: use fseeko64 or fseeko if possible
Changes readelf to make use first of fseeko64 and then fseeko,
depending on which of those is available. If neither is available,
reverts to the previous behavior of using fseek.

This is necessary when building readelf for LLP64 systems, where a
long will only be 32 bits wide. If the elf file in question is >= 2 GiB,
that is greater than the max long value and therefore fseek will fail
indicating that the offset is negative. On such systems, making use of
fseeko64 or fseeko will result in the ability so seek past the 2 GiB
max long boundary.

Note that large archive handling in readelf remains to be fixed.
2022-11-22 08:19:27 +10:30
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
Alan Modra
69bfd1759d PR29799 heap buffer overflow in display_gdb_index dwarf.c:10548
PR 29799
	* dwarf.c (display_gdb_index): Typo fix.
2022-11-18 11:31:17 +10:30
Indu Bhagat
9968a11f9f binutils/NEWS: add text for SFrame support
ChangeLog:

	* binutils/NEWS: Add item for SFrame support.
2022-11-15 15:50:05 -08:00
Indu Bhagat
42b6953bba readelf/objdump: support for SFrame section
This patch adds support for SFrame in readelf and objdump. The arguments
of --sframe are optional for both readelf and objdump.

include/ChangeLog:

	* sframe-api.h (dump_sframe): New function declaration.

ChangeLog:

	* binutils/Makefile.am: Add dependency on libsframe for
	readelf and objdump.
	* binutils/Makefile.in: Regenerate.
	* binutils/doc/binutils.texi: Document --sframe=[section].
	* binutils/doc/sframe.options.texi: New file.
	* binutils/objdump.c: Add support for SFrame format.
	* binutils/readelf.c: Likewise.
	* include/sframe-api.h: Add new API for dumping .sframe
	section.
	* libsframe/Makefile.am: Add sframe-dump.c.
	* libsframe/Makefile.in: Regenerate.
	* libsframe/sframe-dump.c: New file.
2022-11-15 15:50:05 -08:00
Indu Bhagat
cf0e0a0ba9 bfd: linker: merge .sframe sections
The linker merges all the input .sframe sections.  When merging, the
linker verifies that all the input .sframe sections have the same
abi/arch.

The linker uses libsframe library to perform key actions on the
.sframe sections - decode, read, and create output data.  This
implies buildsystem changes to make and install libsframe before
libbfd.

The linker places the output .sframe section in a new segment of its
own: PT_GNU_SFRAME.  A new segment is not added, however, if the
generated .sframe section is empty.

When a section is discarded from the final link, the corresponding
entries in the .sframe section for those functions are also deleted.

The linker sorts the SFrame FDEs on start address by default and sets
the SFRAME_F_FDE_SORTED flag in the .sframe section.

This patch also adds support for generation of SFrame unwind
information for the .plt* sections on x86_64.  SFrame unwind info is
generated for IBT enabled PLT, lazy/non-lazy PLT.

The existing linker option --no-ld-generated-unwind-info has been
adapted to include the control of whether .sframe unwind information
will be generated for the linker generated sections like PLT.

Changes to the linker script have been made as necessary.

ChangeLog:

	* Makefile.def: Add install dependency on libsframe for libbfd.
	* Makefile.in: Regenerated.
	* bfd/Makefile.am: Add elf-sframe.c
	* bfd/Makefile.in: Regenerated.
	* bfd/bfd-in2.h (SEC_INFO_TYPE_SFRAME): Regenerated.
	* bfd/configure: Regenerate.
	* bfd/configure.ac: Add elf-sframe.lo.
	* bfd/elf-bfd.h (struct sframe_func_bfdinfo): New struct.
	(struct sframe_dec_info): Likewise.
	(struct sframe_enc_info): Likewise.
	(struct elf_link_hash_table): New member for encoded .sframe
	object.
	(struct output_elf_obj_tdata): New member.
	(elf_sframe): New access macro.
	(_bfd_elf_set_section_sframe): New declaration.
	* bfd/elf.c (get_segment_type): Handle new segment
	PT_GNU_SFRAME.
	(bfd_section_from_phdr): Likewise.
	(get_program_header_size): Likewise.
	(_bfd_elf_map_sections_to_segments): Likewise.
	* bfd/elf64-x86-64.c (elf_x86_64_link_setup_gnu_properties): Add
	contents to the .sframe sections or .plt* entries.
	* bfd/elflink.c (elf_section_ignore_discarded_relocs): Handle
	SEC_INFO_TYPE_SFRAME.
	(_bfd_elf_default_action_discarded): Handle .sframe section.
	(elf_link_input_bfd): Merge .sframe section.
	(bfd_elf_final_link): Write the output .sframe section.
	(bfd_elf_discard_info): Handle discarding .sframe section.
	* bfd/elfxx-x86.c (_bfd_x86_elf_size_dynamic_sections): Create
	.sframe section for .plt and .plt.sec.
	(_bfd_x86_elf_finish_dynamic_sections): Handle .sframe from
	.plt* sections.
	* bfd/elfxx-x86.h (PLT_SFRAME_FDE_START_OFFSET): New
	definition.
	(SFRAME_PLT0_MAX_NUM_FRES): Likewise.
	(SFRAME_PLTN_MAX_NUM_FRES): Likewise.
	(struct elf_x86_sframe_plt): New structure.
	(struct elf_x86_link_hash_table): New member.
	(struct elf_x86_init_table): New members for .sframe
	creation.
	* bfd/section.c: Add new definition SEC_INFO_TYPE_SFRAME.
	* binutils/readelf.c (get_segment_type): Handle new segment
	PT_GNU_SFRAME.
	* ld/ld.texi: Update documentation for
	--no-ld-generated-unwind-info.
	* ld/scripttempl/elf.sc: Support .sframe sections.
	* ld/Makefile.am (TESTSFRAMELIB): Use it.
	(check-DEJAGNU): Likewise.
	* ld/Makefile.in: Regenerated.
	* ld/configure.ac (TESTSFRAMELIB): Set to the .so or .a like TESTBFDLIB.
	* ld/configure: Regenerated.
	* bfd/elf-sframe.c: New file.

include/ChangeLog:

	* elf/common.h (PT_GNU_SFRAME): New definition.
	* elf/internal.h (struct elf_segment_map): Handle new segment
	type PT_GNU_SFRAME.

ld/testsuite/ChangeLog:

	* ld/testsuite/ld-bootstrap/bootstrap.exp: Add SFRAMELIB.
	* ld/testsuite/ld-aarch64/aarch64-elf.exp: Add new test
	  sframe-simple-1.
	* ld/testsuite/ld-aarch64/sframe-bar.s: New file.
	* ld/testsuite/ld-aarch64/sframe-foo.s: Likewise.
	* ld/testsuite/ld-aarch64/sframe-simple-1.d: Likewise.
	* ld/testsuite/ld-sframe/sframe-empty.d: New test.
	* ld/testsuite/ld-sframe/sframe-empty.s: New file.
	* ld/testsuite/ld-sframe/sframe.exp: New testsuite.
	* ld/testsuite/ld-x86-64/sframe-bar.s: New file.
	* ld/testsuite/ld-x86-64/sframe-foo.s: Likewise.
	* ld/testsuite/ld-x86-64/sframe-simple-1.d: Likewise.
	* ld/testsuite/ld-x86-64/sframe-plt-1.d: Likewise.
	* ld/testsuite/ld-x86-64/sframe-simple-1.d: Likewise.
	* ld/testsuite/ld-x86-64/x86-64.exp: Add new tests -
	  sframe-simple-1, sframe-plt-1.
	* ld/testsuite/lib/ld-lib.exp: Add new proc to check if
	  assembler supports SFrame section.
	* ld/testsuite/ld-sframe/discard.d: New file.
	* ld/testsuite/ld-sframe/discard.ld: Likewise.
	* ld/testsuite/ld-sframe/discard.s: Likewise.
2022-11-15 15:49:47 -08:00
Weimin Pan
19e559f1c9 libsframe: add the SFrame library
libsframe is a library that allows you to:
- decode a .sframe section
- probe and inspect a .sframe section
- encode (and eventually write) a .sframe section.

This library is currently being used by the linker, readelf, objdump.
This library will also be used by the SFrame unwinder which is still
to be upstream'd.

The file include/sframe-api.h defines the user-facing APIs for decoding,
encoding and probing .sframe sections. A set of error codes together
with their error message strings are also defined.

Endian flipping is performed automatically at read and write time, if
cross-endianness is detected.

ChangeLog:

	* Makefile.def: Add libsframe as new module with its
	dependencies.
	* Makefile.in: Regenerated.
	* binutils/Makefile.am: Add libsframe.
	* binutils/Makefile.in: Regenerated.
	* configure: Regenerated
	* configure.ac: Add libsframe to host_libs.
	* libsframe/Makefile.am: New file.
	* libsframe/Makefile.in: New file.
	* libsframe/aclocal.m4: New file.
	* libsframe/config.h.in: New file.
	* libsframe/configure: New file.
	* libsframe/configure.ac: New file.
	* libsframe/sframe-error.c: New file.
	* libsframe/sframe-impl.h: New file.
	* libsframe/sframe.c: New file.

include/ChangeLog:

	* sframe-api.h: New file.

testsuite/ChangeLog:

	* libsframe/testsuite/Makefile.am: New file.
	* libsframe/testsuite/Makefile.in: Regenerated.
	* libsframe/testsuite/libsframe.decode/Makefile.am: New
	  file.
	* libsframe/testsuite/libsframe.decode/Makefile.in:
	  Regenerated.
	* libsframe/testsuite/libsframe.decode/decode.exp: New file.
	* libsframe/testsuite/libsframe.encode/Makefile.am:
	  Likewise.
	* libsframe/testsuite/libsframe.encode/Makefile.in:
	  Regenerated.
	* libsframe/testsuite/libsframe.encode/encode.exp: New file.
	* libsframe/testsuite/libsframe.encode/encode-1.c: Likewise.
	* libsframe/testsuite/libsframe.decode/be-flipping.c: Likewise.
	* libsframe/testsuite/libsframe.decode/frecnt-1.c: Likewise.
	* libsframe/testsuite/libsframe.decode/frecnt-2.c: Likewise.
	* libsframe/testsuite/libsframe.decode/DATA-BE: New file.
	* libsframe/testsuite/libsframe.decode/DATA1: Likewise.
	* libsframe/testsuite/libsframe.decode/DATA2: Likewise.
2022-11-15 15:24:29 -08:00
Srinath Parvathaneni
b62fb887c6 [readelf] arm: Support for new pacbti unwind opcode 0xb5.
This patch adds readelf support for decoding the exception
table opcode "0xb5", which indicates to use effective vsp
as modifier for PAC validation as defined by EHABI
(https://github.com/ARM-software/abi-aa/releases/download/2022Q3/ehabi32.pdf
Section 10.3).

binutils/ChangeLog:

2022-11-07  Srinath Parvathaneni  <srinath.parvathaneni@arm.com>

        * readelf.c (decode_arm_unwind_bytecode): Add entry to decode opcode 0xb5.
2022-11-14 15:12:21 +00:00
Alan Modra
fadfefbf15 Re: objcopy renaming section with explicit flags
For now, xfail the new test.  Some header/aux-header rewriting is
required at the very least.

	* testsuite/binutils-all/rename-section-01.d: xfail xcoff.
2022-11-14 13:40:52 +10:30
Alan Modra
4f5c4fce88 objcopy renaming section with explicit flags
This tidies SEC_RELOC handling in bfd, in the process fixing a bug
with objcopy when renaming sections.

bfd/
	* reloc.c (_bfd_generic_set_reloc): Set/clear SEC_RELOC depending
	on reloc count.
	* elf64-sparc.c (elf64_sparc_set_reloc): Likewise.
binutils/
	* objcopy.c (copy_relocations_in_section): Remove now unnecessary
	clearing of SEC_RELOC.
	* testsuite/binutils-all/rename-section-01.d: New test.
	* testsuite/binutils-all/objcopy.exp: Run it.
gas/
	* write.c (size_seg): Remove unneccesary twiddle of SEC_RELOC.
	(write_relocs): Likewise.  Always call bfd_set_reloc.
2022-11-14 11:36:46 +10:30
Alan Modra
2d4989e98e Re: Fuzzed files in archives
Like commit ffbe89531c this avoids more silliness writing output
that is going to be deleted.  bfd_close and bfd_close_all_done differ
in that only the former calls _bfd_write_contents.

	* objcopy.c (copy_archive): Don't call bfd_close for elements
	that are going to be deleted, call bfd_close_all_done instead.
	Do the same for the archive itself.
2022-11-09 17:31:41 +10:30
Christophe Lyon
200164d467 configure: require libzstd >= 1.4.0
gas uses ZSTD_compressStream2 which is only available with libzstd >=
1.4.0, leading to build errors when an older version is installed.

This patch updates the check libzstd presence to check its version is
>= 1.4.0. However, since gas seems to be the only component requiring
such a recent version this may imply that we disable ZSTD support for
all components although some would still benefit from an older
version.

I ran 'autoreconf -f' in all directories containing a configure.ac
file, using vanilla autoconf-2.69 and automake-1.15.1. I noticed
several errors from autoheader in readline, as well as warnings in
intl, but they are unrelated to this patch.

This should fix some of the buildbots.

OK for trunk?

Thanks,

Christophe
2022-11-07 14:32:10 +01:00
H.J. Lu
d195b95c91 binutils: Run PR binutils/26160 test
Update expected PR binutils/26160 test output for readelf out change
and run PR binutils/26160 test.

	PR binutils/26160
	* testsuite/binutils-all/pr26160.r: Updated.
	* testsuite/binutils-all/readelf.exp: Run PR binutils/26160 test.
2022-11-04 16:47:43 -07:00
Nick Clifton
1da0b075ae Update release documentation with regard to uploading gprofng docs 2022-11-04 12:01:03 +00:00
Andrew Burgess
6576bffe6c opcodes/arm: add disassembler styling for arm
This commit adds disassembler styling for the ARM architecture.

The ARM disassembler is driven by several instruction tables,
e.g. cde_opcodes, coprocessor_opcodes, neon_opcodes, etc

The type for elements in each table can vary, but they all have one
thing in common, a 'const char *assembler' field.  This field
contains a string that describes the assembler syntax of the
instruction.

Embedded within that assembler syntax are various escape characters,
prefixed with a '%'.  Here's an example of a very simple instruction
from the arm_opcodes table:

  "pld\t%a"

The '%a' indicates a particular type of operand, the function
print_insn_arm processes the arm_opcodes table, and includes a switch
statement that handles the '%a' operand, and takes care of printing
the correct value for that instruction operand.

It is worth noting that there are many print_* functions, each
function handles a single *_opcodes table, and includes its own switch
statement for operand handling.  As a result, every *_opcodes table
uses a different mapping for the operand escape sequences.  This means
that '%a' might print an address for one *_opcodes table, but in a
different *_opcodes table '%a' might print a register operand.

Notice as well that in our example above, the instruction mnemonic
'pld' is embedded within the assembler string.  Some instructions also
include comments within the assembler string, for example, also from
the arm_opcodes table:

  "nop\t\t\t@ (mov r0, r0)"

here, everything after the '@' is a comment that is displayed at the
end of the instruction disassembly.

The next complexity is that the meaning of some escape sequences is
not necessarily fixed.  Consider these two examples from arm_opcodes:

  "ldrex%c\tr%12-15d, [%16-19R]"
  "setpan\t#%9-9d"

Here, the '%d' escape is used with a bitfield modifier, '%12-15d' in
the first instruction, and '%9-9d' in the second instruction, but,
both of these are the '%d' escape.

However, in the first instruction, the '%d' is used to print a
register number, notice the 'r' immediately before the '%d'.  In the
second instruction the '%d' is used to print an immediate, notice the
'#' just before the '%d'.

We have two problems here, first, the '%d' needs to know if it should
use register style or immediate style, and secondly, the 'r' and '#'
characters also need to be styled appropriately.

The final thing we must consider is that some escape codes result in
more than just a single operand being printed, for example, the '%q'
operand as used in arm_opcodes ends up calling arm_decode_shift, which
can print a register name, a shift type, and a shift amount, this
could end up using register, sub-mnemonic, and immediate styles, as
well as the text style for things like ',' between the different
parts.

I propose a three layer approach to adding styling:

(1) Basic state machine:

    When we start printing an instruction we should maintain the idea
    of a 'base_style'.  Every character from the assembler string will
    be printed using the base_style.

   The base_style will start as mnemonic, as each instruction starts
   with an instruction mnemonic.  When we encounter the first '\t'
   character, the base_style will change to text.  When we encounter
   the first '@' the base_style will change to comment_start.

   This simple state machine ensures that for simple instructions the
   basic parts, except for the operands themselves, will be printed in
   the correct style.

(2) Simple operand styling:

    For operands that only have a single meaning, or which expand to
    multiple parts, all of which have a consistent meaning, then I
    will simply update the operand printing code to print the operand
    with the correct style.  This will cover a large number of the
    operands, and is the most consistent with how styling has been
    added to previous architectures.

(3) New styling syntax in assembler strings:

    For cases like the '%d' that I describe above, I propose adding a
    new extension to the assembler syntax.  This extension will allow
    me to temporarily change the base_style.  Operands like '%d', will
    then print using the base_style rather than using a fixed style.

    Here are the two examples from above that use '%d', updated with
    the new syntax extension:

      "ldrex%c\t%{R:r%12-15d%}, [%16-19R]"
      "setpan\t%{I:#%9-9d%}"

    The syntax has the general form '%{X:....%}' where the 'X'
    character changes to indicate a different style.  In the first
    instruction I use '%{R:...%}' to change base_style to the register
    style, and in the second '%{I:...%}' changes base_style to
    immediate style.

    Notice that the 'r' and '#' characters are included within the new
    style group, this ensures that these characters are printed with
    the correct style rather than as text.

    The function decode_base_style maps from character to style.  I've
    included a character for each style for completeness, though only
    a small number of styles are currently used.

I have updated arm-dis.c to the above scheme, and checked all of the
tests in gas/testsuite/gas/arm/, and the styling looks reasonable.

There are no regressions on the ARM gas/binutils/ld tests that I can
see, so I don't believe I've changed the output layout at all.  There
were two binutils tests for which I needed to force the disassembler
styling off.

I can't guarantee that I've not missed some untested corners of the
disassembler, or that I might have just missed some incorrectly styled
output when reviewing the test results, but I don't believe I've
introduced any changes that could break the disassembler - the worst
should be some aspect is not styled correctly.
2022-11-01 09:32:13 +00:00
Nick Clifton
1bf074fb6b Updated Romainain translation for the binutils sub-directory and Swedish translations for the ld and opcodes sub-directories. 2022-10-31 14:42:47 +00:00
Nick Clifton
18bf56434d objdump: Add configure time option to enable colored disassembly output by default.
PR 29457
	* configure.ac: Add --enable-colored-disassembly.
	* objdump.c: Add --disassembler-color=terminal.
	* doc/binutils.texi (objdump): Document the new option.
	* NEWS: Mention new feature.
	* config.in: Regenerate in.
	* configure: Regenerate.
2022-10-31 09:35:16 +00:00
Alan Modra
28750e3b96 Pool section entries for DWP version 1
Ref: https://gcc.gnu.org/wiki/DebugFissionDWP?action=recall&rev=3

Fuzzers have found a weakness in the code stashing pool section
entries.  With random nonsensical values in the index entries (rather
than each index pointing to its own set distinct from other sets),
it's possible to overflow the space allocated, losing the NULL
terminator.  Without a terminator, find_section_in_set can run off the
end of the shndx_pool buffer.  Fix this by scanning the pool directly.

binutils/
	* dwarf.c (add_shndx_to_cu_tu_entry): Delete range check.
	(end_cu_tu_entry): Likewise.
	(process_cu_tu_index): Fill shndx_pool by directly scanning
	pool, rather than indirectly from index entries.
2022-10-30 19:30:42 +10:30
Alan Modra
c5d4b1b604 Fix small objcopy memory leak
* objcopy.c (copy_archive): Free l->name.
2022-10-29 15:23:58 +10:30
Lifang Xia
58b2ba6d88 binutils: Update my e-mail and Yunhai's e-mail
binutils/
	* MAINTAINERS(C-SKY): update e-mails of Lifang & Yunhai.
2022-10-28 10:13:56 +08:00
Alan Modra
ffbe89531c Fuzzed files in archives
Given a fuzzed object file in an archive with section size exceeding
file size, objcopy will report an error like "section size (0xfeffffff
bytes) is larger than file size (0x17a bytes)" but will create a copy
of the object laid out for the large section.  That means a large
temporary file on disk that is read back and written to the output
archive, which can take a while.  The output archive is then deleted
due to the error.  Avoid some of this silliness.

	* objcopy.c (copy_section): If section contents cannot be read
	set output section size to zero.
2022-10-27 17:56:51 +10:30
Alan Modra
4d664d5711 segfault in objdump.c reloc_at
bfd_canonicalize_reloc returns -1L on errors.

	* objdump.c (load_specific_debug_section): Properly handle
	error return from bfd_canonicalize_reloc.
2022-10-26 17:27:45 +10:30
Alan Modra
6175be4175 PR29720, objdump -S crashes if build-id is missing
PR 29720
	* objdump.c (slurp_file): Don't call debuginfod_find_source
	when build_id is NULL.
2022-10-26 15:34:53 +10:30
Fangrui Song
1f5a354612 readelf: support zstd compressed debug sections [PR 29640] 2022-10-21 09:33:38 -07:00
Nick Clifton
816be8d8b7 Add a note to the binutils/NEWS file about DCO signed contributions. 2022-10-21 11:58:47 +01:00
Tsukasa OI
b64dc199b0 binutils: Remove unused substitution PROGRAM
Unlike other substitution, this substitution of @PROGRAM@ was done in
binutils/Makefile and it was intended for binutils/cxxfilt.man.  @PROGRAM@
in binutils/cxxfilt.man is removed in the commit 0285c67df1 ("Automate
generate on man pages") in 2001 and @PROGRAM@ is ineffective since then.

Because PROGRAM substitution does nothing, removing this manual
substitution should be completely safe.

binutils/ChangeLog:

	* doc/local.mk: Remove unused substitution PROGRAM.
	* Makefile.in: Regenerate.
2022-10-20 00:42:13 +00:00
Alan Modra
2b06e59de0 Fix addr2line test for ppc64 elfv1 and mingw
* testsuite/binutils-all/addr2line.exp: Tidy.  For powerpc64
	arrange to pass --synthetic to nm, and extract .main and .fn
	symbol address for addr2line test.  Handle default executable
	extension on cygwin/mingw compilers.
2022-10-19 22:23:53 +10:30
Nick Clifton
f2ba47d69e Update MAINTAINERS file with details about accepting DCO signed contributions.
* MAINTAINERS: Add section on patches, copyright and DCO.
2022-10-19 12:39:20 +01:00
rupesh potharla
740a19d914 Binutils: Adding new testcase for addr2line.
* binutils/testsuite/config/default.exp: Set ADDR2LINE and ADDR2LINEFLAGS.
* binutils/testsuite/binutils-all/addr2line.exp: New file.
2022-10-19 12:35:23 +05:30
Alan Modra
61a457e5da e200 LSP support
It has bothered me for a long time that we have disabled LSP (and SPE)
tests.  Also the LSP test comment indicating there is something wrong
with get_powerpc_dialect.  I don't think there is.  Decoding of a VLE
instruction depends on whether the processor is in VLE mode (some
processors support both VLE and standard PPC) which we flag per
section with SHF_PPC_VLE for decoding when disassembling.

Background: Some versions of powerpc e200 have "Lightweight Signal
Processing" support, examples being e200z215 and e200z425.  As far as
I can tell, LSP and SPE are mutually exclusive.  This seems to be
borne out by insn encoding, for example LSP "zvaddih" and SPE "evaddw"
have the same encoding.  So none of the processor descriptions in
ppc_opts ought to have both PPC_OPCODE_LSP and PPC_OPCODE_SPE/2, if we
want disassembly to work.  I also could not find anything to suggest
that the LSP insns are enabled only in VLE mode, which means the LSP
insns should not be in vle_opcodes.

Fix all this by moving the LSP insns to their own table, and add a new
e200z2 cpu entry with LSP support, removing LSP from -me200z4 and from
-mvle.  (Yes, I know, as I said above some of the e200z4 processors
have LSP.  Others have SPE.  It's hard to choose good options.  Think
of z2 as meaning earlier, z4 as later.)  Also add -mlsp to allow
adding the LSP insn set.

include/
	* opcode/ppc.h (lsp_opcodes, lsp_num_opcodes): Declare.
	(LSP_OP_TO_SEG): Define.
binutils/
	* doc/binutils.texi: Update ppc docs.
gas/
	* config/tc-ppc.c (ppc_setup_opcodes): Add lsp opcodes to ppc_hash.
	* doc/c-ppc.texi: Document e200 and lsp.
	* testsuite/gas/ppc/lsp-checks.d: Assemble with -me200z2.
	* testsuite/gas/ppc/lsp.d: Likewise, disassembly too.
	* testsuite/gas/ppc/ppc.exp: Don't xfail lsp test.
opcodes/
	* ppc-dis.c (ppc_opts): Add e200z2 and lsp.  Don't set
	PPC_OPCODE_LSP for e200z4 or vle.
	(ppc_parse_cpu): Mutually exclude LSP and SPE.
	(LSP_OPCD_SEGS): Define.
	(lsp_opcd_indices): New array.
	(disassemble_init_powerpc): Init lsp_opcd_indices.
	(lookup_lsp): New function.
	(print_insn_powerpc): Call it.
	* ppc-opc.c: Include libiberty.h for ARRAY_SIZE and use throughout.
	(vle_opcodes): Move LSP opcodes to..
	(lsp_opcodes): ..here, and sort.
	(lsp_num_opcodes): New.
2022-10-14 22:07:18 +10:30
Nick Clifton
7fd882d4ad Fix objcopy's error message when it cannot add a .gnu_debuglink section because the section already exists.
PR 29665
	* objcopy.c (copy_object): Use the input filename when
	reporting that a .gnu_debuglink section already exists.
2022-10-12 15:33:47 +01:00
Nick Clifton
f54c53e9f4 Add ability to create reproducible source tarballs.
* src-release.sh: Add "-r <date>" option to create reproducible
	tarballs based upon a fixed timestamp of <date>.
	* binutils/README-how-to-make-a-release: Add a line showing how to
	use -r <date> when creating a binutils release.
2022-10-10 11:28:45 +01:00
Alan Modra
306253b2cf PR29647, objdump -S looping
Fuzzed input with this in .debug_line
  [0x0000003b]  Special opcode 115: advance Address by 8 to 0x401180 and Line by -2 to -1

	PR 29647
	* objdump.c (print_line): Don't decrement line number here..
	(dump_lines): ..do so here instead, ensuring loop terminates.
2022-10-05 14:53:41 +10:30
Nick Clifton
907b52f4ce readelf: DO not load section headers from file offset zero
* readelf.c (get_32bit_section_headers): Return false if the
	e_shoff field is zero.
	(get_64bit_section_headers): Likewise.
2022-10-03 13:19:21 +01:00
Tsukasa OI
7b4f240762 RISC-V: Assign DWARF numbers to vector registers
This commit assigns DWARF register numbers to vector registers (v0-v31:
96..127) to implement RISC-V DWARF Specification version 1.0-rc4
(now in the frozen state):

https://github.com/riscv-non-isa/riscv-elf-psabi-doc/releases/tag/v1.0-rc4

binutils/ChangeLog:

	* dwarf.c (dwarf_regnames_riscv): Assign DWARF register numbers
	96..127 to vector registers v0-v31.

gas/ChangeLog:

	* config/tc-riscv.c (tc_riscv_regname_to_dw2regnum): Support
	vector registers.
	* testsuite/gas/riscv/dw-regnums.s: Add vector registers to the
	DWARF register number test.
	* testsuite/gas/riscv/dw-regnums.d: Likewise.
2022-10-03 04:04:35 +00:00
Jan Beulich
3bf4994276 objcopy: avoid "shadowing" of remove() function name
remove() is a standard library function (declared in stdio.h), which
triggers a "shadows a global declaration" warning with some gcc versions.
2022-09-30 10:55:02 +02:00
liuzhensong
c4a7e6b562 LoongArch: Update ELF e_flags handling according to specification.
Update handling of e_flags according to the documentation
  update [1] (discussions [2][3]).

  Object file bitness is now represented in the EI_CLASS byte.
  The e_flags field is now interpreted as follows:

  e_flags[2:0]: Base ABI modifier

  - 0x1: soft-float
  - 0x2: single-precision hard-float
  - 0x3: double-precision hard-float

  e_flags[7:6]: ELF object ABI version

  - 0x0: v0
  - 0x1: v1

  [1]: https://github.com/loongson/LoongArch-Documentation/blob/main/docs/LoongArch-ELF-ABI-EN.adoc#e_flags-identifies-abi-type-and-version
  [2]: https://github.com/loongson/LoongArch-Documentation/pull/61
  [3]: https://github.com/loongson/LoongArch-Documentation/pull/47
2022-09-30 14:00:47 +08:00
Nick Clifton
be5f79aa39 The help document of size misses an option.
PR 29628
	* size.c (usage): Add -f.
	* doc/binutils.texi (size): Add -f.
2022-09-28 15:29:18 +01:00
Alan Modra
e2bae06cf9 Re: egrep in binutils
Multi-line patterns for grep are not supported on some old versions
of grep.

binutils/
	* embedspu.sh: Replace multi-line grep with sed.
ld/
	* testsuite/ld-elfvers/vers.exp: Replace multi-line grep with sed.
2022-09-28 23:01:56 +09:30
Alan Modra
67d1991b78 egrep in binutils
Apparently some distros have a nagging egrep that helpfully tells you
egrep is deprecated and to use "grep -E".  The nag message causes a ld
testsuite failure.  What's more the advice isn't that good.  The "-E"
flag may not be available with older versions of grep.

This patch fixes bare invocation of egrep within binutils, replacing
it with the autoconf $EGREP or with grep.

config/
	* lib-ld.m4 (AC_LIB_PROG_LD_GNU): Require AC_PROG_EGREP and
	invoke $EGREP.
	(AC_LIB_PROG_LD): Likewise.
binutils/
	* configure: Regenerate.
	* embedspu.sh: Replace egrep with grep.
gold/
	* testsuite/Makefile.am (flagstest_compress_debug_sections.check):
	Replace egrep with grep.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/bnd_ifunc_1.sh: Replace egrep with $EGREP.
	* testsuite/bnd_ifunc_2.sh: Likewise.
	* testsuite/bnd_plt_1.sh: Likewise.
	* testsuite/discard_locals_test.sh: Likewise.
	* testsuite/gnu_property_test.sh: Likewise.
	* testsuite/no_version_test.sh: Likewise.
	* testsuite/pr18689.sh: Likewise.
	* testsuite/pr26936.sh: Likewise.
	* testsuite/retain.sh: Likewise.
	* testsuite/split_i386.sh: Likewise.
	* testsuite/split_s390.sh: Likewise.
	* testsuite/split_x32.sh: Likewise.
	* testsuite/split_x86_64.sh: Likewise.
	* testsuite/ver_test_pr16504.sh: Likewise.
intl/
	* configure: Regenerate.
ld/
	* testsuite/ld-elfvers/vers.exp (test_ar): Replace egrep with grep.
2022-09-28 13:37:31 +09:30
Fangrui Song
2cac01e3ff binutils, gdb: support zstd compressed debug sections
PR29397 PR29563: Add new configure option --with-zstd which defaults to
auto.  If pkgconfig/libzstd.pc is found, define HAVE_ZSTD and support
zstd compressed debug sections for most tools.

* bfd: for addr2line, objdump --dwarf, gdb, etc
* gas: support --compress-debug-sections=zstd
* ld: support ELFCOMPRESS_ZSTD input and --compress-debug-sections=zstd
* objcopy: support ELFCOMPRESS_ZSTD input for
  --decompress-debug-sections and --compress-debug-sections=zstd
* gdb: support ELFCOMPRESS_ZSTD input.  The bfd change references zstd
  symbols, so gdb has to link against -lzstd in this patch.

If zstd is not supported, ELFCOMPRESS_ZSTD input triggers an error.  We
can avoid HAVE_ZSTD if binutils-gdb imports zstd/ like zlib/, but this
is too heavyweight, so don't do it for now.

```
% ld/ld-new a.o
ld/ld-new: a.o: section .debug_abbrev is compressed with zstd, but BFD is not built with zstd support
...

% ld/ld-new a.o --compress-debug-sections=zstd
ld/ld-new: --compress-debug-sections=zstd: ld is not built with zstd support

% binutils/objcopy --compress-debug-sections=zstd a.o b.o
binutils/objcopy: --compress-debug-sections=zstd: binutils is not built with zstd support

% binutils/objcopy b.o --decompress-debug-sections
binutils/objcopy: zstd.o: section .debug_abbrev is compressed with zstd, but BFD is not built with zstd support
...
```
2022-09-26 19:50:13 -07:00
Clément Chigot
fe441584bb binutils/testsuite: handle the different install names of c++filt
c++filt is always named cxxfilt in a build directory, but in a install
directory it would be named either cxxfilt or c++filt (depending on
the host).  Handle this last case in testsuite.

binutils/ChangeLog:
        *  testsuite/config/default.exp (CXXFILE): if cxxfilt not found,
        try c++filt.
2022-09-26 17:22:54 +02:00
Clément Chigot
e9d9235172 binutils/testsuite: skip gentestdlls related tests if missing
When launching the testsuite through runtest outside the build tree,
gentestdlls might not be available, this binary being created by make
check.
Simply untested the related tests instead of crashing.

binutils/ChangeLog:

	* testsuite/binutils-all/objdump.exp: Skip dotnet tests if
	gentestdlls is not available.
2022-09-26 17:20:11 +02:00
Alan Modra
544c561957 PKG_CHECK_MODULES for msgpack and jansson
Using AS_IF rather than shell "if" is recommended for conditionals
that contain non-trivial autoconf macros, because autoconf will emit
any AC_REQUIREd autoconf macro expansions outside of the conditional.
This makes them available elsewhere in the configure script.

binutils/
	* configure.ac (msgpack): Use "AS_IF" rather than "if".
	* configure: Regenerate.
ld/
	* configure.ac (jansson): Use "AS_IF" rather than "if".
	* configure: Regenerate.
2022-09-26 14:23:29 +09:30
Shihua
96462b0129 RISC-V: Implement Ztso extension
This patch support ZTSO extension. It will turn on the tso flag for elf_flags
once we have enabled Ztso extension.  This is intended to implement v0.1 of
the proposed specification which can be found in Chapter 25 of,
https://github.com/riscv/riscv-isa-manual/releases/download/draft-20220723-10eea63/riscv-spec.pdf.

bfd\ChangeLog:

        * elfnn-riscv.c (_bfd_riscv_elf_merge_private_bfd_data): Set TSO flag.
        * elfxx-riscv.c: Add Ztso's arch.

binutils\ChangeLog:

        * readelf.c (get_machine_flags): Set TSO flag.

gas\ChangeLog:

        * config/tc-riscv.c (riscv_set_tso): Ditto.
        (riscv_set_arch): Ditto.
        * testsuite/gas/riscv/ztso.d: New test.

include\ChangeLog:

        * elf/riscv.h (EF_RISCV_TSO): Ditto.
2022-09-21 11:43:35 +08:00
Nick Clifton
1588d98bab Stop strip from complaining about empty note sections when stripping a binary for a second time.
* objcopy.c (copy_object): Do not issue a warning message when
	encountering empty .gnu.build.attribute sections.
2022-09-20 11:46:32 +01:00
Nick Clifton
7e19db932c New Serbian translations for various binutils sub-directories. 2022-09-20 11:33:16 +01:00
Zeke Lu
6af418600c Bug 29580 - typo in warning message: .note.gnu.build-id data size is too bug 2022-09-20 11:19:06 +01:00
Tsukasa OI
d0975d8002 bfd, binutils, gas: Remove/mark unused variables
Clang generates a warning on unused (technically, written but not read
thereafter) variables.  By the default configuration (with "-Werror"), it
causes a build failure (unless "--disable-werror" is specified).

This commit adds ATTRIBUTE_UNUSED attribute to some of them, which means
they are *possibly* unused (can be used but no warnings occur when
unused) and removes others.

bfd/ChangeLog:

	* elf32-lm32.c (lm32_elf_size_dynamic_sections): Mark unused
	rgot_count variable.
	* elf32-nds32.c (elf32_nds32_unify_relax_group): Remove unused
	count variable.
	* mmo.c (mmo_scan): Mark unused lineno variable.

binutils/ChangeLog:

	* windmc.c (write_rc): Remove unused i variable.

gas/ChangeLog:

	* config/tc-riscv.c (riscv_ip): Remove unused argnum variable.

ld/ChangeLog:

	* pe-dll.c (generate_reloc): Remove unused bi and page_count
	variables.
2022-09-15 10:46:02 +00:00
Rupesh Potharla
e959744eca Binutils: Readelf testcase failing with clang
* testsuite/binutils-all/readelf.exp (readelf_wi_test): Extend
	regexps to allow for output genreated by the Clang compiler.
2022-09-14 10:27:38 +01:00
Tsukasa OI
491cf3178f bfd: Stop using -Wstack-usage=262144 when built with Clang
Some components of GNU Binutils will pass "-Wstack-usage=262144" when
"GCC >= 5.0" is detected.  However, Clang does not support "-Wstack-usage",
despite that related configuration part in bfd/warning.m4 handles the latest
Clang (15.0.0 as of this writing) as "GCC >= 5.0".

The option "-Wstack-usage" was ignored when the first version of Clang is
released but even this "ignoring" behavior is removed before Clang 4.0.0.
So, if we give Clang "-Wstack-usage=262144", it generates a warning, making
the build failure.

This commit checks "__clang__" macro to prevent adding the option if the
compiler is identified as Clang.

bfd/ChangeLog:

	* warning.m4: Stop appending "-Wstack-usage=262144" option when
	compiled with Clang.
	* configure: Regenerate.

binutils/ChangeLog:

	* configure: Regenerate.

gas/ChangeLog:

	* configure: Regenerate.

gold/ChangeLog:

	* configure: Regenerate.

gprof/ChangeLog:

	* configure: Regenerate.

ld/ChangeLog:

	* configure: Regenerate.

opcodes/ChangeLog:

	* configure: Regenerate.
2022-09-14 05:42:17 +00:00
Aaron Merey
e9a241e87b objdump: '-S' should trigger search for separate debuginfo.
Add with_source_code to the command line options that trigger
might_need_separate_debug_info and dump_any_debugging.  This helps
'objdump -S' download missing files via debuginfod without the need for
specifying extra command line options like '-L'.
2022-09-13 09:29:09 -04:00
Peter Bergner
29a6701e53 ppc: Document the -mfuture and -Mfuture options and make them usable
The -mfuture and -Mfuture options which are used for adding potential
new ISA instructions were not documented.  They also lacked a bitmask
so new instructions could not be enabled by those options.  Fixed.

binutils/
	* doc/binutils.texi: Document -Mfuture.

gas/
	* config/tc-ppc.c: Document -mfuture
	* doc/c-ppc.texi: Likewise.

include/
	* opcode/ppc.h (PPC_OPCODE_FUTURE): Define.

opcodes/
	* ppc-dis.c (ppc_opts) <future>: Use it.
	* ppc-opc.c (FUTURE): Define.
2022-09-12 14:56:20 -05: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
Nick Clifton
2caffd34df i686-w64-mingw32-objdump -WL returns incorrect file paths
PR 29523
	* dwarf.c (display_debug_lines_decoded): Correctly handle DWARF-5
	directory and filename tables.
2022-09-08 09:56:39 +01:00
Aaron Merey
d647c797b7 Add debuginfod support for objdump -S
Currently objdump -S is not able to make use files downloaded from debuginfod.
This is due to bfd_find_nearest_line_discriminator being unable to locate any
separate debuginfo files in the debuginfod cache. Additionally objdump lacked
a call to debuginfod_find_source in order to download missing source files.

Fix this by using bfd_find_nearest_line_with_alt instead of
bfd_find_nearest_line_discriminator. Also add a call to
debuginfod_find_source in order to download missing source files.

Co-authored-by: Nick Clifton <nickc@redhat.com>
2022-09-06 10:43:07 -04:00
Nick Clifton
f4492fb683 dllwrap, windres and dlltools use mktemp, which should be avoided
PR 29534
	* dllwrap.c: Replace uses of choose_temp_base() with
	make_temp_file().
	* dlltool.c: Likewise.
	* resrc.c: Likewise.
2022-09-01 14:51:50 +01:00
Nick Clifton
25ee24d990 Add an option to dlltool to allow the creation of deterministic libraries.
PR 29489
	* dlltool.c (deterministic): New variable.
	(gen_lib_file): If deterministic is true set the
	BFD_DETERMINISTIC_OUTPUT flag.
	(usage): Mention --deterministic-libraries and
	--non-deterministic-libraries.
	(long_options): Add new options.
	(main): Parse new options.
	* doc/binutils.texi: Document the new options.
	* NEWS: Mention the new feature.
2022-08-23 09:54:52 +01:00
Nelson Chu
179390a375 binutils: Updated my email address.
binutils/
    * MAINTAINERS (RISC-V): Updated my email address.
2022-08-23 13:09:56 +08:00
Nick Clifton
b3ea2010cd Fix compile time warning from Clang about error messages not being printed safely. 2022-08-22 16:19:17 +01:00
Nick Clifton
521f726815 Have readelf warn users if it is asked to decode a LLVM bitcode file or a golang object file.
* readelf.c (check_magic_number): New function.  Checks the magic
	bytes at the start of a file.  If they are not the ELF format
	magic values, then attempts to generate a helpful error message.
	(process_file_header): Call check_magic_number.
2022-08-22 11:15:40 +01:00
Alan Modra
450da4bd38 PR29362, some binutils memory leaks
2022-08-16  Alan Modra  <amodra@gmail.com>
	    Cunlong Li  <shenxiaogll@163.com>

	PR 29362
	* dwarf.c (free_debug_information): New function, extracted..
	(free_debug_memory): ..from here.
	(process_debug_info): Use it when before clearing out unit
	debug_information.  Clear all fields.
	* objcopy.c (delete_symbol_htabs): New function.
	(main): Call it via xatexit.
	(copy_archive): Free "dir".
	* objdump.c (free_debug_section): Free reloc_info.
2022-08-16 00:25:10 +09:30
Alan Modra
cc44342012 readelf: print 0x0 as 0, and remove trailing spaces
This changes readelf output a little, removing the 0x prefix on hex
output when the value is 0, except in cases where a fixed field
width is shown.  %#010x is not a good replacement for 0x%08x.
2022-08-13 14:11:27 +09:30
Alan Modra
31e5a3a380 Make dwarf_vma uint64_t
This replaces dwarf_vma, dwarf_size_type and dwarf_signed_vma with
uint64_t and int64_t everywhere.  The patch also gets rid of
DWARF_VMA_FMT since we can't use that with uint64_t, and all of the
configure support for deciding the flavour of HOST_WIDEST_INT.
dwarf_vmatoa also disappears, replacing most uses with one of
PRIx64, PRId64 or PRIu64.  Printing of size_t and ptrdiff_t values
now use %z and %t rather than by casting to unsigned long.  Also,
most warning messages that used 0x%lx or similar now use %#lx and a
few that didn't print the 0x hex prefix now also use %#.  The patch
doesn't change normal readelf output, except in odd cases where values
previously might have been truncated.
2022-08-13 14:11:27 +09:30
Alan Modra
625d49fce7 Don't use bfd_vma in readelf.c
This replaces bfd_vma with uint64_t in readelf, defines BFD64
unconditionally, removes tests of BFD64 and sizeof (bfd_vma), and
removes quite a few now unnecessary casts.
2022-08-13 14:11:27 +09:30
Alan Modra
be7d229ad4 Don't use bfd_size_type in readelf.c and dwarf.c
Replacing bfd_size_type with dwarf_size_type or uint64_t is mostly
cosmetic.  The point of the change is to avoid use of a BFD type
in readelf, where we'd like to keep as independent of BFD as
possible.  Also, the patch is a step towards using standard types.
2022-08-13 14:11:27 +09:30
Alan Modra
928c411de4 Replace elf_vma with uint64_t
This patch replaces all uses of elf_vma with uint64_t, removes
tests of sizeof (elf_vma), and does a little tidying of
byte_get_little_endian and byte_get_big_endian.
2022-08-13 14:11:27 +09:30
Andrew Burgess
daf2618a91 objdump: fix extended (256) disassembler colors
After commit:

  commit a88c79b770
  Date:   Tue Aug 9 14:57:48 2022 +0100

      Default to enabling colored disassembly if output is to a terminal.

The 256 extended-color support for --disassembler-color was broken.
This is fixed in this commit.

	PR 29457
	* objdump (objdump_styled_sprintf): Check disassembler_color
	against an enum value, don't treat it as a bool.
2022-08-10 17:11:55 +01:00
Youling Tang
31f6009538 bfd: Add support for LoongArch64 EFI (efi-*-loongarch64).
This adds support for efi-loongarch64 by virtue of adding a new PEI target
pei-loongarch64.  This is not a full target and only exists to support EFI at
this time.

This means that this target does not support relocation processing and is mostly
a container format.  This format has been added to elf based loongarch64 targets
such that efi images can be made natively on Linux.

However this target is not valid for use with gas but only with objcopy.

We should't limit addresses to 32-bits for 64-bit vma, otherwise there will be
"RVA truncated" error when using objcopy on loongarch64.

With these changes the resulting file is recognized as an efi image.

Any magic number is based on the Microsoft PE specification [1].

The test results are as follows:
$ make check-binutils RUNTESTFLAGS='loongarch64.exp'
  PASS: Check if efi app format is recognized

$ objdump -h -f tmpdir/loongarch64copy.o
  tmpdir/loongarch64copy.o:     file format pei-loongarch64
  architecture: Loongarch64, flags 0x00000132:
  EXEC_P, HAS_SYMS, HAS_LOCALS, D_PAGED
  start address 0x0000000000000000

  Sections:
  Idx Name          Size      VMA               LMA               File off  Algn
    0 .text         0000003c  00000000200000b0  00000000200000b0  00000200  2**2
                    CONTENTS, ALLOC, LOAD, READONLY, CODE

[1] https://docs.microsoft.com/en-us/windows/win32/debug/pe-format

bfd:
  * .gitignore (pe-loongarch64igen.c): New.
  * Makefile.am (pei-loongarch64.lo, pe-loongarch64igen.lo, pei-loongarch64.c,
  pe-loongarch64igen.c): Add support.
  * Makefile.in: Likewise.
  * bfd.c (bfd_get_sign_extend_vma): Add pei-loongarch64.
  * coff-loongarch64.c: New file.
  * coffcode.h (coff_set_arch_mach_hook, coff_set_flags,
  coff_write_object_contents) Add loongarch64 (loongarch64_pei_vec) support.
  * config.bfd: Likewise.
  * configure: Likewise.
  * configure.ac: Likewise.
  * libpei.h (GET_OPTHDR_IMAGE_BASE, PUT_OPTHDR_IMAGE_BASE,
  GET_OPTHDR_SIZE_OF_STACK_RESERVE, PUT_OPTHDR_SIZE_OF_STACK_RESERVE,
  GET_OPTHDR_SIZE_OF_STACK_COMMIT, PUT_OPTHDR_SIZE_OF_STACK_COMMIT,
  GET_OPTHDR_SIZE_OF_HEAP_RESERVE, PUT_OPTHDR_SIZE_OF_HEAP_RESERVE,
  GET_OPTHDR_SIZE_OF_HEAP_COMMIT, PUT_OPTHDR_SIZE_OF_HEAP_COMMIT,
  GET_PDATA_ENTRY, _bfd_peLoongArch64_bfd_copy_private_bfd_data_common,
  _bfd_peLoongArch64_bfd_copy_private_section_data,
  _bfd_peLoongArch64_get_symbol_info, _bfd_peLoongArch64_only_swap_filehdr_out,
  _bfd_peLoongArch64_print_private_bfd_data_common,
  _bfd_peLoongArch64i_final_link_postscript,
  _bfd_peLoongArch64i_only_swap_filehdr_out, _bfd_peLoongArch64i_swap_aouthdr_in,
  _bfd_peLoongArch64i_swap_aouthdr_out, _bfd_peLoongArch64i_swap_aux_in,
  _bfd_peLoongArch64i_swap_aux_out, _bfd_peLoongArch64i_swap_lineno_in,
  _bfd_peLoongArch64i_swap_lineno_out, _bfd_peLoongArch64i_swap_scnhdr_out,
  _bfd_peLoongArch64i_swap_sym_in, _bfd_peLoongArch64i_swap_sym_out,
  _bfd_peLoongArch64i_swap_debugdir_in, _bfd_peLoongArch64i_swap_debugdir_out,
  _bfd_peLoongArch64i_write_codeview_record,
  _bfd_peLoongArch64i_slurp_codeview_record,
  _bfd_peLoongArch64_print_ce_compressed_pdata): New.
  * peXXigen.c (_bfd_XXi_swap_aouthdr_in, _bfd_XXi_swap_aouthdr_out,
  _bfd_XXi_swap_scnhdr_out, pe_print_pdata, _bfd_XX_print_private_bfd_data_common,
  _bfd_XX_bfd_copy_private_section_data, _bfd_XXi_final_link_postscript):
  Support COFF_WITH_peLoongArch64,
  * pei-loongarch64.c: New file.
  * peicode.h (coff_swap_scnhdr_in, pe_ILF_build_a_bfd, pe_ILF_object_p):
  Support COFF_WITH_peLoongArch64.
  (jtab): Add dummy entry that traps.
  * targets.c (loongarch64_pei_vec): New.

binutils
  * testsuite/binutils-all/loongarch64/loongarch64.exp: New file.
  * testsuite/binutils-all/loongarch64/pei-loongarch64.d: New test.
  * testsuite/binutils-all/loongarch64/pei-loongarch64.s: New test.

include
  * coff/loongarch64.h: New file.
  * coff/pe.h (IMAGE_FILE_MACHINE_LOONGARCH64): New.

Signed-off-by: Youling Tang <tangyouling@loongson.cn>
2022-08-10 09:26:25 +08:00
Nick Clifton
a88c79b770 Default to enabling colored disassembly if output is to a terminal.
PR 29457
	* objdump.c (disassembler_color): Change type to an enum.
	(disassembler_extended_color): Remove.
	(usage): Update.
	(objdump_color_for_assembler_style): Update.
	(main): Update initialisation of disassembler_color.  If not
	initialised via a command line option, set based upon terminal
	output.
	* doc/binutils.texi: Update description of disassmbler-color
	option.
	* testsuite/binutils-all/arc/objdump.exp: Add
	--disassembler-color=off option when disassembling.
	* testsuite/binutils-all/arm/objdump.exp: Likewise.
2022-08-09 14:57:48 +01:00
Nick Clifton
e838f9c284 Add a link to the NEWS files in the release announcement email. 2022-08-08 11:45:40 +01:00
Alan Modra
578a7392c3 objcopy section alignment
bfd_set_section_alignment currently always returns true.  This patch
changes it to return false on silly alignment values, avoiding yet
another way to trigger ubsan errors like coffcode.h:3192:12: runtime
error: shift exponent 299 is too large for 32-bit type 'int'.  We'll
catch that one in objcopy.c:setup_sections.  However, setup_sections
gives up on other setup operations that are necessary even after an
error of some sort.  Change that to keep going, which might change the
error message but that shouldn't matter in the least.

bfd/
	* section.c (bfd_set_section_alignment): Return false and
	don't set alignment_power for stupidly large alignments.
	* bfd-in2.h: Regenerate.
	* coffcode.h (coff_compute_section_file_positions): Don't use
	an int constant when calculating alignment.
binutils/
	* objcopy.c (setup_section): Keep on going after hitting
	non-fatal errors.
2022-08-06 18:43:24 +09:30