diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp index 294e69f89fe6f..c5f8a42bab6a5 100644 --- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp +++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp @@ -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(Value); diff --git a/llvm/test/MC/RISCV/riscv64-64b-pcrel.s b/llvm/test/MC/RISCV/riscv64-64b-pcrel.s index f2b84b17ede7f..593820b8778c3 100644 --- a/llvm/test/MC/RISCV/riscv64-64b-pcrel.s +++ b/llvm/test/MC/RISCV/riscv64-64b-pcrel.s @@ -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: