[PATCH] D117316: [MC] Support relocation offset of sym+constant form for PendingFixup

luxufan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 25 21:51:08 PST 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rGd606e2330501: [MC] Support constant offset for symbol PendingFixup (authored by StephenFan).
Herald added a subscriber: pcwang-thead.

Changed prior to commit:
  https://reviews.llvm.org/D117316?vs=399992&id=403133#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D117316/new/

https://reviews.llvm.org/D117316

Files:
  llvm/lib/MC/MCObjectStreamer.cpp
  llvm/test/MC/RISCV/reloc-directive.s


Index: llvm/test/MC/RISCV/reloc-directive.s
===================================================================
--- llvm/test/MC/RISCV/reloc-directive.s
+++ llvm/test/MC/RISCV/reloc-directive.s
@@ -25,6 +25,7 @@
 
 # CHECK:      Section ({{.*}}) .rela.data {
 # CHECK-NEXT:   0x0 R_RISCV_32 - 0x6
+# CHECK-NEXT:   0x4 R_RISCV_32 - 0x6
 # CHECK-NEXT: }
 
 # CHECK:      Section ({{.*}}) .rela.debug_line {
@@ -55,6 +56,7 @@
   .reloc line, R_RISCV_32, 6
   .reloc probe, R_RISCV_32, 6
 
+  .reloc foo+4, R_RISCV_32, 6
 .data
 .globl foo
 foo:
Index: llvm/lib/MC/MCObjectStreamer.cpp
===================================================================
--- llvm/lib/MC/MCObjectStreamer.cpp
+++ llvm/lib/MC/MCObjectStreamer.cpp
@@ -119,7 +119,8 @@
       continue;
     }
     flushPendingLabels(PendingFixup.DF, PendingFixup.DF->getContents().size());
-    PendingFixup.Fixup.setOffset(PendingFixup.Sym->getOffset());
+    PendingFixup.Fixup.setOffset(PendingFixup.Sym->getOffset() +
+                                 PendingFixup.Fixup.getOffset());
 
     // If the location symbol to relocate is in MCEncodedFragmentWithFixups,
     // put the Fixup into location symbol's fragment. Otherwise
@@ -838,8 +839,9 @@
     return None;
   }
 
-  PendingFixups.emplace_back(&SRE.getSymbol(), DF,
-                             MCFixup::create(-1, Expr, Kind, Loc));
+  PendingFixups.emplace_back(
+      &SRE.getSymbol(), DF,
+      MCFixup::create(OffsetVal.getConstant(), Expr, Kind, Loc));
   return None;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117316.403133.patch
Type: text/x-patch
Size: 1507 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220126/d7cfef49/attachment.bin>


More information about the llvm-commits mailing list