36cd2e22d4
Also use the function labels for Dwarf in Assembly snapshots to avoid creating duplicate labels. Fixes https://github.com/dart-lang/sdk/issues/38978 Issue https://github.com/dart-lang/sdk/issues/38526 Change-Id: Icafd3d3a86381990ec8097397a21b16ad4a7a766 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122150 Reviewed-by: Ryan Macnak <rmacnak@google.com> Commit-Queue: Samir Jindel <sjindel@google.com>
172 lines
3.9 KiB
C++
172 lines
3.9 KiB
C++
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
#ifndef RUNTIME_PLATFORM_ELF_H_
|
|
#define RUNTIME_PLATFORM_ELF_H_
|
|
|
|
#include "platform/globals.h"
|
|
|
|
namespace dart {
|
|
namespace elf {
|
|
|
|
#pragma pack(push, 1)
|
|
|
|
struct ElfHeader {
|
|
uint8_t ident[16];
|
|
uint16_t type;
|
|
uint16_t machine;
|
|
uint32_t version;
|
|
#if defined(TARGET_ARCH_IS_32_BIT)
|
|
uint32_t entry_point;
|
|
uint32_t program_table_offset;
|
|
uint32_t section_table_offset;
|
|
#else
|
|
uint64_t entry_point;
|
|
uint64_t program_table_offset;
|
|
uint64_t section_table_offset;
|
|
#endif
|
|
uint32_t flags;
|
|
uint16_t header_size;
|
|
uint16_t program_table_entry_size;
|
|
uint16_t num_program_headers;
|
|
uint16_t section_table_entry_size;
|
|
uint16_t num_section_headers;
|
|
uint16_t shstrtab_section_index;
|
|
};
|
|
|
|
enum class ProgramHeaderType : uint32_t {
|
|
PT_LOAD = 1,
|
|
PT_DYNAMIC = 2,
|
|
PT_PHDR = 6,
|
|
};
|
|
|
|
struct ProgramHeader {
|
|
#if defined(TARGET_ARCH_IS_32_BIT)
|
|
ProgramHeaderType type;
|
|
uint32_t file_offset;
|
|
uint32_t memory_offset;
|
|
uint32_t physical_memory_offset;
|
|
uint32_t file_size;
|
|
uint32_t memory_size;
|
|
uint32_t flags;
|
|
uint32_t alignment;
|
|
#else
|
|
ProgramHeaderType type;
|
|
uint32_t flags;
|
|
uint64_t file_offset;
|
|
uint64_t memory_offset;
|
|
uint64_t physical_memory_offset;
|
|
uint64_t file_size;
|
|
uint64_t memory_size;
|
|
uint64_t alignment;
|
|
#endif
|
|
};
|
|
|
|
struct SectionHeader {
|
|
#if defined(TARGET_ARCH_IS_32_BIT)
|
|
uint32_t name;
|
|
uint32_t type;
|
|
uint32_t flags;
|
|
uint32_t memory_offset;
|
|
uint32_t file_offset;
|
|
uint32_t file_size;
|
|
uint32_t link;
|
|
uint32_t info;
|
|
uint32_t alignment;
|
|
uint32_t entry_size;
|
|
#else
|
|
uint32_t name;
|
|
uint32_t type;
|
|
uint64_t flags;
|
|
uint64_t memory_offset;
|
|
uint64_t file_offset;
|
|
uint64_t file_size;
|
|
uint32_t link;
|
|
uint32_t info;
|
|
uint64_t alignment;
|
|
uint64_t entry_size;
|
|
#endif
|
|
};
|
|
|
|
struct Symbol {
|
|
#if defined(TARGET_ARCH_IS_32_BIT)
|
|
uint32_t name;
|
|
uint32_t value;
|
|
uint32_t size;
|
|
uint8_t info;
|
|
uint8_t other; // Reserved by ELF.
|
|
uint16_t section;
|
|
#else
|
|
uint32_t name;
|
|
uint8_t info;
|
|
uint8_t other; // Reserved by ELF.
|
|
uint16_t section;
|
|
uint64_t value;
|
|
uint64_t size;
|
|
#endif
|
|
};
|
|
|
|
#pragma pack(pop)
|
|
|
|
static constexpr intptr_t ELFCLASS32 = 1;
|
|
static constexpr intptr_t ELFCLASS64 = 2;
|
|
|
|
static const intptr_t EI_DATA = 5;
|
|
static const intptr_t ELFDATA2LSB = 1;
|
|
|
|
static const intptr_t ELFOSABI_SYSV = 0;
|
|
|
|
static const intptr_t ET_DYN = 3;
|
|
|
|
static constexpr intptr_t EF_ARM_ABI_FLOAT_HARD = 0x00000400;
|
|
static constexpr intptr_t EF_ARM_ABI_FLOAT_SOFT = 0x00000200;
|
|
static constexpr intptr_t EF_ARM_ABI = 0x05000000;
|
|
|
|
static constexpr intptr_t EM_386 = 3;
|
|
static constexpr intptr_t EM_ARM = 40;
|
|
static constexpr intptr_t EM_X86_64 = 62;
|
|
static constexpr intptr_t EM_AARCH64 = 183;
|
|
|
|
static const intptr_t EV_CURRENT = 1;
|
|
|
|
static const intptr_t PF_X = 1;
|
|
static const intptr_t PF_W = 2;
|
|
static const intptr_t PF_R = 4;
|
|
|
|
static const intptr_t SHT_PROGBITS = 1;
|
|
static const intptr_t SHT_SYMTAB = 2;
|
|
static const intptr_t SHT_STRTAB = 3;
|
|
static const intptr_t SHT_HASH = 5;
|
|
static const intptr_t SHT_DYNAMIC = 6;
|
|
static const intptr_t SHT_DYNSYM = 11;
|
|
|
|
static const intptr_t SHF_WRITE = 0x1;
|
|
static const intptr_t SHF_ALLOC = 0x2;
|
|
static const intptr_t SHF_EXECINSTR = 0x4;
|
|
|
|
static const intptr_t SHN_UNDEF = 0;
|
|
|
|
static const intptr_t STN_UNDEF = 0;
|
|
|
|
static const intptr_t PT_LOAD = 1;
|
|
static const intptr_t PT_DYNAMIC = 2;
|
|
static const intptr_t PT_PHDR = 6;
|
|
|
|
static const intptr_t STB_GLOBAL = 1;
|
|
|
|
static const intptr_t STT_OBJECT = 1; // I.e., data.
|
|
static const intptr_t STT_FUNC = 2;
|
|
|
|
static const intptr_t DT_NULL = 0;
|
|
static const intptr_t DT_HASH = 4;
|
|
static const intptr_t DT_STRTAB = 5;
|
|
static const intptr_t DT_SYMTAB = 6;
|
|
static const intptr_t DT_STRSZ = 10;
|
|
static const intptr_t DT_SYMENT = 11;
|
|
|
|
} // namespace elf
|
|
} // namespace dart
|
|
|
|
#endif // RUNTIME_PLATFORM_ELF_H_
|