Skip to content

Commit 7aae895

Browse files
MaskRaytru
authored andcommitted
[ELF] .llvm.call-graph-profile: support CREL
https://reviews.llvm.org/D105217 added RELA support. This patch adds CREL support. (cherry picked from commit 0766a59)
1 parent 32e2000 commit 7aae895

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lld/ELF/Driver.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -991,6 +991,15 @@ processCallGraphRelocations(SmallVector<uint32_t, 32> &symbolIndices,
991991
for (size_t i = 0, e = objSections.size(); i < e; ++i) {
992992
const Elf_Shdr_Impl<ELFT> &sec = objSections[i];
993993
if (sec.sh_info == inputObj->cgProfileSectionIndex) {
994+
if (sec.sh_type == SHT_CREL) {
995+
auto crels =
996+
CHECK(obj.crels(sec), "could not retrieve cg profile rela section");
997+
for (const auto &rel : crels.first)
998+
symbolIndices.push_back(rel.getSymbol(false));
999+
for (const auto &rel : crels.second)
1000+
symbolIndices.push_back(rel.getSymbol(false));
1001+
break;
1002+
}
9941003
if (sec.sh_type == SHT_RELA) {
9951004
ArrayRef<typename ELFT::Rela> relas =
9961005
CHECK(obj.relas(sec), "could not retrieve cg profile rela section");

lld/test/ELF/cgprofile-rela.test

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
# RUN: ld.lld --no-call-graph-profile-sort %t.o -o %t
99
# RUN: llvm-nm --no-sort %t | FileCheck %s --check-prefix=NO-CG
1010

11+
# RUN: yaml2obj -DTYPE=SHT_CREL %s -o %tcrel.o
12+
# RUN: ld.lld --call-graph-profile-sort=hfsort %tcrel.o -o %t
13+
# RUN: llvm-nm --no-sort %t | FileCheck %s
14+
1115
# CHECK: 0000000000201124 t D
1216
# CHECK: 0000000000201122 t C
1317
# CHECK: 0000000000201128 t B
@@ -60,7 +64,7 @@ Sections:
6064
- Weight: 30
6165
- Weight: 90
6266
- Name: .rela.llvm.call-graph-profile
63-
Type: SHT_RELA
67+
Type: [[TYPE=SHT_RELA]]
6468
Info: .llvm.call-graph-profile
6569
Relocations:
6670
- Offset: 0x0

0 commit comments

Comments
 (0)