[PATCH] D117317: [MC] Put the Pending Fixups into location symbol's fragment
luxufan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 14 07:24:00 PST 2022
StephenFan created this revision.
Herald added subscribers: luke957, frasercrmck, luismarques, apazos, sameer.abuasal, s.egerton, Jim, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, hiraditya.
StephenFan requested review of this revision.
Herald added subscribers: llvm-commits, MaskRay.
Herald added a project: LLVM.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D117317
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
@@ -22,6 +22,10 @@
# CHECK-NEXT: 0x0 R_RISCV_NONE - 0x9
# CHECK-NEXT: 0x0 R_RISCV_32 - 0x9
# CHECK-NEXT: 0x0 R_RISCV_64 - 0x9
+
+# CHECK: Section ({{.*}}) .rela.data
+# CHECK-NEXT: 0x0 R_RISCV_32 - 0x6
+# CHECK-NEXT: }
.text
ret
nop
@@ -38,6 +42,8 @@
.reloc 0, BFD_RELOC_32, 9
.reloc 0, BFD_RELOC_64, 9
+ .reloc foo, R_RISCV_32, 6
+
.data
.globl foo
foo:
Index: llvm/lib/MC/MCObjectStreamer.cpp
===================================================================
--- llvm/lib/MC/MCObjectStreamer.cpp
+++ llvm/lib/MC/MCObjectStreamer.cpp
@@ -120,7 +120,29 @@
}
flushPendingLabels(PendingFixup.DF, PendingFixup.DF->getContents().size());
PendingFixup.Fixup.setOffset(PendingFixup.Sym->getOffset());
- PendingFixup.DF->getFixups().push_back(PendingFixup.Fixup);
+
+ // If the location symbol to relocate is in MCEncodedFragmentWithFixups,
+ // put the Fixup into location symbol's fragment. Otherwise
+ // put into PendingFixup.DF
+ MCFragment *SymFragment = PendingFixup.Sym->getFragment();
+ switch (SymFragment->getKind()) {
+ case MCFragment::FT_Relaxable:
+ case MCFragment::FT_Dwarf:
+ case MCFragment::FT_PseudoProbe:
+ cast<MCEncodedFragmentWithFixups<8, 1>>(SymFragment)
+ ->getFixups()
+ .push_back(PendingFixup.Fixup);
+ break;
+ case MCFragment::FT_Data:
+ case MCFragment::FT_CVDefRange:
+ cast<MCEncodedFragmentWithFixups<32, 4>>(SymFragment)
+ ->getFixups()
+ .push_back(PendingFixup.Fixup);
+ break;
+ default:
+ PendingFixup.DF->getFixups().push_back(PendingFixup.Fixup);
+ break;
+ }
}
PendingFixups.clear();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117317.399994.patch
Type: text/x-patch
Size: 1869 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220114/778be9c5/attachment.bin>
More information about the llvm-commits
mailing list