[all-commits] [llvm/llvm-project] 8a900f: [ELF] Merge SHT_RISCV_ATTRIBUTES sections

Fangrui Song via All-commits all-commits at lists.llvm.org
Thu Dec 8 01:53:56 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 8a900f2438b4a167b98404565ad4da2645cc9330
      https://github.com/llvm/llvm-project/commit/8a900f2438b4a167b98404565ad4da2645cc9330
  Author: Fangrui Song <i at maskray.me>
  Date:   2022-12-08 (Thu, 08 Dec 2022)

  Changed paths:
    M lld/ELF/Arch/RISCV.cpp
    M lld/ELF/Driver.cpp
    M lld/ELF/InputFiles.cpp
    M lld/ELF/SyntheticSections.cpp
    M lld/ELF/SyntheticSections.h
    M lld/ELF/Target.h
    M lld/docs/ReleaseNotes.rst
    A lld/test/ELF/lto/riscv-attributes.ll
    A lld/test/ELF/riscv-attributes-place.s
    M lld/test/ELF/riscv-attributes.s
    M llvm/include/llvm/Support/RISCVISAInfo.h

  Log Message:
  -----------
  [ELF] Merge SHT_RISCV_ATTRIBUTES sections

Currently we take the first SHT_RISCV_ATTRIBUTES (.riscv.attributes) as the
output. If we link an object without an extension with an object with the
extension, the output Tag_RISCV_arch may not contain the extension and some
tools like objdump -d will not decode the related instructions.

This patch implements
Tag_RISCV_stack_align/Tag_RISCV_arch/Tag_RISCV_unaligned_access merge as
specified by
https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-elf.adoc#attributes

For the deprecated Tag_RISCV_priv_spec{,_minor,_revision}, dump the attribute to
the output iff all input agree on the value. This is different from GNU ld but
our simple approach should be ok for deprecated tags.

`RISCVAttributeParser::handler` currently warns about unknown tags. This
behavior is retained. In GNU ld arm, tags >= 64 (mod 128) are ignored with a
warning. If RISC-V ever wants to do something similar
(https://github.com/riscv-non-isa/riscv-elf-psabi-doc/issues/352), consider
documenting it in the psABI and changing RISCVAttributeParser.

Like GNU ld, zero value integer attributes and empty string attributes are not
dumped to the output.

Reviewed By: asb, kito-cheng

Differential Revision: https://reviews.llvm.org/D138550




More information about the All-commits mailing list