Skip to content

Commit a19064d

Browse files
committed
Making the API compatible with non-ELF binaries
1 parent c097d37 commit a19064d

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

llvm/include/llvm/Object/ObjectFile.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ class SymbolRef : public BasicSymbolRef {
198198
/// Get the alignment of this symbol as the actual value (not log 2).
199199
uint32_t getAlignment() const;
200200
uint64_t getCommonSize() const;
201+
uint64_t getSize() const;
201202
Expected<SymbolRef::Type> getType() const;
202203

203204
/// Get section this symbol is defined in reference to. Result is
@@ -482,6 +483,10 @@ inline uint64_t SymbolRef::getCommonSize() const {
482483
return getObject()->getCommonSymbolSize(getRawDataRefImpl());
483484
}
484485

486+
inline uint64_t SymbolRef::getSize() const {
487+
return getObject()->getCommonSymbolSizeImpl(getRawDataRefImpl());
488+
}
489+
485490
inline Expected<section_iterator> SymbolRef::getSection() const {
486491
return getObject()->getSymbolSection(getRawDataRefImpl());
487492
}

llvm/tools/llvm-profgen/ProfiledBinary.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ void ProfiledBinary::load() {
257257
if (ShowDisassemblyOnly)
258258
decodePseudoProbe(Obj);
259259

260-
populateSymbolsFromElf(Obj);
260+
populateSymbolsFromBinary(Obj);
261261

262262
// Disassemble the text sections.
263263
disassemble(Obj);
@@ -822,10 +822,10 @@ void ProfiledBinary::populateSymbolAddressList(const ObjectFile *Obj) {
822822
}
823823
}
824824

825-
void ProfiledBinary::populateSymbolsFromElf(const ObjectFile *Obj) {
826-
// Load binary functions from ELF symbol table when DWARF info is incomplete
825+
void ProfiledBinary::populateSymbolsFromBinary(const ObjectFile *Obj) {
826+
// Load binary functions from symbol table when Debug info is incomplete
827827
StringRef FileName = Obj->getFileName();
828-
for (const ELFSymbolRef Symbol : Obj->symbols()) {
828+
for (const SymbolRef &Symbol : Obj->symbols()) {
829829
const SymbolRef::Type Type = unwrapOrError(Symbol.getType(), FileName);
830830
const uint64_t Addr = unwrapOrError(Symbol.getAddress(), FileName);
831831
const StringRef Name = unwrapOrError(Symbol.getName(), FileName);

llvm/tools/llvm-profgen/ProfiledBinary.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ class ProfiledBinary {
357357
void populateSymbolAddressList(const object::ObjectFile *O);
358358

359359
// Load functions from its symbol table (when DWARF info is missing).
360-
void populateSymbolsFromElf(const object::ObjectFile *O);
360+
void populateSymbolsFromBinary(const object::ObjectFile *O);
361361

362362
// A function may be spilt into multiple non-continuous address ranges. We use
363363
// this to set whether start a function range is the real entry of the

0 commit comments

Comments
 (0)