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

Roger Ferrer Ibanez via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 17 06:19:36 PDT 2019


rogfer01 added a comment.
Herald added subscribers: benna, psnobl, jocewei, PkmX, rkruppe, the_o, brucehoult, MartinMosbeck, jrtc27.
Herald added a project: LLVM.

I don't like resurrecting old reviews. This is just a warning in advance of a future issue we will have with the RISC-V backend when exception handling is enabled (it is not yet upstream).

`DwarfDebug` is using `AsmPrinter::EmitLabelDifferenceAsULEB128` which ends calling `MCObjectStreamer::emitAbsoluteSymbolDiffAsULEB128` which calls `MCObjectStreamer::absoluteSymbolDiff`. That last function checks `MCAsmBackend::requiresDiffExpressionRelocations` to tell if it can simplify the label difference.

It happens that the function `AsmPrinter::EmitLabelDifferenceAsULEB128` is also used by `EHStreamer`.

When relaxation is enabled, we end with an invalid `.eh_frame` section. GNU ld rejects those and so do tools like `llvm-objdump --dwarf=frames`.

After some analysis, I think the reason why the `.eh_frame` is rejected is because, some of the label differences must be resolved in the final object.  At least for the `Length` field (I'm using this reference: https://refspecs.linuxfoundation.org/LSB_3.0.0/LSB-PDA/LSB-PDA/ehframechpt.html) but maybe other values currently emitted as label differences by `EHStreamer` too (I'm not well versed in this topic).

Now, the RISC-V backend returns true for `MCAsmBackend::requiresDiffExpressionRelocations` when relaxation is enabled.  This means no label difference is folded in `.eh_frame`. Instead we end with a field `Length` that is just emitted as zeroes and should be patched up by a relocation (emitted in `.rela.eh_frame`), but the code that looks at the `.eh_frame` section does not seem to care with relocations in that field.

@simoncook @asb perhaps you were already aware of this issue?

Thank you!


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D45181/new/

https://reviews.llvm.org/D45181





More information about the llvm-commits mailing list