aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm-project/llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp')
-rw-r--r--contrib/llvm-project/llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/contrib/llvm-project/llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp b/contrib/llvm-project/llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp
index 379aaa713a00..88b926fce2aa 100644
--- a/contrib/llvm-project/llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp
+++ b/contrib/llvm-project/llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp
@@ -239,6 +239,16 @@ bool RISCVELFStreamer::requiresFixups(MCContext &C, const MCExpr *Value,
if (B.isInSection() && B.getSection().getKind().isText())
return true;
+ // If A is undefined and B is defined, we should emit ADD/SUB for A-B.
+ // Unfortunately, A may be defined later, but this requiresFixups call has to
+ // eagerly make a decision. For now, emit ADD/SUB unless A is .L*. This
+ // heuristic handles many temporary label differences for .debug_* and
+ // .apple_types sections.
+ //
+ // TODO Implement delayed relocation decision.
+ if (!A.isInSection() && !A.isTemporary() && B.isInSection())
+ return true;
+
// Support cross-section symbolic differences ...
return A.isInSection() && B.isInSection() &&
A.getSection().getName() != B.getSection().getName();