[llvm] 08b29b1 - [MC] Put the Pending Fixups into location symbol's fragment
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 25 19:23:30 PST 2022
Author: luxufan
Date: 2022-01-26T11:21:56+08:00
New Revision: 08b29b175b1561af181e768587ffaf5f2bf4eb8d
URL: https://github.com/llvm/llvm-project/commit/08b29b175b1561af181e768587ffaf5f2bf4eb8d
DIFF: https://github.com/llvm/llvm-project/commit/08b29b175b1561af181e768587ffaf5f2bf4eb8d.diff
LOG: [MC] Put the Pending Fixups into location symbol's fragment
Differential Revision: https://reviews.llvm.org/D117317
Added:
Modified:
llvm/lib/MC/MCObjectStreamer.cpp
llvm/test/MC/RISCV/reloc-directive.s
Removed:
################################################################################
diff --git a/llvm/lib/MC/MCObjectStreamer.cpp b/llvm/lib/MC/MCObjectStreamer.cpp
index 6604d7988c4ca..ca462b3e558c9 100644
--- a/llvm/lib/MC/MCObjectStreamer.cpp
+++ b/llvm/lib/MC/MCObjectStreamer.cpp
@@ -120,7 +120,29 @@ void MCObjectStreamer::resolvePendingFixups() {
}
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();
}
diff --git a/llvm/test/MC/RISCV/reloc-directive.s b/llvm/test/MC/RISCV/reloc-directive.s
index 98c0efd06b44d..d4c20cde060bb 100644
--- a/llvm/test/MC/RISCV/reloc-directive.s
+++ b/llvm/test/MC/RISCV/reloc-directive.s
@@ -22,6 +22,19 @@
# 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: }
+
+# CHECK: Section ({{.*}}) .rela.debug_line {
+# CHECK-NEXT: 0x0 R_RISCV_32 - 0x6
+# CHECK-NEXT: }
+
+# CHECK: Section ({{.*}}) .rela.pseudoprobe {
+# CHECK-NEXT: 0x0 R_RISCV_32 - 0x6
+# CHECK-NEXT: }
+
.text
ret
nop
@@ -38,9 +51,21 @@
.reloc 0, BFD_RELOC_32, 9
.reloc 0, BFD_RELOC_64, 9
+ .reloc foo, R_RISCV_32, 6
+ .reloc line, R_RISCV_32, 6
+ .reloc probe, R_RISCV_32, 6
+
.data
.globl foo
foo:
.word 0
.word 0
.word 0
+
+.section .debug_line,"", at progbits
+line:
+ .word 0
+
+.section .pseudoprobe,"", at progbits
+probe:
+ .word 0
More information about the llvm-commits
mailing list