[all-commits] [llvm/llvm-project] a0d8a5: [RISCV][MC] Implement mapping symbols

Job Noorman via All-commits all-commits at lists.llvm.org
Fri Jul 28 02:13:20 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a0d8a53c7d0e6ca1c94b5d5c4a65790dd5705ef8
      https://github.com/llvm/llvm-project/commit/a0d8a53c7d0e6ca1c94b5d5c4a65790dd5705ef8
  Author: Job Noorman <jnoorman at igalia.com>
  Date:   2023-07-28 (Fri, 28 Jul 2023)

  Changed paths:
    M lld/test/ELF/riscv-variant-cc.s
    M llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp
    M llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.h
    A llvm/test/MC/RISCV/mapping-across-sections.s
    A llvm/test/MC/RISCV/mapping-within-section.s

  Log Message:
  -----------
  [RISCV][MC] Implement mapping symbols

Mapping symbols [1] are special ELF symbols that can be inserted to
indicate regions of code or data. A sequence of data bytes is indicated
by a `$d` (or `$d.<any>`) symbol pointing to its start while a sequence
of instructions uses a `$x` (or `$x.<any>`) symbol. This can be used,
for example, to assist disassembling a memory region containing both
data and code.

This patch implements mapping symbols for RISC-V, copying the
implementation mostly from the AArch64 target.

Note that the `$x<ISA>` mapping symbol, indicating an instruction
sequence with a specific ISA extension, is not implemented by this
patch. As far as I can tell, binutils doesn't implement this yet either.

Note that this patch uses the same symbol naming convention as the
AArch64 target: always use `$x.i` and `$d.i` (where `i` is a
monotonically increasing counter). This differs from binutils where all
symbols are named `$x` or `$d` (causing multiple symbol having the same
name). I'm not not sure whether it makes more sense to avoid duplicate
symbol names or be consistent with binutils.

Note that the handling of nop-slides inserted for alignment differs from
binutils: binutils always marks the nops as instructions (`$x`) while
this patch doesn't insert a symbol for the nops (so the last inserted
symbol is used). I believe binutil's behavior makes most sense but this
seems difficult to implement in LLVM as the insertion of nops is handled
by `RISCVAsmBackend`. At this point, inserting ELF symbols seems
impossible. Any ideas for how to handle this would be appreciated.

[1]: https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-elf.adoc#mapping-symbol

Depends on D156190 and D156236

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


  Commit: ec4d061671cf03eab5e915942e3c6f60ddc2729d
      https://github.com/llvm/llvm-project/commit/ec4d061671cf03eab5e915942e3c6f60ddc2729d
  Author: Job Noorman <jnoorman at igalia.com>
  Date:   2023-07-28 (Fri, 28 Jul 2023)

  Changed paths:
    M llvm/test/ExecutionEngine/JITLink/RISCV/ELF_branch.s

  Log Message:
  -----------
  [JITLink][RISCV] Fix tests after D154958


Compare: https://github.com/llvm/llvm-project/compare/9a0164a0c66c...ec4d061671cf


More information about the All-commits mailing list