ctf_archive_next returns an opened dict, which must be closed by the caller.
Thanks to Alan Modra for spotting this.
binutils/
* objdump.c (dump_ctf): Close dict.
* readelf.c (dump_section_as_ctf): Likewise.
The GNU_PROPERTY_MEMORY_SEAL gnu property is a way to mark binaries
to be memory sealed by the loader, to avoid further changes of
PT_LOAD segments (such as unmapping or change permission flags).
This is done along with Linux kernel (the mseal syscall [1]), and
C runtime supports to instruct the kernel on the correct time during
program startup (for instance, after RELRO handling). This support
is added along the glibc support to handle the new gnu property [2].
This is a opt-in security features, like other security hardening
ones like NX-stack or RELRO.
The new property is ignored if present on ET_REL objects, and only
added on ET_EXEC/ET_DYN if the linker option is used. A gnu property
is used instead of DT_FLAGS_1 flag to allow memory sealing to work
with ET_EXEC without PT_DYNAMIC support (at least on glibc some ports
still do no support static-pie).
[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=8be7258aad44b5e25977a98db136f677fa6f4370
[2] https://sourceware.org/pipermail/libc-alpha/2024-September/160291.html
Change-Id: Id47fadabecd24be0e83cff45653f7ce9a900ecf4
Link with mixed IR/non-IR objects
* 2 kinds of object files
o non-IR object file has
* non-IR sections
o IR object file has
* IR sections
* non-IR sections
* The output of "ld -r" with mixed IR/non-IR objects should work with:
o Compilers/linkers with IR support.
o Compilers/linkers without IR support.
* Add the mixed object file which has
o IR sections
o non-IR sections:
* Object codes from IR sections.
* Object codes from non-IR object files.
o Object-only section:
* With section name ".gnu_object_only" and SHT_GNU_OBJECT_ONLY type
on ELF:
https://gitlab.com/x86-psABIs/Linux-ABI
#define SHT_GNU_OBJECT_ONLY 0x6ffffff8 /* Object only */
* Contain non-IR object file.
* Input is discarded after link.
* Linker action:
o Classify each input object file:
* If there is a ".gnu_object_only" section, it is a mixed object file.
* If there is a IR section, it is an IR object file.
* Otherwise, it is a non-IR object file.
o Relocatable non-IR link:
* Prepare for an object-only output.
* Prepare for a regular output.
* For each mixed object file:
* Add IR and non-IR sections to the regular output.
* For object-only section:
* Extract object only file.
* Add it to the object-only output.
* Discard object-only section.
* For each IR object file:
* Add IR and non-IR sections to the regular output.
* For each non-IR object file:
* Add non-IR sections to the regular output.
* Add non-IR sections to the object-only output.
* Final output:
* If there are IR objects, non-IR objects and the object-only
output isn't empty:
* Put the object-only output into the object-only section.
* Add the object-only section to the regular output.
* Remove the object-only output.
o Normal link and relocatable IR link:
* Prepare for output.
* IR link:
* For each mixed object file:
* Compile and add IR sections to the output.
* Discard non-IR sections.
* Object-only section:
* Extract object only file.
* Add it to the output.
* Discard object-only section.
* For each IR object file:
* Compile and add IR sections to the output.
* Discard non-IR sections.
* For each non-IR object file:
* Add non-IR sections to the output.
* Non-IR link:
* For each mixed object file:
* Add non-IR sections to the output.
* Discard IR sections and object-only section.
* For each IR object file:
* Add non-IR sections to the output.
* Discard IR sections.
* For each non-IR object file:
* Add non-IR sections to the output.
This is useful for Linux kernel build with LTO.
bfd/
PR ld/12291
PR ld/12430
PR ld/13298
* bfd.c (bfd_lto_object_type): Add lto_mixed_object.
(bfd): Add object_only_section.
(bfd_group_signature): New.
* elf.c (special_sections_g): Add .gnu_object_only.
* format.c: Include "plugin-api.h" and "plugin.h" if
BFD_SUPPORTS_PLUGINS is defined.
(bfd_set_lto_type): Set type to lto_mixed_object for
GNU_OBJECT_ONLY_SECTION_NAME section.
(bfd_check_format_matches): Don't check the plugin target twice
if the plugin target is explicitly specified.
* opncls.c (bfd_extract_object_only_section): New.
* plugin.c (bfd_plugin_fake_text_section): New.
(bfd_plugin_fake_data_section): Likewise.
(bfd_plugin_fake_bss_section): Likewise.
(bfd_plugin_fake_common_section): Likewise.
(bfd_plugin_get_symbols_in_object_only): Likewise.
* plugin.c (add_symbols): Call
bfd_plugin_get_symbols_in_object_only and count
plugin_data->object_only_nsyms.
(bfd_plugin_get_symtab_upper_bound): Count
plugin_data->object_only_nsyms.
bfd_plugin_get_symbols_in_object_only and add symbols from
object only section.
(bfd_plugin_canonicalize_symtab): Remove fake_section,
fake_data_section, fake_bss_section and fake_common_section.
Set udata.p to NULL. Use bfd_plugin_fake_text_section,
bfd_plugin_fake_data_section, bfd_plugin_fake_bss_section and
bfd_plugin_fake_common_section.
Set udata.p to NULL.
* plugin.h (plugin_data_struct): Add object_only_nsyms and
object_only_syms.
* section.c (GNU_OBJECT_ONLY_SECTION_NAME): New.
* bfd-in2.h: Regenerated.
binutils/
PR ld/12291
PR ld/12430
PR ld/13298
* objcopy.c (group_signature): Removed.
(is_strip_section): Replace group_signature with
bfd_group_signature.
(setup_section): Likewise.
* readelf.c (get_os_specific_section_type_name): Handle
SHT_GNU_OBJECT_ONLY.
gas/
PR ld/12291
PR ld/12430
PR ld/13298
* testsuite/gas/elf/section9.s: Add the .gnu_object_only test.
* testsuite/gas/elf/section9.d: Updated.
include/
PR ld/12291
PR ld/12430
PR ld/13298
* elf/common.h (SHT_GNU_OBJECT_ONLY): New.
ld/
PR ld/12291
PR ld/12430
PR ld/13298
* ld.h (ld_config_type): Add emit_gnu_object_only and
emitting_gnu_object_only.
* ldelf.c (orphan_init_done): Make it file scope.
(ldelf_place_orphan): Rename hold to orig_hold. Initialize hold
from orig_hold at run-time.
(ldelf_finish): New.
* ldelf.h (ldelf_finish): New.
* ldexp.c (ldexp_init): Take a bfd_boolean argument to supprt
object-only output.
(ldexp_finish): Likewise.
* ldexp.h (ldexp_init): Take a bfd_boolean argument.
(ldexp_finish): Likewise.
* ldfile.c (ldfile_try_open_bfd): Call
cmdline_check_object_only_section.
* ldlang.c: Include "ldwrite.h" and elf-bfd.h.
* ldlang.c (cmdline_object_only_file_list): New.
(cmdline_object_only_archive_list): Likewise.
(cmdline_temp_object_only_list): Likewise.
(cmdline_lists_init): Likewise.
(cmdline_list_new): Likewise.
(cmdline_list_append): Likewise.
(print_cmdline_list): Likewise.
(cmdline_on_object_only_archive_list_p): Likewise.
(cmdline_object_only_list_append): Likewise.
(cmdline_get_object_only_input_files): Likewise.
(cmdline_arg): Likewise.
(setup_section): Likewise.
(copy_section): Likewise.
(cmdline_fopen_temp): Likewise.
(cmdline_add_object_only_section): Likewise.
(cmdline_emit_object_only_section): Likewise.
(cmdline_extract_object_only_section): Likewise.
(cmdline_check_object_only_section): Likewise.
(cmdline_remove_object_only_files): Likewise.
(lang_init): Take a bfd_boolean argument to supprt object-only
output. Call cmdline_lists_init.
(load_symbols): Call cmdline_on_object_only_archive_list_p
to check if an archive member should be loaded.
(lang_process): Handle object-only link.
* ldlang.h (lang_init): Take a bfd_boolean argument.
(cmdline_enum_type): New.
(cmdline_header_type): Likewise.
(cmdline_file_type): Likewise.
(cmdline_bfd_type): Likewise.
(cmdline_union_type): Likewise.
(cmdline_list_type): Likewise.
(cmdline_emit_object_only_section): Likewise.
(cmdline_check_object_only_section): Likewise.
(cmdline_remove_object_only_files): Likewise.
* ldmain.c (main): Call xatexit with
cmdline_remove_object_only_files. Pass FALSE to lang_init,
ldexp_init and ldexp_finish. Use ld_parse_linker_script.
Set link_info.output_bfd to NULL after close. Call
cmdline_emit_object_only_section if needed.
(add_archive_element): Call cmdline_check_object_only_section.
(ld_parse_linker_script): New.
* ldmain.h (ld_parse_linker_script): New.
* plugin.c (plugin_maybe_claim): Call
cmdline_check_object_only_section on claimed IR files.
* scripttempl/elf.sc: Also discard .gnu_object_only sections.
* scripttempl/elf64hppa.sc: Likewise.
* scripttempl/elfxtensa.sc: Likewise.
* scripttempl/mep.sc: Likewise.
* scripttempl/pe.sc: Likewise.
* scripttempl/pep.sc: Likewise.
* emultempl/aarch64elf.em (gld${EMULATION_NAME}_finish): Replace
finish_default with ldelf_finish.
* emultempl/alphaelf.em (alpha_finish): Likewise.
* emultempl/avrelf.em (avr_finish): Likewise.
* emultempl/elf.em (ld_${EMULATION_NAME}_emulation): Likewise.
* emultempl/ppc32elf.em (ppc_finish): Likewise.
* emultempl/ppc64elf.em (gld${EMULATION_NAME}_finish): Likewise.
* emultempl/spuelf.em (gld${EMULATION_NAME}_finish): Likewise.
* testsuite/ld-plugin/lto-10.out: New file.
* testsuite/ld-plugin/lto-10a.c: Likewise.
* testsuite/ld-plugin/lto-10b.c: Likewise.
* testsuite/ld-plugin/lto-10r.d: Likewise.
* testsuite/ld-plugin/lto-4.out: Likewise.
* testsuite/ld-plugin/lto-4a.c: Likewise.
* testsuite/ld-plugin/lto-4b.c: Likewise.
* testsuite/ld-plugin/lto-4c.c: Likewise.
* testsuite/ld-plugin/lto-4r-a.d: Likewise.
* testsuite/ld-plugin/lto-4r-b.d: Likewise.
* testsuite/ld-plugin/lto-4r-c.d: Likewise.
* testsuite/ld-plugin/lto-4r-d.d: Likewise.
* testsuite/ld-plugin/lto.exp (lto_link_tests): Prepare for
"LTO 4[acd]", "lto-4r-[abcd]" and "LTO 10" tests.
(lto_run_tests): Add "LTO 4[acd]" and "LTO 10" tests.
Build liblto-4.a. Run "lto-4r-[abcd]" tests.
Run lto-10r and create tmpdir/lto-10.o.
Add test for nm on mixed LTO/non-LTO object.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
This fixes multiple readelf memory leaks:
- The check functions used to validate separate debug info files
opened and read file data but didn't release the memory nor close
the file.
- A string table was being re-read into a buffer, leaking the old
contents.
- Decompressed section contents leaked.
* dwarf.c (check_gnu_debuglink): Always call close_debug_file.
(check_gnu_debugaltlink): Likewise.
* readelf.c (process_section_headers): Don't read string_table
again if we already have it.
(maybe_expand_or_relocate_section): Add decomp_buf param to
return new uncompressed buffer.
(dump_section_as_strings, filedata->string_table): Free any
uncompressed buffer.
(process_file): Call close_debug_file rather than freeing
various filedata components.
This patch adds support for Guarded Control Stack in AArch64 linker.
This patch implements the following:
1) Defines GNU_PROPERTY_AARCH64_FEATURE_1_GCS bit for GCS in
GNU_PROPERTY_AARCH64_FEATURE_1_AND macro.
2) Adds readelf support to read and print the GCS feature in GNU
properties in AArch64.
Displaying notes found in: .note.gnu.property
[ ]+Owner[ ]+Data size[ ]+Description
GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0
Properties: AArch64 feature: GCS
3) Adds support for the "-z gcs" linker option and document all the values
allowed with this option (-z gcs[=always|never|implicit]) where "-z gcs" is
equivalent to "-z gcs=always". When '-z gcs' option is omitted from the
command line, it defaults to "implicit" and relies on the GCS feature
marking in GNU properties.
4) Adds support for the "-z gcs-report" linker option and document all the
values allowed with this option (-z gcs-report[=none|warning|error]) where
"-z gcs-report" is equivalent to "-z gcs-report=warning". When this option
is omitted from the command line, it defaults to "warning".
The ABI changes adding GNU_PROPERTY_AARCH64_FEATURE_1_GCS to the GNU
property GNU_PROPERTY_AARCH64_FEATURE_1_AND is merged into main and
can be found in [1].
[1] https://github.com/ARM-software/abi-aa/blob/main/sysvabi64/sysvabi64.rst
Co-authored-by: Matthieu Longo <matthieu.longo@arm.com>
Co-authored-by: Yury Khrustalev <yury.khrustalev@arm.com>
In some cases using section names instead of symbol names for
displaying an address is more useful.
If the symbol falls outside the section where the address is
then likely it is not useful to display the address relative to.
And if symbols are stripped from a binary then printing the
section that contains the address is more useful than printing
<no sym>.
Filter symbols before binary searching for the right symbol to display
for a given address, such that only displayable symbols are present and
at most one per address.
The current logic does not handle multiple symbols for the same address
well if some of them are empty, the selected symbol is not stable with
respect to an unrelated symbol table change and on aarch64 often mapping
symbols are displayed which is not useful.
Filtering solves these problems at the cost of a linear scan of the
sorted symbol table.
The heuristic to select the best symbol likely could be improved, this
patch aims to improve symbol display for RELR without complex logic
such that the output is useful and stable for ld tests.
If a BFD user is making use of a function like
bfd_get_section_contents to read a section into a pre-allocated
buffer, then that BFD user might also want to make use of
_bfd_section_size_insane prior to allocating the buffer they intend to
use in order to validate that the buffer size that plan to allocate is
sane.
This commit makes _bfd_section_size_insane public, by renaming it to
bfd_section_size_insane.
I've updated the existing uses within bfd/, I don't believe this
function is used outside of bfd/ currently.
One place that I plan to make use of this function is in
gdb/gdb_bfd.c, in the function gdb_bfd_get_full_section_contents.
This change isn't included in this commit, but will come later if/when
this has been merged into bfd.
There should be no change in behaviour after this commit.
bfd/
* bfd-in2.h (bfd_section_size_insane): Add declaration.
* compress.c (bfd_get_full_section_contents): Update for new name
of _bfd_section_size_insane.
(bfd_init_section_compress_status): Likewise.
* dwarf2.c (read_section): Likewise.
(_bfd_dwarf2_slurp_debug_info): Likewise.
* libbfd.h (_bfd_section_size_insane): Remove declaration.
* section.c (_bfd_section_size_insane): Rename to ...
(bfd_section_size_insane): ... this.
binutils/
* readelf.c (uncompress_section_contents): Update comment to
account for new name of _bfd_section_size_insane.
Adds two new external authors to etc/update-copyright.py to cover
bfd/ax_tls.m4, and adds gprofng to dirs handled automatically, then
updates copyright messages as follows:
1) Update cgen/utils.scm emitted copyrights.
2) Run "etc/update-copyright.py --this-year" with an extra external
author I haven't committed, 'Kalray SA.', to cover gas testsuite
files (which should have their copyright message removed).
3) Build with --enable-maintainer-mode --enable-cgen-maint=yes.
4) Check out */po/*.pot which we don't update frequently.
Define NT_X86_SHSTK which is the note for x86 Shadow Stack (SHSTK) to
support Intel SHSTK in Linux kernel.
For now only userspace shadow stack and kernel IBT are supported by the
linux kernel. This note should be used instead of NT_X86_CET introduced
in the commit "x86: Add NT_X86_CET note", as it is outdated and only
used by old binutils versions.
PR 31062
* objdump.c (decompressed_dumps): New local variable. (usage): Mention the -z/--decompress option. (long_options): Add --decompress. (dump_section_header): Add "COMPRESSED" to the Flags field of any compressed section. (dump_section): Warn users when dumping a compressed section. (display_any_bfd): Decompress the section if decompressed_dumps is true. (main): Handle the -z/--decompress option.
* NEWS: Mention the new feature.
* doc/binutils.texi: Document the new feature.
* testsuite/binutils-all/objdump.s: Update expected output.
* testsuite/binutils-all/objdump.exp: Add test of -Z -s.
* testsuite/binutils-all/objdump.Zs: New file.
* readelf.c (maybe_expand_or_relocate_section): New function. Contains common code found in dump functions. Adds a note message if a compressed section is not being decompressed. (dump_section_as_strings): Use new function. (dump_section_as_bytes): Likewise.
This patch adds the R_MICROBLAZE_32_NONE relocation type.
This is a 32-bit reloc that stores the 32-bit pc relative
value in two words (with an imm instruction).
Add test case to gas test suite.
Signed-off-by: Neal Frager <neal.frager@amd.com>
Signed-off-by: Michael J. Eager <eager@eagercon.com>
This patches adds new bsefi and bsifi instructions.
BSEFI- The instruction shall extract a bit field from a
register and place it right-adjusted in the destination register.
The other bits in the destination register shall be set to zero.
BSIFI- The instruction shall insert a right-adjusted bit field
from a register at another position in the destination register.
The rest of the bits in the destination register shall be unchanged.
Further documentation of these instructions can be found here:
https://docs.xilinx.com/v/u/en-US/ug984-vivado-microblaze-ref
This patch has been tested for years of AMD Xilinx Yocto
releases as part of the following patch set:
https://github.com/Xilinx/meta-xilinx/tree/master/meta-microblaze/recipes-devtools/binutils/binutils
Signed-off-by: nagaraju <nagaraju.mekala@amd.com>
Signed-off-by: Ibai Erkiaga <ibai.erkiaga-elorza@amd.com>
Signed-off-by: Neal Frager <neal.frager@amd.com>
Signed-off-by: Michael J. Eager <eager@eagercon.com>
The PLT entry in executables and shared libraries contains an indirect
branch, like
jmp *foo@GOTPCREL(%rip)
push $index_foo
jmp .PLT0
or
endbr64
jmp *foo@GOTPCREL(%rip)
NOP padding
which is used to branch to the function, foo, defined in another object.
Each R_X86_64_JUMP_SLOT relocation has a corresponding PLT entry.
The dynamic tags have been added to the x86-64 psABI to mark such PLT
entries:
6d824a52a4
Add an x86-64 linker option, -z mark-plt, to mark PLT entries with
#define DT_X86_64_PLT (DT_LOPROC + 0)
#define DT_X86_64_PLTSZ (DT_LOPROC + 1)
#define DT_X86_64_PLTENT (DT_LOPROC + 3)
1. DT_X86_64_PLT: The address of the procedure linkage table.
2. DT_X86_64_PLTSZ: The total size, in bytes, of the procedure linkage
table.
3. DT_X86_64_PLTENT: The size, in bytes, of a procedure linkage table
entry.
and set the r_addend field of the R_X86_64_JUMP_SLOT relocation to the
memory offset of the indirect branch instruction. The dynamic linker
can use these tags to update the PLT section to direct branch.
bfd/
* elf-linker-x86.h (elf_linker_x86_params): Add mark_plt.
* elf64-x86-64.c (elf_x86_64_finish_dynamic_symbol): Set the
r_addend of R_X86_64_JUMP_SLOT to the indirect branch offset
in PLT entry for -z mark-plt.
* elfxx-x86.c (_bfd_x86_elf_size_dynamic_sections): Add
DT_X86_64_PLT, DT_X86_64_PLTSZ and DT_X86_64_PLTENT for
-z mark-plt.
(_bfd_x86_elf_finish_dynamic_sections): Set DT_X86_64_PLT,
DT_X86_64_PLTSZ and DT_X86_64_PLTENT.
(_bfd_x86_elf_get_synthetic_symtab): Ignore addend for
JUMP_SLOT relocation.
(_bfd_x86_elf_link_setup_gnu_properties): Set
plt_indirect_branch_offset.
* elfxx-x86.h (elf_x86_plt_layout): Add plt_indirect_branch_offset.
binutils/
* readelf.c (get_x86_64_dynamic_type): New function.
(get_dynamic_type): Call get_x86_64_dynamic_type.
include/
* elf/x86-64.h (DT_X86_64_PLT): New.
(DT_X86_64_PLTSZ): Likewise.
(DT_X86_64_PLTENT): Likewise.
ld/
* ld.texi: Document -z mark-plt and -z nomark-plt.
* emulparams/elf32_x86_64.sh: Source x86-64-plt.sh.
* emulparams/elf_x86_64.sh: Likewise.
* emulparams/x86-64-plt.sh: New file.
* testsuite/ld-x86-64/mark-plt-1.s: Likewise.
* testsuite/ld-x86-64/mark-plt-1a-x32.d: Likewise.
* testsuite/ld-x86-64/mark-plt-1a.d: Likewise.
* testsuite/ld-x86-64/mark-plt-1b-x32.d: Likewise.
* testsuite/ld-x86-64/mark-plt-1b.d: Likewise.
* testsuite/ld-x86-64/mark-plt-1c-x32.d: Likewise.
* testsuite/ld-x86-64/mark-plt-1c.d: Likewise.
* testsuite/ld-x86-64/mark-plt-1d-x32.d: Likewise.
* testsuite/ld-x86-64/mark-plt-1d.d: Likewise.
* testsuite/ld-x86-64/x86-64.exp: Run -z mark-plt tests.
PR 30684
* readelf.c (extra_sym_info): New variable. (section_name_valid): Also check for filedata being NULL. (section_name_print): Delete. (section_index_real): New function. Returns true if the given section index references a real section. (print_symbol): Rename to print_sumbol_name. (printable_section_name): Use a rotating array of static buffers for the return string. (printable_section_name_from_index): Merge code from dump_relocations and get_symbol_index_type into here. (long_option_values): Add OPTION_NO_EXTRA_SYM_INFO. (options): Add "extra-sym-info" and "no-extra-sym-info". (usage): Mention new options. (parse_args): Parse new options. (get_symbol_index_type): Delete. (print_dynamic_symbol_size): Rename to print_symbol_size. (print_dynamic_symbol): Rename to print_symbol. (print_symbol_table_heading): New function. (process_symbol_table): Use new function.
* doc/binutils.texi: Document the new option.
* NEWS: Mention the new feature.
The Scalable Matrix Extension v2 (SME2) defines a new register, ZT0, that
the Linux Kernel handles through a new NT_ARM_ZT register set.
Teach binutils/BFD about it so that gdb can make use of it for reading
and writing core files. This also enables readelf/objdump to show the
correct identification for the NT_ARM_ZT register set.
Validated under Fast Models.
This replaces sprintf and strcat calls with stpcpy, and makes use of
sprintf return value rather than using strlen, for get_machine_flags.
decode_NDS32_machine_flags made use of snprintf, which is arguably the
"correct" way to do things if there can be a buffer overflow. In this
case I don't think there can be, the buffer is 1k in size which is at
least 5 times more than needed. What's more, snprintf returns the
count of chars that would be output given no buffer limit, which means
code like
r += snprintf (buf + r, size - r, ...);
r += snprintf (buf + r, size - r, ...);
is just wrong. There needs to be a check on the return value in order
to prevent buf + r being out of bounds for the second snprintf call.
BTW, if you look closely you'll see the return value of the decode
functions is unused. I admit to getting a little carried away with
writing "out = stpcpy (out, ...):" in each of the decode functions and
didn't notice that until get_machine_flags was trimmed down to a much
smaller size. When I did notice, I decided it's not such a bad thing.
* readelf.c (decode_ARC_machine_flags, decode_ARM_machine_flags),
(decode_AVR_machine_flags, decode_NDS32_machine_flags),
(decode_AMDGPU_machine_flags): Use stpcpy and sprintf return
value. Return end of string.
(decode_BLACKFIN_machine_flags, decode_FRV_machine_flags),
(decode_IA64_machine_flags, decode_LOONGARCH_machine_flags),
(decode_M68K_machine_flags, decode_MeP_machine_flags),
(decode_MIPS_machine_flags, decode_MSP430_machine_flags),
(decode_PARISC_machine_flags, decode_RISCV_machine_flags),
(decode_RL78_machine_flags, decode_RX_machine_flags),
(decode_SH_machine_flags, decode_SPARC_machine_flags),
(decode_V800_machine_flags, decode_V850_machine_flags),
(decode_Z80_machine_flags): New functions, split out from..
(get_machine_flags): ..here. Similarly use stpcpy.
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.
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>
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>
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.
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.