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

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 1 11:15:08 PDT 2022


Author: Fangrui Song
Date: 2022-07-01T11:15:04-07:00
New Revision: 6e8ec13d3f016da1e6581e2938fb69a932ab09c7

URL: https://github.com/llvm/llvm-project/commit/6e8ec13d3f016da1e6581e2938fb69a932ab09c7
DIFF: https://github.com/llvm/llvm-project/commit/6e8ec13d3f016da1e6581e2938fb69a932ab09c7.diff

LOG: [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`.

Added: 
    

Modified: 
    llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp
    llvm/test/MC/RISCV/riscv64-64b-pcrel.s

Removed: 
    


################################################################################
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<MCBinaryExpr>(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", at 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:


        


More information about the llvm-commits mailing list