[PATCH] D45181: [RISCV] Add diff relocation support for RISC-V

Simon Cook via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 22 08:05:59 PDT 2018


simoncook updated this revision to Diff 148007.
simoncook added a comment.

Rebased on top of tree, and applied changes as per Alex's review.

Regarding InSet, I've tried to put a comment that explains its usage, but I'm not sure if it explains why it's there too well (or whether this is really should have a `FIXME: The use of InSet = SymbolSize is a hack`, similiar to `evaluateAsAbsolute` (line 461) ).

As far as I can tell, InSet is used as a flag to determine whether to allow expressions to evaluate as an absolute across sections (as this is otherwise an error), and the ELF object emitter re-uses this when emitting the size of a symbol in the symbol table (this seems the most reliable way of identifying an explicit "IsSymbolSize" through the expression evaluator).

The way our linker relaxtion works is that the size in the symbol table is a constant which represents the current symbol size, and the linker adjusts this before emitting its final binary based on how much relaxation occurs. Without this change we would emit a symbol size of zero, and a pair of relocations in the `.symtab` section, which I don't think the linker understands, or is able to support easily (if at all). Using this approach generates the binary we would expect.


Repository:
  rL LLVM

https://reviews.llvm.org/D45181

Files:
  include/llvm/MC/MCAsmBackend.h
  include/llvm/MC/MCFixup.h
  lib/MC/MCAsmBackend.cpp
  lib/MC/MCAssembler.cpp
  lib/MC/MCExpr.cpp
  lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
  lib/Target/RISCV/MCTargetDesc/RISCVELFObjectWriter.cpp
  lib/Target/RISCV/MCTargetDesc/RISCVMCExpr.cpp
  test/MC/RISCV/fixups-expr.s
  test/MC/RISCV/hilo-constaddr-expr.s
  test/MC/RISCV/hilo-constaddr.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45181.148007.patch
Type: text/x-patch
Size: 13906 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180522/68ee5443/attachment.bin>


More information about the llvm-commits mailing list