chromium/third_party/abseil-cpp/absl/debugging/internal/elf_mem_image.cc

// Copyright 2017 The Abseil Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Allow dynamic symbol lookup in an in-memory Elf image.
//

#include "absl/debugging/internal/elf_mem_image.h"

#ifdef ABSL_HAVE_ELF_MEM_IMAGE  // defined in elf_mem_image.h

#include <string.h>

#include <cassert>
#include <cstddef>
#include <cstdint>

#include "absl/base/config.h"
#include "absl/base/internal/raw_logging.h"

// From binutils/include/elf/common.h (this doesn't appear to be documented
// anywhere else).
//
//   /* This flag appears in a Versym structure.  It means that the symbol
//      is hidden, and is only visible with an explicit version number.
//      This is a GNU extension.  */
//   #define VERSYM_HIDDEN           0x8000
//
//   /* This is the mask for the rest of the Versym information.  */
//   #define VERSYM_VERSION          0x7fff

#define VERSYM_VERSION

namespace absl {
ABSL_NAMESPACE_BEGIN
namespace debugging_internal {

namespace {

#if __SIZEOF_POINTER__ == 4
const int kElfClass = ELFCLASS32;
int ElfBind(const ElfW(Sym) *symbol) { return ELF32_ST_BIND(symbol->st_info); }
int ElfType(const ElfW(Sym) *symbol) { return ELF32_ST_TYPE(symbol->st_info); }
#elif __SIZEOF_POINTER__ == 8
const int kElfClass =;
int ElfBind(const ElfW(Sym) *symbol) {}
int ElfType(const ElfW(Sym) *symbol) {}
#else
const int kElfClass = -1;
int ElfBind(const ElfW(Sym) *) {
  ABSL_RAW_LOG(FATAL, "Unexpected word size");
  return 0;
}
int ElfType(const ElfW(Sym) *) {
  ABSL_RAW_LOG(FATAL, "Unexpected word size");
  return 0;
}
#endif

// Extract an element from one of the ELF tables, cast it to desired type.
// This is just a simple arithmetic and a glorified cast.
// Callers are responsible for bounds checking.
template <typename T>
const T *GetTableElement(const ElfW(Ehdr) * ehdr, ElfW(Off) table_offset,
                         ElfW(Word) element_size, size_t index) {}

}  // namespace

// The value of this variable doesn't matter; it's used only for its
// unique address.
const int ElfMemImage::kInvalidBaseSentinel =;

ElfMemImage::ElfMemImage(const void *base) {}

uint32_t ElfMemImage::GetNumSymbols() const {}

const ElfW(Sym) * ElfMemImage::GetDynsym(uint32_t index) const {}

const ElfW(Versym) *ElfMemImage::GetVersym(uint32_t index) const {}

const ElfW(Phdr) *ElfMemImage::GetPhdr(int index) const {}

const char *ElfMemImage::GetDynstr(ElfW(Word) offset) const {}

const void *ElfMemImage::GetSymAddr(const ElfW(Sym) *sym) const {}

const ElfW(Verdef) *ElfMemImage::GetVerdef(int index) const {}

const ElfW(Verdaux) *ElfMemImage::GetVerdefAux(
    const ElfW(Verdef) *verdef) const {}

const char *ElfMemImage::GetVerstr(ElfW(Word) offset) const {}

void ElfMemImage::Init(const void *base) {}

bool ElfMemImage::LookupSymbol(const char *name,
                               const char *version,
                               int type,
                               SymbolInfo *info_out) const {}

bool ElfMemImage::LookupSymbolByAddress(const void *address,
                                        SymbolInfo *info_out) const {}

ElfMemImage::SymbolIterator::SymbolIterator(const void *const image,
                                            uint32_t index)
    :{}

const ElfMemImage::SymbolInfo *ElfMemImage::SymbolIterator::operator->() const {}

const ElfMemImage::SymbolInfo& ElfMemImage::SymbolIterator::operator*() const {}

bool ElfMemImage::SymbolIterator::operator==(const SymbolIterator &rhs) const {}

bool ElfMemImage::SymbolIterator::operator!=(const SymbolIterator &rhs) const {}

ElfMemImage::SymbolIterator &ElfMemImage::SymbolIterator::operator++() {}

ElfMemImage::SymbolIterator ElfMemImage::begin() const {}

ElfMemImage::SymbolIterator ElfMemImage::end() const {}

void ElfMemImage::SymbolIterator::Update(uint32_t increment) {}

}  // namespace debugging_internal
ABSL_NAMESPACE_END
}  // namespace absl

#endif  // ABSL_HAVE_ELF_MEM_IMAGE