chromium/third_party/perfetto/src/profiling/symbolizer/elf.h

/*
 * Copyright (C) 2021 The Android Open Source Project
 *
 * 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
 *
 *      http://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.
 */

#ifndef SRC_PROFILING_SYMBOLIZER_ELF_H_
#define SRC_PROFILING_SYMBOLIZER_ELF_H_

#include <stddef.h>
#include <cinttypes>

#include "perfetto/base/build_config.h"

// We cannot just include elf.h, as that only exists on Linux, and we want to
// allow symbolization on other platforms as well. As we only need a small
// subset, it is easiest to define the constants and structs ourselves.

namespace perfetto {
namespace profiling {

constexpr auto PT_LOAD =;
constexpr auto PF_X =;
constexpr auto SHT_NOTE =;
constexpr auto NT_GNU_BUILD_ID =;
constexpr auto ELFCLASS32 =;
constexpr auto ELFCLASS64 =;
constexpr auto ELFMAG0 =;
constexpr auto ELFMAG1 =;
constexpr auto ELFMAG2 =;
constexpr auto ELFMAG3 =;
constexpr auto ELFDATA2LSB =;
constexpr auto EV_CURRENT =;
constexpr auto EI_MAG0 =;
constexpr auto EI_MAG1 =;
constexpr auto EI_MAG2 =;
constexpr auto EI_MAG3 =;
constexpr auto EI_CLASS =;
constexpr auto EI_DATA =;
constexpr auto EI_VERSION =;

struct Elf32 {};

struct Elf64 {};

template <typename E>
typename E::Shdr* GetShdr(void* mem, const typename E::Ehdr* ehdr, size_t i) {}

template <typename E>
typename E::Phdr* GetPhdr(void* mem, const typename E::Ehdr* ehdr, size_t i) {}

}  // namespace profiling
}  // namespace perfetto

#endif  // SRC_PROFILING_SYMBOLIZER_ELF_H_