Skip to content

Commit 0766a59

Browse files
committed
[ELF] .llvm.call-graph-profile: support CREL
https://reviews.llvm.org/D105217 added RELA support. This patch adds CREL support.
1 parent 182e1c7 commit 0766a59

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
@@ -1003,6 +1003,15 @@ processCallGraphRelocations(SmallVector<uint32_t, 32> &symbolIndices,
10031003
for (size_t i = 0, e = objSections.size(); i < e; ++i) {
10041004
const Elf_Shdr_Impl<ELFT> &sec = objSections[i];
10051005
if (sec.sh_info == inputObj->cgProfileSectionIndex) {
1006+
if (sec.sh_type == SHT_CREL) {
1007+
auto crels =
1008+
CHECK(obj.crels(sec), "could not retrieve cg profile rela section");
1009+
for (const auto &rel : crels.first)
1010+
symbolIndices.push_back(rel.getSymbol(false));
1011+
for (const auto &rel : crels.second)
1012+
symbolIndices.push_back(rel.getSymbol(false));
1013+
break;
1014+
}
10061015
if (sec.sh_type == SHT_RELA) {
10071016
ArrayRef<typename ELFT::Rela> relas =
10081017
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)