Age | Commit message (Collapse) | Author | Files | Lines |
|
The target_defaulted field in BFD is set to true if the target isn't
specified. After
commit 717a38e9a02109fcbcb18bb2ec3aa251e2ad0a0d
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Sun May 4 05:12:46 2025 +0800
strip: Add GCC LTO IR support
the target is set to "plugin" if BFD supports plugin when the target
isn't specified nor default. Update strip to check the input target,
instead of the target_defaulted field in input BFD.
PR binutils/33230
* objcopy.c (copy_object): Add a bool argument, target_defaulted,
to indicate if the input target isn't specified nor default.
Check it instead of ibfd->target_defaulted.
(copy_archive): Add a bool argument, target_defaulted, and pass
it to copy_object.
(copy_file): Set target_defaulted to true if the input target
isn't specified and pass it to copy_archive and copy_object.
* testsuite/binutils-all/x86-64/pr33230.obj.bz2: New file.
* testsuite/binutils-all/x86-64/x86-64.exp: Run PR binutils/33230
tests.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
|
|
|
|
Fix PR binutils/33186 - No SFrame dump if section name is not .sframe
When the section name is not ".sframe", ensure that readelf and objdump
are able to dump a section of type SHT_GNU_SFRAME and not fail if the
user specifies the new section name.
For objdump, in dump_dwarf_section (), use the match string of ".sframe"
to find the corresponding debug_displays[] item for SFrame section.
Doing this ensures that any call to dump_dwarf_section () with the
section pointing to the SFrame section (with name possibly different
from ".sframe") will successfully dump the SFrame section.
If the SFrame section is named anything but ".sframe", and user does not
specify the name of the SFrame section either, the documented behaviour
is that the default section name is assumed to be ".sframe". So the
following (albeit counter intuitive) is expected at this time:
$ readelf -S sort | grep sframe
[NN] .sframe2 GNU_SFRAME 0000000000NNNNNN 0000NNNN
(Note section name .sframe2).
$ objdump --sframe sort
sort: file format elf64-x86-64
No .sframe section present
(Similarly for readelf as well).
For objdump, set dump_sframe_section_name to ".sframe" if user specifies
no section name. In the error checking done in dump_sframe_section, add
the case when user specifies a valid section name but one that does not
contain SFrame section data. For sections generated with Binutils >=
2.45, this can be checked with section type of SHT_GNU_SFRAME.
Previously these sections were SHT_PROGBITS with name ".sframe".
Similar changes in readelf.
Add a test each for objdump and readelf to dump a renamed section. Use
gas_sframe_check to limit the execution of these tests only when a gas
supporting SFrame format is present.
binutils/
PR binutils/33186
* objdump.c (dump_dwarf_section): Set match to ".sframe" which
corresponds to the name in the debug_displays[] entry for
SFrame section.
(dump_sframe_section): Check if the user specified section name
contains SFrame data.
(main): Set default section name to ".sframe".
* readelf.c (display_debug_section): Adjust checks to find the
debug_diplays[] item for the input arg SFrame section.
Use id instead of i, as it is more readable.
binutils/testsuite/
PR binutils/33186
* binutils-all/x86-64/objdump-sframe-01.d: New test.
* binutils-all/x86-64/readelf-sframe-01.d: New test.
* binutils-all/x86-64/sframe-func.s: New test.
|
|
commit 717a38e9a02109fcbcb18bb2ec3aa251e2ad0a0d
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Sun May 4 05:12:46 2025 +0800
strip: Add GCC LTO IR support
added "-R .gnu.lto_.*" to strip to remove all GCC LTO sections. When
"-R .gnu.lto_.*" is used, the plugin target is ignored so that all LTO
sections are stripped as the regular sections. It works for the slim
GCC LTO IR since the GCC LTO IR is stored in the regular sections. When
the plugin target is ignored, the GCC LTO IR can be recognized as the
normal object files. But it doesn't work for the slim LLVM IR which
is stored in a standalone file.
1. Add bfd_check_format_matches_lto and bfd_check_format_lto to take an
argument, lto_sections_removed, to indicate if all LTO sections should
be removed.
2. Update strip to always enable the plugin target so that the plugin
target is enabled when checking for bfd_archive.
3. Update strip to ignore the plugin target for bfd_object when all LTO
sections should be removed. If the object is unknown, copy it as an
unknown file without any messages.
4. Treat the "-R .llvm.lto" strip option as removing all LTO sections.
bfd/
PR binutils/33198
* format.c (bfd_check_format_lto): New function.
(bfd_check_format): Call bfd_check_format_matches_lto.
(bfd_check_format_matches): Renamed to ...
(bfd_check_format_matches_lto): This. Add an argument,
lto_sections_removed, to indicate if all LTO sections should be
removed and don't match the plugin target if lto_sections_removed
is true.
(bfd_check_format_matches): Call bfd_check_format_matches_lto.
* bfd-in2.h: Regenerated.
binutils/
PR binutils/33198
* objcopy.c (copy_archive): Call bfd_check_format_lto, instead
of bfd_check_format, and pass lto_sections_removed. Remove the
non-fatal message on unknown element since it will be copied as
an unknown file.
(copy_file): Don't check lto_sections_removed when enabling LTO
plugin in strip.
(copy_file): Ignore the plugin target first if all LTO sections
should be removed. Try with the plugin target next if ignoring
the plugin target failed to match the format.
(strip_main): Also set lto_sections_removed for -R .llvm.lto.
* testsuite/binutils-all/x86-64/pr33198.c: New file.
* testsuite/binutils-all/x86-64/x86-64.exp (run_pr33198_test):
New.
Run binutils/33198 tests.
* testsuite/lib/binutils-common.exp (llvm_plug_opt): New.
(CLANG_FOR_TARGET): New. Set to "clang" for native build if
"clang -v" reports "clang version".
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
|
|
|
|
NaCl has been deprecated:
https://developer.chrome.com/docs/native-client/migration/
It is now in the process of being removed from llvm:
https://github.com/llvm/llvm-project/pull/133661
Remove NaCl/arm target support from bfd, binutils, gas and ld.
bfd/
* Makefile.am (BFD32_BACKENDS): Remove elf-nacl.lo.
(BFD32_BACKENDS_CFILES): Remove elf-nacl.c.
(SOURCE_HFILES): Remove elf-nacl.h.
* Makefile.in: Regenerated.
* config.bfd: Add *-*-nacl* to obsolete targets.
Remove *-*-nacl* targets.
* configure.ac: Remove nacl target vectors.
* elf-bfd.h (elf_target_os): Remove is_nacl.
* elf-nacl.c: Removed.
* elf-nacl.h: Likewise.
* elf32-arm.c: Don't include "elf-nacl.h".
(elf32_arm_nacl_plt0_entry): Removed.
(elf32_arm_nacl_plt_entry): Likewise.
(elf32_arm_stub_long_branch_arm_nacl): Likewise.
(elf32_arm_stub_long_branch_arm_nacl_pic): Likewise.
(arm_movw_immediate): Likewise.
(arm_movt_immediate): Likewise.
(arm_nacl_put_plt0): Likewise.
(elf32_arm_nacl_link_hash_table_create): Likewise.
(elf32_arm_nacl_modify_segment_map): Likewise.
(elf32_arm_nacl_final_write_processing): Likewise.
(elf32_arm_nacl_plt_sym_val): Likewise.
(elf32_arm_stub_cmse_branch_thumb_only): Remove
long_branch_arm_nacl and long_branch_arm_nacl_pic entries.
(arm_type_of_stub): Updated.
(elf32_arm_create_or_find_stub_sec): Likewise.
(arm_stub_required_alignment): Likewise.
(elf32_arm_allocate_plt_entry): Likewise.
(elf32_arm_populate_plt_entry): Likewise.
(elf32_arm_finish_dynamic_sections): Likewise.
(elf32_arm_output_plt_map_1): Likewise.
(elf32_arm_output_arch_local_syms): Likewise.
Remove elf32_arm_nacl_bed.
* targets.c: Remove NaCl target vectors.
* bfd-in2.h: Regenerated.
* configure: Likewise.
* po/SRC-POTFILES.in: Likewise.
binutils/
* NEWS: Mention NaCl target support removal.
* testsuite/lib/binutils-common.exp: Remove NaCl target support.
gas/
* NEWS: Mention NaCl target support removal.
* configure.tgt: Likewise.
* config/tc-arm.c: Remove NaCl target support.
* testsuite/gas/arm/any-armv8m.d: Likewise.
* testsuite/gas/arm/any-cmse-main.d: Likewise.
* testsuite/gas/arm/any-cmse.d: Likewise.
* testsuite/gas/arm/any-idiv.d: Likewise.
* testsuite/gas/arm/arch4t-eabi.d: Likewise.
* testsuite/gas/arm/arch4t.d: Likewise.
* testsuite/gas/arm/armv8m.base-idiv.d: Likewise.
* testsuite/gas/arm/armv9-a_arch.d: Likewise.
* testsuite/gas/arm/attr-abi-hardfp-use-0.d: Likewise.
* testsuite/gas/arm/attr-abi-hardfp-use-1.d: Likewise.
* testsuite/gas/arm/attr-abi-hardfp-use-2.d: Likewise.
* testsuite/gas/arm/attr-abi-hardfp-use-3.d: Likewise.
* testsuite/gas/arm/attr-any-armv4t.d: Likewise.
* testsuite/gas/arm/attr-any-thumbv6.d: Likewise.
* testsuite/gas/arm/attr-arch-assumption.d: Likewise.
* testsuite/gas/arm/attr-cpu-directive.d: Likewise.
* testsuite/gas/arm/attr-default.d: Likewise.
* testsuite/gas/arm/attr-empty-string.d: Likewise.
* testsuite/gas/arm/attr-ext-fpv5-d16.d: Likewise.
* testsuite/gas/arm/attr-ext-fpv5.d: Likewise.
* testsuite/gas/arm/attr-ext-idiv.d: Likewise.
* testsuite/gas/arm/attr-ext-mp.d: Likewise.
* testsuite/gas/arm/attr-ext-neon-fp16.d: Likewise.
* testsuite/gas/arm/attr-ext-neon-vfpv3.d: Likewise.
* testsuite/gas/arm/attr-ext-neon-vfpv4.d: Likewise.
* testsuite/gas/arm/attr-ext-sec.d: Likewise.
* testsuite/gas/arm/attr-ext-vfpv3-d16-fp16.d: Likewise.
* testsuite/gas/arm/attr-ext-vfpv3-d16.d: Likewise.
* testsuite/gas/arm/attr-ext-vfpv3-fp16.d: Likewise.
* testsuite/gas/arm/attr-ext-vfpv3.d: Likewise.
* testsuite/gas/arm/attr-ext-vfpv3xd-fp.d: Likewise.
* testsuite/gas/arm/attr-ext-vfpv3xd.d: Likewise.
* testsuite/gas/arm/attr-ext-vfpv4-d16.d: Likewise.
* testsuite/gas/arm/attr-ext-vfpv4-sp-d16.d: Likewise.
* testsuite/gas/arm/attr-ext-vfpv4.d: Likewise.
* testsuite/gas/arm/attr-march-all.d: Likewise.
* testsuite/gas/arm/attr-march-armv1.d: Likewise.
* testsuite/gas/arm/attr-march-armv2.d: Likewise.
* testsuite/gas/arm/attr-march-armv2a.d: Likewise.
* testsuite/gas/arm/attr-march-armv2s.d: Likewise.
* testsuite/gas/arm/attr-march-armv3.d: Likewise.
* testsuite/gas/arm/attr-march-armv3m.d: Likewise.
* testsuite/gas/arm/attr-march-armv4.d: Likewise.
* testsuite/gas/arm/attr-march-armv4t.d: Likewise.
* testsuite/gas/arm/attr-march-armv4txm.d: Likewise.
* testsuite/gas/arm/attr-march-armv4xm.d: Likewise.
* testsuite/gas/arm/attr-march-armv5.d: Likewise.
* testsuite/gas/arm/attr-march-armv5t.d: Likewise.
* testsuite/gas/arm/attr-march-armv5te.d: Likewise.
* testsuite/gas/arm/attr-march-armv5tej.d: Likewise.
* testsuite/gas/arm/attr-march-armv5texp.d: Likewise.
* testsuite/gas/arm/attr-march-armv5txm.d: Likewise.
* testsuite/gas/arm/attr-march-armv6-m+os.d: Likewise.
* testsuite/gas/arm/attr-march-armv6-m.d: Likewise.
* testsuite/gas/arm/attr-march-armv6.d: Likewise.
* testsuite/gas/arm/attr-march-armv6j.d: Likewise.
* testsuite/gas/arm/attr-march-armv6k+sec.d: Likewise.
* testsuite/gas/arm/attr-march-armv6k.d: Likewise.
* testsuite/gas/arm/attr-march-armv6kt2.d: Likewise.
* testsuite/gas/arm/attr-march-armv6kz.d: Likewise.
* testsuite/gas/arm/attr-march-armv6kzt2.d: Likewise.
* testsuite/gas/arm/attr-march-armv6s-m.d: Likewise.
* testsuite/gas/arm/attr-march-armv6t2.d: Likewise.
* testsuite/gas/arm/attr-march-armv6z.d: Likewise.
* testsuite/gas/arm/attr-march-armv6zk.d: Likewise.
* testsuite/gas/arm/attr-march-armv6zkt2.d: Likewise.
* testsuite/gas/arm/attr-march-armv6zt2.d: Likewise.
* testsuite/gas/arm/attr-march-armv7-a+idiv.d: Likewise.
* testsuite/gas/arm/attr-march-armv7-a+mp.d: Likewise.
* testsuite/gas/arm/attr-march-armv7-a+sec+virt.d: Likewise.
* testsuite/gas/arm/attr-march-armv7-a+sec.d: Likewise.
* testsuite/gas/arm/attr-march-armv7-a+virt.d: Likewise.
* testsuite/gas/arm/attr-march-armv7-a.d: Likewise.
* testsuite/gas/arm/attr-march-armv7-m.d: Likewise.
* testsuite/gas/arm/attr-march-armv7-r+mp.d: Likewise.
* testsuite/gas/arm/attr-march-armv7-r.d: Likewise.
* testsuite/gas/arm/attr-march-armv7.d: Likewise.
* testsuite/gas/arm/attr-march-armv7a.d: Likewise.
* testsuite/gas/arm/attr-march-armv7em.d: Likewise.
* testsuite/gas/arm/attr-march-armv7m.d: Likewise.
* testsuite/gas/arm/attr-march-armv7r.d: Likewise.
* testsuite/gas/arm/attr-march-armv7ve.d: Likewise.
* testsuite/gas/arm/attr-march-armv8-a+crypto.d: Likewise.
* testsuite/gas/arm/attr-march-armv8-a+fp.d: Likewise.
* testsuite/gas/arm/attr-march-armv8-a+rdma.d: Likewise.
* testsuite/gas/arm/attr-march-armv8-a+simd.d: Likewise.
* testsuite/gas/arm/attr-march-armv8-a.d: Likewise.
* testsuite/gas/arm/attr-march-armv8-r+crypto.d: Likewise.
* testsuite/gas/arm/attr-march-armv8-r+fp.d: Likewise.
* testsuite/gas/arm/attr-march-armv8-r+simd.d: Likewise.
* testsuite/gas/arm/attr-march-armv8-r.d: Likewise.
* testsuite/gas/arm/attr-march-armv8_1-a+simd.d: Likewise.
* testsuite/gas/arm/attr-march-armv8_1-m.main.d: Likewise.
* testsuite/gas/arm/attr-march-armv8_4-a.d: Likewise.
* testsuite/gas/arm/attr-march-armv8_5-a.d: Likewise.
* testsuite/gas/arm/attr-march-armv8_6-a.d: Likewise.
* testsuite/gas/arm/attr-march-armv8_7-a.d: Likewise.
* testsuite/gas/arm/attr-march-armv8_8-a.d: Likewise.
* testsuite/gas/arm/attr-march-armv8_9-a.d: Likewise.
* testsuite/gas/arm/attr-march-armv9_1-a.d: Likewise.
* testsuite/gas/arm/attr-march-armv9_2-a.d: Likewise.
* testsuite/gas/arm/attr-march-armv9_3-a.d: Likewise.
* testsuite/gas/arm/attr-march-armv9_4-a.d: Likewise.
* testsuite/gas/arm/attr-march-armv9_5-a.d: Likewise.
* testsuite/gas/arm/attr-march-armv8m.base.d: Likewise.
* testsuite/gas/arm/attr-march-armv8m.main.d: Likewise.
* testsuite/gas/arm/attr-march-armv8m.main.dsp.d: Likewise.
* testsuite/gas/arm/attr-march-iwmmxt.d: Likewise.
* testsuite/gas/arm/attr-march-iwmmxt2.d: Likewise.
* testsuite/gas/arm/attr-march-xscale.d: Likewise.
* testsuite/gas/arm/attr-mcpu.d: Likewise.
* testsuite/gas/arm/attr-mfpu-arm1020e.d: Likewise.
* testsuite/gas/arm/attr-mfpu-arm1020t.d: Likewise.
* testsuite/gas/arm/attr-mfpu-arm1136jf-s.d: Likewise.
* testsuite/gas/arm/attr-mfpu-arm1136jfs.d: Likewise.
* testsuite/gas/arm/attr-mfpu-neon-fp16.d: Likewise.
* testsuite/gas/arm/attr-mfpu-neon.d: Likewise.
* testsuite/gas/arm/attr-mfpu-softvfp+vfp.d: Likewise.
* testsuite/gas/arm/attr-mfpu-softvfp.d: Likewise.
* testsuite/gas/arm/attr-mfpu-vfp.d: Likewise.
* testsuite/gas/arm/attr-mfpu-vfp10-r0.d: Likewise.
* testsuite/gas/arm/attr-mfpu-vfp10.d: Likewise.
* testsuite/gas/arm/attr-mfpu-vfp3.d: Likewise.
* testsuite/gas/arm/attr-mfpu-vfp9.d: Likewise.
* testsuite/gas/arm/attr-mfpu-vfpv2.d: Likewise.
* testsuite/gas/arm/attr-mfpu-vfpv3-d16.d: Likewise.
* testsuite/gas/arm/attr-mfpu-vfpv3.d: Likewise.
* testsuite/gas/arm/attr-mfpu-vfpv4-d16.d: Likewise.
* testsuite/gas/arm/attr-mfpu-vfpv4.d: Likewise.
* testsuite/gas/arm/attr-mfpu-vfpxd.d: Likewise.
* testsuite/gas/arm/attr-names.d: Likewise.
* testsuite/gas/arm/attr-non-null-terminated-string.d: Likewise.
* testsuite/gas/arm/attr-order.d: Likewise.
* testsuite/gas/arm/attr-override-cpu-directive.d: Likewise.
* testsuite/gas/arm/attr-override-mcpu.d: Likewise.
* testsuite/gas/arm/bl-local-2.d: Likewise.
* testsuite/gas/arm/bl-local-v4t.d: Likewise.
* testsuite/gas/arm/blx-local.d: Likewise.
* testsuite/gas/arm/branch-reloc.d: Likewise.
* testsuite/gas/arm/directives.d: Likewise.
* testsuite/gas/arm/got_prel.d: Likewise.
* testsuite/gas/arm/mapdir.d: Likewise.
* testsuite/gas/arm/mapmisc.d: Likewise.
* testsuite/gas/arm/mapsecs.d: Likewise.
* testsuite/gas/arm/mapshort-eabi.d: Likewise.
* testsuite/gas/arm/mov-highregs-any.d: Likewise.
* testsuite/gas/arm/mov-lowregs-any.d: Likewise.
* testsuite/gas/arm/note-march-armv2.d: Likewise.
* testsuite/gas/arm/note-march-armv2a.d: Likewise.
* testsuite/gas/arm/note-march-armv3.d: Likewise.
* testsuite/gas/arm/note-march-armv3m.d: Likewise.
* testsuite/gas/arm/note-march-armv4.d: Likewise.
* testsuite/gas/arm/note-march-armv4t.d: Likewise.
* testsuite/gas/arm/note-march-armv5.d: Likewise.
* testsuite/gas/arm/note-march-armv5t.d: Likewise.
* testsuite/gas/arm/note-march-armv5te.d: Likewise.
* testsuite/gas/arm/note-march-iwmmxt.d: Likewise.
* testsuite/gas/arm/note-march-iwmmxt2.d: Likewise.
* testsuite/gas/arm/note-march-xscale.d: Likewise.
* testsuite/gas/arm/pr12198-1.d: Likewise.
* testsuite/gas/arm/pr12198-2.d: Likewise.
* testsuite/gas/arm/thumb-eabi.d: Likewise.
* testsuite/gas/arm/thumb.d: Likewise.
* testsuite/gas/arm/thumbrel.d: Likewise.
* config/te-nacl.h: Removed.
ld/
* Makefile.am (ALL_EMULATION_SOURCES): Remove earmelf_nacl.c and
and earmelfb_nacl.c.
Remove NaCl dep files.
* NEWS: Mention NaCl target support removal.
* configure.tgt: Remove NaCl target support.
* Makefile.in: Regenerated.
* configure: Likewise.
* po/BLD-POTFILES.in: Likewise.
* emulparams/armelf_nacl.sh: Removed.
* emulparams/armelfb_nacl.sh: Likewise.
* emulparams/elf_nacl.sh: Likewise.
* testsuite/ld-arm/farcall-arm-nacl-pic.d: Likewise.
* testsuite/ld-arm/farcall-arm-nacl.d: Likewise.
* testsuite/ld-arm/farcall-data-nacl.d: Likewise.
* testsuite/ld-arm/farcall-thumb2-purecode-consecutive-veneer.d:
Adjusted.
* testsuite/ld-arm/arm-elf.exp: Remove NaCl target support.
* testsuite/ld-arm/cortex-a8-far.d: Likewise.
* testsuite/ld-arm/non-contiguous-arm3.d: Likewise.
* testsuite/ld-arm/non-contiguous-arm6.d: Likewise.
* testsuite/ld-elf/binutils.exp: Likewise.
* testsuite/ld-elf/build-id.exp: Likewise.
* testsuite/ld-elf/ehdr_start-missing.d: Likewise.
* testsuite/ld-elf/ehdr_start-shared.d: Likewise.
* testsuite/ld-elf/ehdr_start-userdef.d: Likewise.
* testsuite/ld-elf/ehdr_start-weak.d: Likewise.
* testsuite/ld-elf/ehdr_start.d: Likewise.
* testsuite/ld-elf/elf.exp: Likewise.
* testsuite/ld-elf/export-class.exp: Likewise.
* testsuite/ld-elf/fatal-warnings-1a.d: Likewise.
* testsuite/ld-elf/fatal-warnings-1b.d: Likewise.
* testsuite/ld-elf/orphan-region.d: Likewise.
* testsuite/ld-elf/package-note.exp: Likewise.
* testsuite/ld-elf/pr16322.d: Likewise.
* testsuite/ld-elf/pr16498a.d: Likewise.
* testsuite/ld-elf/pr16498b.d: Likewise.
* testsuite/ld-elf/pr19162.d: Likewise.
* testsuite/ld-elf/pr22269a.d: Likewise.
* testsuite/ld-elf/pr22269b.d: Likewise.
* testsuite/ld-elf/pr22393-1a.d: Likewise.
* testsuite/ld-elf/pr22393-1b.d: Likewise.
* testsuite/ld-elf/pr22393-1c.d: Likewise.
* testsuite/ld-elf/pr22393-1d.d: Likewise.
* testsuite/ld-elf/pr22393-1e.d: Likewise.
* testsuite/ld-elf/pr22393-1f.d: Likewise.
* testsuite/ld-elf/pr22393-2a.rd: Likewise.
* testsuite/ld-elf/pr22393-2b.rd: Likewise.
* testsuite/ld-elf/pr23900-1-32.rd: Likewise.
* testsuite/ld-elf/pr23900-1-64.rd: Likewise.
* testsuite/ld-elf/pr23900-1.d: Likewise.
* testsuite/ld-elf/pr23900-2a.d: Likewise.
* testsuite/ld-elf/pr23900-2b.d: Likewise.
* testsuite/ld-elf/pr30508.d: Likewise.
* testsuite/ld-elf/pr30907-1.d: Likewise.
* testsuite/ld-elf/pr30907-2.d: Likewise.
* testsuite/ld-elf/pr32341.d: Likewise.
* testsuite/ld-elf/shared.exp: Likewise.
* testsuite/ld-elf/tls.exp: Likewise.
* testsuite/ld-elf/tls_common.exp: Likewise.
* testsuite/ld-elfvers/vers.exp: Likewise.
* testsuite/ld-elfvsb/elfvsb.exp: Likewise.
* testsuite/ld-elfweak/elfweak.exp: Likewise.
* testsuite/ld-gc/gc.exp: Likewise.
* testsuite/ld-ifunc/binutils.exp: Likewise.
* testsuite/ld-pie/pie.exp: Likewise.
* testsuite/ld-plugin/lto-binutils.exp: Likewise.
* testsuite/ld-plugin/lto.exp: Likewise.
* testsuite/ld-scripts/rgn-at3.d: Likewise.
* testsuite/ld-shared/shared.exp: Likewise.
* testsuite/ld-size/size.exp: Likewise.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
|
|
GCC trunk recently had improvements to its -Wunused-but-set-variable which
picked up that contents and hence note_size & old aren't used at all in the
end.
* objcopy.c (merge_gnu_build_notes): Drop unused 'note_size', 'contents',
and 'old' variables.
|
|
This patch was prompted by a clang warning:
readelf.c:23317:37: warning: pointer comparison always evaluates to false [-Wtautological-compare]
23317 | || inote.namedata + inote.namesz < inote.namedata)
| ^
Use the same sanity checks as used by process_notes_at. (See commit
5396a86e4396). While we are at it, print all the v850 note info in
one place to properly handle error conditions.
|
|
|
|
|
|
|
|
These aren't needed since commit 862776f26a59.
|
|
PR ld/33146
Correct TCL errors trying to access error output file in commit
ef7a634dc01d. In fact, get rid of the output file test entirely since
gas exit status is sufficient.
Also there is no need to firstly check for ELF support.
Set check_as_sframe_result, and remove ld-lib.exp check_as_sframe.
|
|
Move gas_sframe_check to binutils-common.exp so that it can be used in
linker tests to check if a target assembler supports --gsframe.
binutils/
PR ld/33146
* testsuite/lib/binutils-common.exp (gas_sframe_check): Moved
from cfi-sframe.exp. Replace gas_host_run with remote_exec.
gas/
PR ld/33146
* testsuite/gas/cfi-sframe/cfi-sframe.exp (gas_sframe_check):
Moved to binutils-common.exp.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
|
|
|
|
|
|
|
|
Add new command line option -z memtag-stack for aarch64 elf. This
option instructs the linker to generate the necessary dynamic tag
DT_AARCH64_MEMTAG_STACK, which the dynamic loader can then use to
protect the stack memory with PROT_MTE. Linker issues an
'unrecognized option' error when -z memtag-stack is specified for
non-aarch64 based emulations.
readelf displays the dynamic tag when present:
$ readelf -d <exectutable>
Dynamic section at offset 0xfdd8 contains XX entries:
Tag Type Name/Value
0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
0x000000000000000c (INIT) 0x400520
0x000000000000000d (FINI) 0x400b64
0x0000000000000019 (INIT_ARRAY) 0x41fdc8
... ... ...
0x000000007000000c (AARCH64_MEMTAG_STACK) 0x1
... ... ...
ChangeLog:
* bfd/elfnn-aarch64.c (elfNN_aarch64_late_size_sections): Emit
DT_AARCH64_MEMTAG_STACK dynamic tag.
* bfd/elfxx-aarch64.h (struct aarch64_memtag_opts): Add new
member for tracking whether stack access uses MTE insns.
* binutils/readelf.c (get_aarch64_dynamic_type): Handle
DT_AARCH64_MEMTAG_STACK.
* ld/emultempl/aarch64elf.em: Add new command line option.
* ld/ld.texi: Add documentation for -z memtag-stack.
* ld/testsuite/ld-aarch64/aarch64-elf.exp: Add new test.
* ld/testsuite/ld-aarch64/dt-memtag-stack.d: New test.
include/ChangeLog:
* elf/aarch64.h (DT_AARCH64_MEMTAG_STACK): New definition.
|
|
Add new command line option -z memtag-mode=<mode> to aarch64 elf,
where <mode> can be one of none, sync, or async. For mode of sync or
async, a DT_AARCH64_MEMTAG_MODE dynamic tag with a value of 0 or 1
respectively is emitted.
readelf displays the dynamic tag when present:
$ readelf -d <exectutable>
Dynamic section at offset 0xfdd8 contains XX entries:
Tag Type Name/Value
0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
0x000000000000000c (INIT) 0x400520
0x000000000000000d (FINI) 0x400b64
0x0000000000000019 (INIT_ARRAY) 0x41fdc8
... ... ...
0x0000000070000009 (AARCH64_MEMTAG_MODE) 0x1
... ... ...
Note that this patch doesn't add support for the "asymm" MTE mode,
which is an Armv8.7 extension.
ChangeLog:
* bfd/elfnn-aarch64.c (struct elf_aarch64_link_hash_table): Add
new member for memtag properties.
(bfd_elfNN_aarch64_set_options): New argument to pass memtag
properties.
(elfNN_aarch64_late_size_sections): Emit DT_AARCH64_MEMTAG_MODE
dynamic tag.
* bfd/elfxx-aarch64.h: New definition for the various memtag
properties.
* binutils/readelf.c (get_aarch64_dynamic_type): Handle
DT_AARCH64_MEMTAG_MODE.
* ld/emultempl/aarch64elf.em: Likewise.
* ld/ld.texi: Add documentation for the new option
-z memtag-mode.
* ld/testsuite/ld-aarch64/aarch64-elf.exp: New test.
* ld/testsuite/ld-aarch64/dt-memtag.d: New test.
* ld/testsuite/ld-aarch64/dt-memtag-mode.s: New test.
include/ChangeLog:
* elf/aarch64.h (DT_AARCH64_MEMTAG_MODE): New definition.
|
|
This allows objdump/readelf to dump DWARF/EH Frame info when the stack
frame makes use of MTE tagging.
ChangeLog:
* binutils/dwarf.c (is_aarch64_augmentation): Add handling for augmentation
char 'G'.
---
[No change in V3]
|
|
This patch factorizes the handling of architecture/machine specific
augmentation characters in CIEs.
Based on an idea proposed by Richard Earnshaw.
binutils/ChangeLog:
* dwarf.c (is_mach_augmentation_ftype): New type.
(is_mach_augmentation): New variable.
(is_nomach_augmentation): New function.
(is_aarch64_augmentation): Likewise.
(init_dwarf_by_elf_machine_code): Set is_mach_augmentation as
appropriate.
(init_dwarf_by_bfd_arch_and_mach): Likewise.
(read_cie): Handle architecture-specific augmentation characters
in a generic way.
|
|
This patch renames the functions:
init_dwarf_regnames_by_elf_machine_code
init_dwarf_regnames_by_bfd_arch_and_mach
to
init_dwarf_by_elf_machine_code
init_dwarf_by_bfd_arch_and_mach
The idea is to start using these functions to perform general
architecture/machine specific initializations beyond register names.
Regtested in x86_64-linux-gnu and aarch64-linux-gnu targets.
binutils/ChangeLog:
* dwarf.c (init_dwarf_regnames_by_elf_machine_code): Rename to
init_dwarf_by_elf_machine_code.
(init_dwarf_regnames_by_bfd_arch_and_mach): Rename to
init_dwarf_by_bfd_arch_and_mach.
* dwarf.h: Adjust prototypes accordingly.
* readelf.c (process_file_header): Adjust call to
init_dwarf_regnames_by_elf_machine_code accordingly.
* objdump.c (dump_dwarf): Adjust call to
init_dwarf_regnames_by_bfd_arch_and_mach accordingly.
|
|
Remove LIBSFRAME_1.1, LIBSFRAME_1.0 nodes and add a new LIBSFRAME_2.0
node (non-inheritance version) to create new global versioned symbols.
Also announce libsframe.so.2 in NEWS.
New APIs:
sframe_decoder_get_flags;
sframe_decoder_get_offsetof_fde_start_addr;
sframe_encoder_get_flags;
sframe_encoder_get_offsetof_fde_start_addr;
Removed APIs: (already deprecated since X-2 release)
sframe_get_funcdesc_with_addr;
APIs with changed semantics:
sframe_decoder_get_funcdesc_v2;
sframe_encoder_add_funcdesc_v2;
sframe_encoder_write;
lisbframe/
* libsframe.ver: Define new LIBSFRAME_2.0.
* libtool-version: Bump the 'current' numeral to indicate a binary
incompatible release.
include/
* sframe-api.h (sframe_get_funcdesc_with_addr): Remove
deprecated interface.
libsframe/
* sframe.c (sframe_get_funcdesc_with_addr): Likewise.
binutils/
* NEWS: Announce new versioned release of libsframe.
|
|
So far, SFrame sections were of type SHT_PROGBITS.
As per ELF specification, SHT_PROGBITS indicates that the section holds
information defined by the program, whose format and meaning are
determined solely by the program.
On the linker side, SHT_PROGBITS should be reserved for the simple "cat
contents after applying relocs" semantics.
Currently, the only way to know that a section contains SFrame stack
trace data is if consumer checks for section name. Such a check for
section name is not quite conformant to ELF principles.
Some of this was discussed here
https://sourceware.org/pipermail/binutils/2025-March/140181.html
With this change, the SFrame sections generated by gas, ld will have
section type set to SHT_GNU_SFRAME. The new section type is defined in
the SHT_LOOS/SHT_HIOS space. The SFrame parsing routine
_bfd_elf_parse_sframe () now admits sections only when the the section
type is SHT_GNU_SFRAME.
No special handling / validation is done at the moment for the case of
manual creation of SFrame sections via obj_elf_section (). Add function
level comments for now to add a note about this.
Although the default handling for (sh_type >= SHT_LOOS && sh_type <=
SHT_HIOS) is sufficient when SHT_GNU_SFRAME is in that range, it makes
sense to add it as a case of its own.
bfd/
* elf-sframe.c (_bfd_elf_parse_sframe): Check if section type is
SHT_GNU_SFRAME.
(_bfd_elf_set_section_sframe): Set SHT_GNU_SFRAME for output
SFrame section.
* elflink.c (obj_elf_section): Use section type for check
instead of section name.
* elfxx-x86.c: Set SHT_GNU_SFRAME for SFrame sections for
.plt* sections.
* elf.c (bfd_section_from_shdr): Add case for SHT_GNU_SFRAME.
binutils/
* readelf.c (get_os_specific_section_type_name): Add
SHT_GNU_SFRAME.
gas/
* NEWS: Announce emitted SFrame sections have SHT_GNU_SFRAME
set.
* config/obj-elf.c (obj_elf_attach_to_group): Add comments to
indicate no special handling for SFrame yet.
* dw2gencfi.c (cfi_finish): Set SHT_GNU_SFRAME for emitted
SFrame section.
ld/
* NEWS: Announce emitted SFrame sections have SHT_GNU_SFRAME
set.
gas/testsuite/
* gas/cfi-sframe/cfi-sframe.exp: Add new test.
* gas/cfi-sframe/cfi-sframe-common-1b.d: New test.
* gas/cfi-sframe/cfi-sframe-common-1b.s: New test.
include/
* elf/common.h (SHT_GNU_SFRAME): Add new section type for SFrame
stack trace information.
libsframe/doc/
* sframe-spec.texi: Add expected ELF section type.
|
|
Signed-off-by: WANG Xuerui <git@xen0n.name>
|
|
The preceding commits add s390 64-bit (s390x) support in binutils to
generate SFrame stack trace information (.sframe section) in the
assembler from CFI directives (with option --gsframe), generate .sframe
section for linker-generated .plt section in the linker, and dump SFrame
information in objdump and readelf (with option --sframe).
binutils/
* NEWS: Announce s390 64-bit (s390x) SFrame V2 support in
as, ld, objdump, and readelf.
gas/
* NEWS: Update s390 64-bit (s390x) SFrame V2 support in
assembler.
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
|
|
Swap AM_PO_SUBDIRS and ZW_GNU_GETTEXT_SISTER_DIR lines in
*/configure.ac. ZW_GNU_GETTEXT_SISTER_DIR indirectly invokes
AC_REQUIRE(AM_PO_SUBDIRS) so results in AM_PO_SUBDIRS being emitted
before ZW_GNU_GETTEXT_SISTER_DIR if it hasn't already been invoked.
|
|
init_private_section_data is used by the linker and is a special case
of copy_private_section_data that copies a reduced set of section data
from input to output. Merge the two functions, adding a link_info
param to copy_private_section_data and remove init_private_section_data.
|
|
The SFrame FDE's function start address is always emitted as follows by
GAS and ld: it is the offset of the start PC of the respective function
from the FDE field itself.
GAS and ld will emit a flag SFRAME_F_FDE_FUNC_START_PCREL set to 1
when emitting the field in this encoding.
* binutils/NEWS: Announce the change of encoding for SFrame FDE
func start addr field.
* gas/NEWS: Announce the emission of new flag
SFRAME_F_FDE_FUNC_START_PCREL.
* ld/NEWS: Likewise. Relocatable links are now fixed.
|
|
This patch convenes a set of changes in bfd, gas, ld, libsframe towards
moving to the new encoding for the 'sfde_func_start_address' field in
SFrame FDE.
First, gas must now mark all SFrame sections with the new flag
SFRAME_F_FDE_FUNC_START_PCREL. gas was already emitting the field
in the said encoding.
* gas/gen-sframe.c (output_sframe_internal): Emit the flag
SFRAME_F_FDE_FUNC_START_PCREL.
Similarly for ld, adopt the new semantics of sfde_func_start_address
consistently. This means:
- When merging SFrame sections, check that all input SFrame sections
have the SFRAME_F_FDE_FUNC_START_PCREL flag set. If the check
fails, ld errors out.
- When merging SFrame sections, keep even the in-memory contents of
the FDE function start address (buffer passed to libsframe
sframe_encoder_write () for writing out) encoded in the new
semantics. While it is, in theory, possible that instead of doing this
change here, we adjust the value of sfde_func_start_address at the final
write (sframe_encoder_write) time. But latter is not favorable for
maintenanance and may be generally confusing for developers.
- When creating SFrame for PLT entries, emit flag
SFRAME_F_FDE_FUNC_START_PCREL.
include/
* sframe-api.h (SFRAME_F_LD_MUSTHAVE_FLAGS): New definition.
bfd/
* elf-sframe.c (_bfd_elf_merge_section_sframe): Check for flag
combinatation SFRAME_F_LD_MUSTHAVE_FLAGS set for all input and
output SFrame sections. If not, error out. Also, adopt the new
semantics of function start address encoding.
* bfd/elfxx-x86.c (_bfd_x86_elf_create_sframe_plt): Emit flag
SFRAME_F_FDE_FUNC_START_PCREL.
Next, for dumping SFrame sections, now that we are emitting the same
encoding in GAS, non-relocatable and relocatable SFrame links, it is the
time to set relocate to TRUE in debug_displays[].
binutils/
* dwarf.c (struct dwarf_section_display): Allow sframe sections
to now be relocated.
gas/testsuite/
* gas/cfi-sframe/cfi-sframe-aarch64-pac-ab-key-1.d: Update the
test. Relocatable SFrame sections now display non-zero value
(appropriate function start address).
Now, as the SFrame sections on-disk and in-memory use the new semantics of
sfde_func_start_address encoding (i.e., function start address is the
offset from the sfde_func_start_address field to the start PC), the
calculation to make it human readable (i.e., relatable to the addresses
in .text sections) needs adjustment.
libsframe/
* sframe-dump.c (dump_sframe_func_with_fres): Adjust the
function start address for dumping.
Now that both the emission of the new encoding, and the relocation of
sections before dumping them is in place, it is time to adjust the
testcases.
gas/testsuite/
* gas/cfi-sframe/cfi-sframe-aarch64-1.d: Update expected output
to include SFRAME_F_FDE_FUNC_START_PCREL instead of NONE.
* gas/cfi-sframe/cfi-sframe-aarch64-2.d: Likewise.
* gas/cfi-sframe/cfi-sframe-aarch64-3.d: Likewise.
* gas/cfi-sframe/cfi-sframe-aarch64-4.d: Likewise.
* gas/cfi-sframe/cfi-sframe-common-1.d: Likewise.
* gas/cfi-sframe/cfi-sframe-common-10.d: Likewise.
* gas/cfi-sframe/cfi-sframe-common-11.d: Likewise.
* gas/cfi-sframe/cfi-sframe-common-2.d: Likewise.
* gas/cfi-sframe/cfi-sframe-common-3.d: Likewise.
* gas/cfi-sframe/cfi-sframe-common-4.d: Likewise.
* gas/cfi-sframe/cfi-sframe-common-5.d: Likewise.
* gas/cfi-sframe/cfi-sframe-common-6.d: Likewise.
* gas/cfi-sframe/cfi-sframe-common-7.d: Likewise.
* gas/cfi-sframe/cfi-sframe-common-8.d: Likewise.
* gas/cfi-sframe/cfi-sframe-common-9.d: Likewise.
* gas/cfi-sframe/cfi-sframe-x86_64-1.d: Likewise.
* gas/cfi-sframe/cfi-sframe-x86_64-2.d: Likewise.
* gas/cfi-sframe/cfi-sframe-x86_64-empty-1.d: Likewise.
* gas/cfi-sframe/cfi-sframe-x86_64-empty-2.d: Likewise.
* gas/cfi-sframe/cfi-sframe-x86_64-empty-3.d: Likewise.
* gas/cfi-sframe/cfi-sframe-x86_64-empty-4.d: Likewise.
* gas/cfi-sframe/common-empty-1.d: Likewise.
* gas/cfi-sframe/common-empty-2.d: Likewise.
* gas/cfi-sframe/common-empty-3.d: Likewise.
* gas/scfi/x86_64/scfi-cfi-sections-1.d: Likewise.
* gas/scfi/x86_64/scfi-dyn-stack-1.d: Likewise.
ld/testsuite/
* ld-aarch64/sframe-simple-1.d: Update expected output to
include SFRAME_F_FDE_FUNC_START_PCREL.
* ld-x86-64/sframe-ibt-plt-1.d: Likewise.
* ld-x86-64/sframe-plt-1.d: Likewise.
* ld-x86-64/sframe-pltgot-1.d: Likewise.
* ld-x86-64/sframe-pltgot-2.d: Likewise.
* ld-x86-64/sframe-simple-1.d: Likewise.
Naturally, the change of semantics for 'SFrame FDE function start address'
has consequences on the implementation in libsframe. As per the new
semantics:
- Function start address in the SFrame FDE (sfde_func_start_address)
is an offset from the FDE function start address field to the start
PC of the associated function.
Note that, the libsframe library brings the SFrame section contents into
its own memory to create a sframe_decoder_ctx object via sframe_decode
(). Many internal and user-interfacing APIs then may use
sframe_decoder_ctx object to interact and fulfill the work.
In context of changing semantics for sfde_func_start_address, following
relevant examples may help understand the impact:
- sframe_find_fre () finds a the SFrame stack trace data (SFrame FRE)
given a lookup offset (offset of lookup_pc from the start of SFrame
section). Now that the sfde_func_start_address includes the
distance from the sfde_func_start_address field to the start of
SFrame section itself, the comparison checks of
sfde_func_start_address with the incoming lookup offset need
adjustment.
- Some internal functions (sframe_get_funcdesc_with_addr_internal ()
finds SFrame FDE by using binary seach comparing
sfde_func_start_address fields, etc.) need adjustments.
- sframe_encoder_write () sorts the SFrame FDEs before writing out
the SFrame data. Sorting of SFrame FDE via the internal function
sframe_sort_funcdesc() needs adjustments: the new encoding of
sfde_func_start_address means the distances are not from the same
anchor, so cannot be sorted directly.
This patch takes the approach of adding a new internal function:
- sframe_decoder_get_secrel_func_start_addr (): This function returns
the offset of the start PC of the function from the start of SFrame
section, i.e., it gives a section-relative offset.
As the sframe_decoder_get_secrel_func_start_addr () API needs the value
of the function index in the FDE list, another internal API needs
sframe_fre_check_range_p () adjustments too.
Sorting the FDEs (via sframe_sort_funcdesc ()) is done by first bringing
all offsets in sfde_func_start_address relative to start of SFrame
section, followed by sorting, and then readjusting the offsets accroding
to the new position in the FDE list.
libsframe/
* sframe.c (sframe_decoder_get_secrel_func_start_addr): New
static function.
(sframe_fre_check_range_p): Adjust the interface a bit.
(sframe_get_funcdesc_with_addr_internal): Use
sframe_decoder_get_secrel_func_start_addr () when comparing
sfde_func_start_address with user input offset.
(sframe_find_fre): Adopt the new semantics.
(sframe_sort_funcdesc): Likewise.
For the libsframe testsuite, use the new encoding for FDE func start
addr: distance between the FDE sfde_func_start_address field and the
start PC of the function itself.
Use SFRAME_F_FDE_FUNC_START_PCREL flag, though the sframe_encode ()
interface in libsframe applies no sanity checks for the encoding itself.
libsframe/testsuite/
* libsframe.find/findfre-1.c: Adjust to use the new
SFRAME_F_FDE_FUNC_START_PCREL specific encoding.
* libsframe.find/findfunc-1.c: Likewise.
* libsframe.find/plt-findfre-1.c: Likewise.
* libsframe/testsuite/libsframe.decode/DATA2: Update data file
due to usage of new SFRAME_F_FDE_FUNC_START_PCREL flag.
* libsframe/testsuite/libsframe.encode/encode-1.c: Use flag
SFRAME_F_FDE_FUNC_START_PCREL.
|
|
PR libsframe/32589 - function start address is zero in SFrame section dump
Currently, readelf and objdump display the SFrame sections in ET_REL
object files with function start addresses of each function as 0. This
makes it difficult to correlate SFrame stack trace information with the
individual functions in the object file.
For objdump, use the dump_dwarf () interface to dump SFrame section.
Similarly, for readelf, use the display_debug_section () interface to
dump SFrame section. These existing interfaces (for DWARF debug
sections) already support relocating the section contents before
dumping, so lets use them for SFrame sections as well.
When adding a new entry for SFrame in debug_option_table[], use char
'nil' and the option name of "sframe-internal-only". This is done so
that there is no additional (unnecessary) user-exposed ways of dumping
SFrame sections. Additionally, we explicitly disallow the
"sframe-internal-only" from external/user input in --dwarf (objdump).
Similarly, "sframe-internal-only" is explicitly matched and disallowed
from --debug-dump (readelf).
For objdump and readelf, we continue to keep the same error messaging as
earlier:
$ objdump --sframe=sframe bubble_sort.o
...
No sframe section present
$ objdump --sframe=.sfram bubble_sort.o
...
No .sfram section present
$ objdump --sframe=sframe-internal-only sort
...
No sframe-internal-only section present
Similarly for readelf:
$ readelf --sframe= bubble_sort.o
readelf: Error: Section name must be provided
$ readelf --sframe=.sfram bubble_sort.o
readelf: Warning: Section '.sfram' was not dumped because it does not exist
$ readelf --sframe=sframe bubble_sort.o
readelf: Warning: Section 'sframe' was not dumped because it does not exist
PS: Note how this patch adds a new entry to debug_displays[] with a
relocate value set to FALSE. This will be set to TRUE in a subsequent
patch ("bfd: gas: ld: libsframe: emit func start addr field as an offset
from FDE") when fixes are made to emit the value of the
'sfde_func_start_address' field in the new encoding
SFRAME_F_FDE_FUNC_START_PCREL across gas and ld.
binutils/
* dwarf.c (display_sframe): New definition.
(dwarf_select_sections_all): Enable SFrame section too.
(struct dwarf_section_display): Add entry for SFrame section.
* dwarf.h (enum dwarf_section_display_enum): Add enumerator for
SFrame.
* objdump.c (dump_section_sframe): Remove.
(dump_sframe_section): Add new definition.
(dump_bfd): Use dump_sframe_section.
* binutils/readelf.c (dump_section_as_sframe): Remove.
|
|
binutils/ChangeLog
2025-06-29 Vladimir Mezentsev <vladimir.mezentsev@oracle.com>
* dwarf.c: Change "/usrlib64/debug/usr" to "/usr/lib64/debug/usr/" and
.gun_debugaltlink to .gnu_debugaltlink.
|
|
Change
verbose "cmp tmpdir/pr27708.out $srcdir/$subdir/pr26808.dump" 1
to
verbose "cmp tmpdir/pr27708.out $srcdir/$subdir/pr27708.dump" 1
* testsuite/binutils-all/x86-64/x86-64.exp: Correct pr26808.dump
to pr27708.dump.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
|
|
Disclaimer: this issue cannot occur with Object Attributes v1 (OAv1) while
using the GNU binutils because a value of '\0' (empty string) for a tag
with a string value is considered as the default value for the attribute,
and consequently is eliminated by gas from the output object file during
the serialization.
An empty string is a valid value for a NTBS tag in both OAv1 and OAv2 [1]
cases. However, contrarily to OAv1, a OAv2 subsection can be required and
so, tags in this subsection might have to be present even if the value is
the default. To comply with this requirement, the OAv2 serializer won't
drop the default values.
In the case where a NTBS tag has the value '\0' and is last in the object
attributes section, the current code in readelf used for dumping the object
attributes incorrectly detects an overflow, and prints out an error message
for a corrupted string tag.
This patch fixes the detection of the overflow so that it now accept an
empty string in the last tag of the object attributes section.
It also fixes the previous tests for the empty NTBS case and the non-null
terminated string one. The fix was also tested in the context of OAv2's
patch series [1] where the issue was originally detected. No regression
was found.
[1]: https://inbox.sourceware.org/binutils/20250509151319.88725-1-matthieu
.longo@arm.com/
|
|
|
|
GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_UNLABELED
This patch adds two new GNU properties for RISC-V:
GNU_PROPERTY_RISCV_FEATURE_1_CFI_SS and GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_UNLABELED.
We only add readelf and define the properties in this patch.
Ref: https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/417
|
|
Since the output section contents are copied from the input, don't
extend the output section size beyond the input section size.
PR binutils/33049
* objcopy.c (copy_section): Don't extend the output section
size beyond the input section size.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
|
|
commit 717a38e9a02109fcbcb18bb2ec3aa251e2ad0a0d
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Sun May 4 05:12:46 2025 +0800
strip: Add GCC LTO IR support
added:
@@ -3744,6 +3768,12 @@ copy_archive (bfd *ibfd, bfd *obfd, const char
*output_target,
goto cleanup_and_exit;
}
+#if BFD_SUPPORTS_PLUGINS
+ /* Copy LTO IR file as unknown object. */
+ if (bfd_plugin_target_p (ibfd->xvec))
^^^^ A typo, should be this_element.
+ ok_object = false;
+ else
+#endif
if (ok_object)
{
ok = copy_object (this_element, output_element, input_arch);
to check if the archive element is a LTO IR file. "ibfd" is the archive
BFD. "this_element" should be used to check for LTO IR in the archive
element. Fix it by replacing "ibfd" with "this_element".
PR binutils/33078
* objcopy.c (copy_archive): Correctly check archive element for
LTO IR.
* testsuite/binutils-all/objcopy.exp (strip_test_archive): New.
Run strip_test_archive.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
|
|
Noticed the extra zeros while inspecting the output.
Signed-off-by: Jeremy Drake <sourceware-bugzilla@jdrake.com>
|
|
This allows the delay IAT to be in its own section with nothing else, as
required by IMAGE_GUARD_DELAYLOAD_IAT_IN_ITS_OWN_SECTION, documented at
https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#load-configuration-layout
Signed-off-by: Jeremy Drake <sourceware-bugzilla@jdrake.com>
|
|
A delay-import symbol (of a function) is resolved when a call to it is made.
The delay loader may overwrite the `__imp_` pointer to the actual function
after it has been resolved, which requires the pointer itself be in a
writeable section.
Previously it was placed in the ordinary Import Address Table (IAT), which
is emitted into the `.idata` section, which had been changed to read-only
in db00f6c3aceabbf03acdb69e74b59b2d2b043cd7, which caused segmentation
faults when functions from delay-import library were called. This is
PR 32675.
This commit makes DLLTOOL emit delay-import IAT into `.didat`, as specified
by Microsoft. Most of the code is copied from `.idata`, except that this
section is writeable. As a side-effect of this, PR 14339 is also fixed.
Using this DEF:
```
; ws2_32.def
LIBRARY "WS2_32.DLL"
EXPORTS
WSAGetLastError
```
and this C program:
```
// delay.c
#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
#include <stdio.h>
/////////////////////////////////////////////////////////
// User code
/////////////////////////////////////////////////////////
DWORD WINAPI WSAGetLastError(void);
extern PVOID __imp_WSAGetLastError;
int
main(void)
{
fprintf(stderr, "before delay load, __imp_WSAGetLastError = %p\n", __imp_WSAGetLastError);
SetLastError(123);
fprintf(stderr, "WSAGetLastError() = %d\n", WSAGetLastError());
fprintf(stderr, "after delay load, __imp_WSAGetLastError = %p\n", __imp_WSAGetLastError);
__imp_WSAGetLastError = (PVOID) 1234567;
fprintf(stderr, "after plain write, __imp_WSAGetLastError = %p\n", __imp_WSAGetLastError);
}
/////////////////////////////////////////////////////////
// Overridden `__delayLoadHelper2` facility
/////////////////////////////////////////////////////////
extern char __ImageBase[];
PVOID WINAPI ResolveDelayLoadedAPI(PVOID ParentModuleBase, LPCVOID DelayloadDescriptor,
PVOID FailureDllHook, PVOID FailureSystemHook,
FARPROC* ThunkAddress, ULONG Flags);
FARPROC WINAPI DelayLoadFailureHook(LPCSTR name, LPCSTR function);
FARPROC WINAPI __delayLoadHelper2(LPCVOID pidd, FARPROC* ppfnIATEntry)
{
return ResolveDelayLoadedAPI(&__ImageBase, pidd, NULL, (PVOID) DelayLoadFailureHook,
ppfnIATEntry, 0);
}
```
This program used to crash:
```
$ dlltool -nn -d ws2_32.def -y delay_ws2_32.a
$ gcc -g delay.c delay_ws2_32.a -o delay.exe
$ ./delay.exe
before delay load, __imp_WSAGetLastError = 00007FF6937215C6
Segmentation fault
```
After this commit, it loads and calls `WSAGetLastError()` properly, and
`__imp_WSAGetLastError` is writeable:
```
$ dlltool -nn -d ws2_32.def -y delay_ws2_32.a
$ gcc -g delay.c delay_ws2_32.a -o delay.exe
$ ./delay.exe
before delay load, __imp_WSAGetLastError = 00007FF76E2215C6
WSAGetLastError() = 123
after delay load, __imp_WSAGetLastError = 00007FFF191FA720
after plain write, __imp_WSAGetLastError = 000000000012D687
```
Reference: https://learn.microsoft.com/en-us/windows/win32/secbp/pe-metadata#import-handling
Co-authored-by: Jeremy Drake <sourceware-bugzilla@jdrake.com>
Signed-off-by: LIU Hao <lh_mouse@126.com>
Signed-off-by: Jeremy Drake <sourceware-bugzilla@jdrake.com>
|
|
This is a followup to commt 619f863c55ca "dlltool memory leaks".
The name passed to def_name is freed, so if missing we can't just
use "". strdup it.
* defparse.y (opt_name): xstrdup empty string.
|
|
|
|
PR 33024
PR 33025
* elfedit.c (update_gnu_property): Sanity check program headers.
|
|
* objdump.c (disassemble_data): Free modified xvec and replace
original.
|
|
Texinfo 7.2 began showing warnings like:
binutils.texi:882: warning: do not set .info suffix in reference for manual `ld.info'
binutils.texi:1365: warning: do not set .info suffix in reference for manual `ld.info'
The Texinfo developers plan to stop removing the '.info' suffix
internally in a future release so without this patch the references will
break in the future.
Signed-off-by: Collin Funk <collin.funk1@gmail.com>
|
|
When all LTO sections have been removed, the BFD lto_type is set to
lto_non_ir_object by bfd_set_lto_type. In this case, don't complain
needing a plugin when seeing a LTO slim symbol.
bfd/
PR binutils/32967
* archive.c (_bfd_compute_and_write_armap): Call
bfd_lto_slim_symbol_p to check LTO slim symbol.
* bfd-in2.h: Generated.
* bfd.c (bfd_lto_slim_symbol_p): New.
binutils/
PR binutils/32967
* nm.c (filter_symbols): Call bfd_lto_slim_symbol_p to check
LTO slim symbol.
ld/
PR binutils/32967
* testsuite/ld-plugin/lto-binutils.exp: Run PR binutils/32967
tests.
* testsuite/ld-plugin/strip-1a-s-all.nd: New file.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
|
|
Fix three place where a NULL could be passed to "toosmall".
|
|
Marcus has resigned from the project.
|
|
|