Skip to content

Commit a967994

Browse files
committed
Get symbol size only for ELFObjectFile
1 parent 8f59bfa commit a967994

File tree

3 files changed

+5
-13
lines changed

3 files changed

+5
-13
lines changed

llvm/include/llvm/Object/ELFObjectFile.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,6 @@ template <class ELFT> class ELFObjectFile : public ELFObjectFileBase {
310310
uint64_t getSymbolValueImpl(DataRefImpl Symb) const override;
311311
uint32_t getSymbolAlignment(DataRefImpl Symb) const override;
312312
uint64_t getCommonSymbolSizeImpl(DataRefImpl Symb) const override;
313-
uint64_t getSymbolSizeImpl(DataRefImpl Symb) const override;
314313
Expected<uint32_t> getSymbolFlags(DataRefImpl Symb) const override;
315314
uint8_t getSymbolBinding(DataRefImpl Symb) const override;
316315
uint8_t getSymbolOther(DataRefImpl Symb) const override;
@@ -704,11 +703,6 @@ uint64_t ELFObjectFile<ELFT>::getCommonSymbolSizeImpl(DataRefImpl Symb) const {
704703
return getSymbolSize(Symb);
705704
}
706705

707-
template <class ELFT>
708-
uint64_t ELFObjectFile<ELFT>::getSymbolSizeImpl(DataRefImpl Symb) const {
709-
return getSymbolSize(Symb);
710-
}
711-
712706
template <class ELFT>
713707
uint8_t ELFObjectFile<ELFT>::getSymbolBinding(DataRefImpl Symb) const {
714708
Expected<const Elf_Sym *> SymOrErr = getSymbol(Symb);

llvm/include/llvm/Object/ObjectFile.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ 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;
202201
Expected<SymbolRef::Type> getType() const;
203202

204203
/// Get section this symbol is defined in reference to. Result is
@@ -256,7 +255,6 @@ class LLVM_ABI ObjectFile : public SymbolicFile {
256255
virtual uint64_t getSymbolValueImpl(DataRefImpl Symb) const = 0;
257256
virtual uint32_t getSymbolAlignment(DataRefImpl Symb) const;
258257
virtual uint64_t getCommonSymbolSizeImpl(DataRefImpl Symb) const = 0;
259-
virtual uint64_t getSymbolSizeImpl(DataRefImpl Symb) const { return 0; }
260258
virtual Expected<SymbolRef::Type> getSymbolType(DataRefImpl Symb) const = 0;
261259
virtual Expected<section_iterator>
262260
getSymbolSection(DataRefImpl Symb) const = 0;
@@ -484,10 +482,6 @@ inline uint64_t SymbolRef::getCommonSize() const {
484482
return getObject()->getCommonSymbolSize(getRawDataRefImpl());
485483
}
486484

487-
inline uint64_t SymbolRef::getSize() const {
488-
return getObject()->getSymbolSizeImpl(getRawDataRefImpl());
489-
}
490-
491485
inline Expected<section_iterator> SymbolRef::getSection() const {
492486
return getObject()->getSymbolSection(getRawDataRefImpl());
493487
}

llvm/tools/llvm-profgen/ProfiledBinary.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,11 @@ void ProfiledBinary::populateSymbolsFromBinary(const ObjectFile *Obj) {
839839
const SymbolRef::Type Type = unwrapOrError(Symbol.getType(), FileName);
840840
const uint64_t Addr = unwrapOrError(Symbol.getAddress(), FileName);
841841
const StringRef Name = unwrapOrError(Symbol.getName(), FileName);
842-
const uint64_t Size = Symbol.getSize();
842+
uint64_t Size = 0;
843+
if (isa<ELFObjectFileBase>(Symbol.getObject())) {
844+
ELFSymbolRef ElfSymbol(Symbol);
845+
Size = ElfSymbol.getSize();
846+
}
843847

844848
if (Size == 0 || Type != SymbolRef::ST_Function)
845849
continue;

0 commit comments

Comments
 (0)