[PATCH] D153260: [RISCV][MC] Implement mapping symbols
Job Noorman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 19 04:00:00 PDT 2023
jobnoorman created this revision.
jobnoorman added reviewers: asb, jrtc27, craig.topper, kito-cheng, MaskRay.
Herald added subscribers: luke, pmatos, VincentWu, vkmr, frasercrmck, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, shiva0217, niosHD, sabuasal, simoncook, johnrusso, rbar, hiraditya, kristof.beyls, arichardson.
Herald added a project: All.
jobnoorman requested review of this revision.
Herald added subscribers: llvm-commits, wangpc, eopXD.
Herald added a project: LLVM.
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.
Note on testing: several tests needed to be updated for this patch. This
was mainly caused by the introduction of new symbols causing the labels
in `llvm-objdump` to change.
[1]: https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-elf.adoc#mapping-symbol
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D153260
Files:
llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp
llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.h
llvm/test/MC/RISCV/align.s
llvm/test/MC/RISCV/mapping-across-sections.s
llvm/test/MC/RISCV/mapping-within-section.s
llvm/test/MC/RISCV/nop-slide.s
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153260.532593.patch
Type: text/x-patch
Size: 7866 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230619/db80667e/attachment.bin>
More information about the llvm-commits
mailing list