Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion llvm/include/llvm/Object/ELFTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ class Elf_Note_Impl {

/// Get the note's descriptor.
ArrayRef<uint8_t> getDesc(size_t Align) const {
if (!Nhdr.n_descsz)
if (!Nhdr.n_descsz || !Align)
return ArrayRef<uint8_t>();
return ArrayRef<uint8_t>(
reinterpret_cast<const uint8_t *>(&Nhdr) +
Expand Down
14 changes: 14 additions & 0 deletions llvm/lib/Object/BuildID.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,20 @@ using namespace llvm::object;
namespace {

template <typename ELFT> BuildIDRef getBuildID(const ELFFile<ELFT> &Obj) {
auto Sections = cantFail(Obj.sections());
if (!Sections.empty()) {
for (const auto &S : Sections) {
if (S.sh_type != ELF::SHT_NOTE)
continue;
Error Err = Error::success();
for (auto N : Obj.notes(S, Err))
if (N.getType() == ELF::NT_GNU_BUILD_ID &&
N.getName() == ELF::ELF_NOTE_GNU)
return N.getDesc(S.sh_addralign);
consumeError(std::move(Err));
}
}

auto PhdrsOrErr = Obj.program_headers();
if (!PhdrsOrErr) {
consumeError(PhdrsOrErr.takeError());
Expand Down