aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/MC/ELFObjectWriter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/MC/ELFObjectWriter.cpp')
-rw-r--r--llvm/lib/MC/ELFObjectWriter.cpp25
1 files changed, 5 insertions, 20 deletions
diff --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp
index 534c263..fec77d2 100644
--- a/llvm/lib/MC/ELFObjectWriter.cpp
+++ b/llvm/lib/MC/ELFObjectWriter.cpp
@@ -1127,14 +1127,6 @@ uint64_t ELFWriter::writeObject(MCAssembler &Asm, const MCAsmLayout &Layout) {
OWriter.TargetObjectWriter->addTargetSectionFlags(Ctx, Section);
}
- MCSectionELF *CGProfileSection = nullptr;
- if (!Asm.CGProfile.empty()) {
- CGProfileSection = Ctx.getELFSection(".llvm.call-graph-profile",
- ELF::SHT_LLVM_CALL_GRAPH_PROFILE,
- ELF::SHF_EXCLUDE, 16);
- SectionIndexMap[CGProfileSection] = addToSectionTable(CGProfileSection);
- }
-
for (MCSectionELF *Group : Groups) {
// Remember the offset into the file for this section.
const uint64_t SecStart = align(Group->getAlignment());
@@ -1186,17 +1178,6 @@ uint64_t ELFWriter::writeObject(MCAssembler &Asm, const MCAsmLayout &Layout) {
}
}
- if (CGProfileSection) {
- uint64_t SecStart = W.OS.tell();
- for (const MCAssembler::CGProfileEntry &CGPE : Asm.CGProfile) {
- W.write<uint32_t>(CGPE.From->getSymbol().getIndex());
- W.write<uint32_t>(CGPE.To->getSymbol().getIndex());
- W.write<uint64_t>(CGPE.Count);
- }
- uint64_t SecEnd = W.OS.tell();
- SectionOffsets[CGProfileSection] = std::make_pair(SecStart, SecEnd);
- }
-
{
uint64_t SecStart = W.OS.tell();
StrTabBuilder.write(W.OS);
@@ -1471,7 +1452,11 @@ void ELFObjectWriter::recordRelocation(MCAssembler &Asm,
return;
unsigned Type = TargetObjectWriter->getRelocType(Ctx, Target, Fixup, IsPCRel);
- bool RelocateWithSymbol = shouldRelocateWithSymbol(Asm, RefA, SymA, C, Type);
+ const auto *Parent = cast<MCSectionELF>(Fragment->getParent());
+ // Emiting relocation with sybmol for CG Profile to help with --cg-profile.
+ bool RelocateWithSymbol =
+ shouldRelocateWithSymbol(Asm, RefA, SymA, C, Type) ||
+ (Parent->getType() == ELF::SHT_LLVM_CALL_GRAPH_PROFILE);
uint64_t Addend = 0;
FixedValue = !RelocateWithSymbol && SymA && !SymA->isUndefined()