#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "base/debug/elf_reader.h"
#include <arpa/inet.h>
#include <elf.h>
#include <string.h>
#include <optional>
#include <string_view>
#include "base/bits.h"
#include "base/containers/span.h"
#include "base/hash/sha1.h"
#include "base/strings/safe_sprintf.h"
#include "build/build_config.h"
namespace base {
namespace debug {
namespace {
#if __SIZEOF_POINTER__ == 4
using Ehdr = Elf32_Ehdr;
using Dyn = Elf32_Dyn;
using Half = Elf32_Half;
using Nhdr = Elf32_Nhdr;
using Word = Elf32_Word;
using Xword = Elf32_Word;
#else
Ehdr;
Dyn;
Half;
Nhdr;
Word;
Xword;
#endif
constexpr char kGnuNoteName[] = …;
const Ehdr* GetElfHeader(const void* elf_mapped_base) { … }
}
size_t ReadElfBuildId(const void* elf_mapped_base,
bool uppercase,
ElfBuildIdBuffer build_id) { … }
std::optional<std::string_view> ReadElfLibraryName(
const void* elf_mapped_base) { … }
span<const Phdr> GetElfProgramHeaders(const void* elf_mapped_base) { … }
size_t GetRelocationOffset(const void* elf_mapped_base) { … }
}
}