This is an archive of the discontinued LLVM Phabricator instance.

[WIP][RISCV] Use RISCV_32_PCREL reloc for FDE initial location
AbandonedPublic

Authored by edward-jones on Jul 15 2019, 4:04 AM.

Details

Reviewers
asb
Summary

The default FDE encoding is a 4-byte pc-relative offset, and the standard implementation of MCAsmInfo::getExprForFDESymbol generates a <symbol>-<pc> expression for this (which generates a R_RISCV_ADD32+R_RISCV_SUB32 reloc pair).

For reasons that are still not quite clear, the GNU toolchain generates a R_RISCV_32_PCREL relocation instead of the R_RISCV_ADD32+R_RISCV_SUB32 pair. This patch matches that behavior.

Diff Detail

Event Timeline

edward-jones created this revision.Jul 15 2019, 4:04 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 15 2019, 4:05 AM

Here's a link to the equivalent change made to GAS which should give more context (the commit has since be incorporated into upstream binutils):

https://github.com/riscv/riscv-binutils-gdb/commit/a6cbf936e3dce68114d28cdf60d510a3f78a6d40

I'm leaving this as WIP as I'm missing tests, and I think there's probably a better way to implement this change too (adding the VK_RISCV_PCREL feels like overkill)

asb added a comment.Jul 15 2019, 4:53 AM

Thanks Ed. I came to the same conclusion re the need for emitting R_RISCV_32_PCREL when debuggin some issues over the weekend. I had a different fix though - I'll try to compare vs this and get back to you later today.

@edward-jones Could you please mark this as abandoned, since is has been superseded by D66419?

edward-jones abandoned this revision.Sep 2 2019, 4:42 AM

Superceded by D66419