[MC][RISCV] Suppress R_RISCV_{ADD,SUB}32 in .apple_names .apple_types after D127549

This fixes test/DebugInfo/Generic/accel-table-hash-collisions.ll and
cross-cu-inlining.ll when the default triple is riscv. llvm-dwarfdump
--apple-names does not resolve R_RISCV_{ADD,SUB}32 in .apple_names .apple_types
and having ADD/SUB will cause decoding failure `Atom[0]: Error extracting the
value`.
This commit is contained in:
Fangrui Song 2022-07-01 11:15:04 -07:00
parent b764e58865
commit 6e8ec13d3f
2 changed files with 14 additions and 2 deletions

View File

@ -208,7 +208,11 @@ class RISCVELFStreamer : public MCELFStreamer {
static bool requiresFixups(MCContext &C, const MCExpr *Value,
const MCExpr *&LHS, const MCExpr *&RHS) {
auto IsMetadataOrEHFrameSection = [](const MCSection &S) -> bool {
return S.getKind().isMetadata() || S.getName() == ".eh_frame";
// Additionally check .apple_names/.apple_types. They are fixed-size and
// do not need fixups. llvm-dwarfdump --apple-names does not process
// R_RISCV_{ADD,SUB}32 in them.
return S.getKind().isMetadata() || S.getName() == ".eh_frame" ||
S.getName() == ".apple_names" || S.getName() == ".apple_types";
};
const auto *MBE = dyn_cast<MCBinaryExpr>(Value);

View File

@ -18,7 +18,7 @@
# CHECK-NEXT: 0x0 R_RISCV_ADD64 a 0x0
# CHECK-NEXT: 0x0 R_RISCV_SUB64 z 0x0
# CHECK: }
# CHECK: ]
# CHECK-NEXT: ]
.section sx,"aw",@progbits
x:
@ -35,3 +35,11 @@ z:
.section sa
a:
.quad a-z
## .apple_names/.apple_types are fixed-size and do not need fixups.
## llvm-dwarfdump --apple-names does not process R_RISCV_{ADD,SUB}32 in them.
## See llvm/test/DebugInfo/Generic/accel-table-hash-collisions.ll
.section .apple_types
.word 0
.word .Ltypes0-.apple_types
.Ltypes0: