mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 19:23:23 +01:00
176f7790ec
This is part of the ODR checker proposal: http://lists.llvm.org/pipermail/llvm-dev/2017-June/113820.html Per discussion on the gnu-gabi mailing list [1] the section type range 0x6fff4c00..0x6fff4cff is reserved for LLVM. [1] https://sourceware.org/ml/gnu-gabi/2017-q2/msg00030.html Differential Revision: https://reviews.llvm.org/D33978 llvm-svn: 305407
205 lines
5.0 KiB
C++
205 lines
5.0 KiB
C++
//===- ELF.cpp - ELF object file implementation ---------------------------===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "llvm/Object/ELF.h"
|
|
#include "llvm/BinaryFormat/ELF.h"
|
|
|
|
using namespace llvm;
|
|
using namespace object;
|
|
|
|
#define STRINGIFY_ENUM_CASE(ns, name) \
|
|
case ns::name: \
|
|
return #name;
|
|
|
|
#define ELF_RELOC(name, value) STRINGIFY_ENUM_CASE(ELF, name)
|
|
|
|
StringRef llvm::object::getELFRelocationTypeName(uint32_t Machine,
|
|
uint32_t Type) {
|
|
switch (Machine) {
|
|
case ELF::EM_X86_64:
|
|
switch (Type) {
|
|
#include "llvm/BinaryFormat/ELFRelocs/x86_64.def"
|
|
default:
|
|
break;
|
|
}
|
|
break;
|
|
case ELF::EM_386:
|
|
case ELF::EM_IAMCU:
|
|
switch (Type) {
|
|
#include "llvm/BinaryFormat/ELFRelocs/i386.def"
|
|
default:
|
|
break;
|
|
}
|
|
break;
|
|
case ELF::EM_MIPS:
|
|
switch (Type) {
|
|
#include "llvm/BinaryFormat/ELFRelocs/Mips.def"
|
|
default:
|
|
break;
|
|
}
|
|
break;
|
|
case ELF::EM_AARCH64:
|
|
switch (Type) {
|
|
#include "llvm/BinaryFormat/ELFRelocs/AArch64.def"
|
|
default:
|
|
break;
|
|
}
|
|
break;
|
|
case ELF::EM_ARM:
|
|
switch (Type) {
|
|
#include "llvm/BinaryFormat/ELFRelocs/ARM.def"
|
|
default:
|
|
break;
|
|
}
|
|
break;
|
|
case ELF::EM_AVR:
|
|
switch (Type) {
|
|
#include "llvm/BinaryFormat/ELFRelocs/AVR.def"
|
|
default:
|
|
break;
|
|
}
|
|
break;
|
|
case ELF::EM_HEXAGON:
|
|
switch (Type) {
|
|
#include "llvm/BinaryFormat/ELFRelocs/Hexagon.def"
|
|
default:
|
|
break;
|
|
}
|
|
break;
|
|
case ELF::EM_LANAI:
|
|
switch (Type) {
|
|
#include "llvm/BinaryFormat/ELFRelocs/Lanai.def"
|
|
default:
|
|
break;
|
|
}
|
|
break;
|
|
case ELF::EM_PPC:
|
|
switch (Type) {
|
|
#include "llvm/BinaryFormat/ELFRelocs/PowerPC.def"
|
|
default:
|
|
break;
|
|
}
|
|
break;
|
|
case ELF::EM_PPC64:
|
|
switch (Type) {
|
|
#include "llvm/BinaryFormat/ELFRelocs/PowerPC64.def"
|
|
default:
|
|
break;
|
|
}
|
|
break;
|
|
case ELF::EM_RISCV:
|
|
switch (Type) {
|
|
#include "llvm/BinaryFormat/ELFRelocs/RISCV.def"
|
|
default:
|
|
break;
|
|
}
|
|
break;
|
|
case ELF::EM_S390:
|
|
switch (Type) {
|
|
#include "llvm/BinaryFormat/ELFRelocs/SystemZ.def"
|
|
default:
|
|
break;
|
|
}
|
|
break;
|
|
case ELF::EM_SPARC:
|
|
case ELF::EM_SPARC32PLUS:
|
|
case ELF::EM_SPARCV9:
|
|
switch (Type) {
|
|
#include "llvm/BinaryFormat/ELFRelocs/Sparc.def"
|
|
default:
|
|
break;
|
|
}
|
|
break;
|
|
case ELF::EM_WEBASSEMBLY:
|
|
switch (Type) {
|
|
#include "llvm/BinaryFormat/ELFRelocs/WebAssembly.def"
|
|
default:
|
|
break;
|
|
}
|
|
break;
|
|
case ELF::EM_AMDGPU:
|
|
switch (Type) {
|
|
#include "llvm/BinaryFormat/ELFRelocs/AMDGPU.def"
|
|
default:
|
|
break;
|
|
}
|
|
case ELF::EM_BPF:
|
|
switch (Type) {
|
|
#include "llvm/BinaryFormat/ELFRelocs/BPF.def"
|
|
default:
|
|
break;
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
return "Unknown";
|
|
}
|
|
|
|
#undef ELF_RELOC
|
|
|
|
StringRef llvm::object::getELFSectionTypeName(uint32_t Machine, unsigned Type) {
|
|
switch (Machine) {
|
|
case ELF::EM_ARM:
|
|
switch (Type) {
|
|
STRINGIFY_ENUM_CASE(ELF, SHT_ARM_EXIDX);
|
|
STRINGIFY_ENUM_CASE(ELF, SHT_ARM_PREEMPTMAP);
|
|
STRINGIFY_ENUM_CASE(ELF, SHT_ARM_ATTRIBUTES);
|
|
STRINGIFY_ENUM_CASE(ELF, SHT_ARM_DEBUGOVERLAY);
|
|
STRINGIFY_ENUM_CASE(ELF, SHT_ARM_OVERLAYSECTION);
|
|
}
|
|
break;
|
|
case ELF::EM_HEXAGON:
|
|
switch (Type) { STRINGIFY_ENUM_CASE(ELF, SHT_HEX_ORDERED); }
|
|
break;
|
|
case ELF::EM_X86_64:
|
|
switch (Type) { STRINGIFY_ENUM_CASE(ELF, SHT_X86_64_UNWIND); }
|
|
break;
|
|
case ELF::EM_MIPS:
|
|
case ELF::EM_MIPS_RS3_LE:
|
|
switch (Type) {
|
|
STRINGIFY_ENUM_CASE(ELF, SHT_MIPS_REGINFO);
|
|
STRINGIFY_ENUM_CASE(ELF, SHT_MIPS_OPTIONS);
|
|
STRINGIFY_ENUM_CASE(ELF, SHT_MIPS_ABIFLAGS);
|
|
STRINGIFY_ENUM_CASE(ELF, SHT_MIPS_DWARF);
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
switch (Type) {
|
|
STRINGIFY_ENUM_CASE(ELF, SHT_NULL);
|
|
STRINGIFY_ENUM_CASE(ELF, SHT_PROGBITS);
|
|
STRINGIFY_ENUM_CASE(ELF, SHT_SYMTAB);
|
|
STRINGIFY_ENUM_CASE(ELF, SHT_STRTAB);
|
|
STRINGIFY_ENUM_CASE(ELF, SHT_RELA);
|
|
STRINGIFY_ENUM_CASE(ELF, SHT_HASH);
|
|
STRINGIFY_ENUM_CASE(ELF, SHT_DYNAMIC);
|
|
STRINGIFY_ENUM_CASE(ELF, SHT_NOTE);
|
|
STRINGIFY_ENUM_CASE(ELF, SHT_NOBITS);
|
|
STRINGIFY_ENUM_CASE(ELF, SHT_REL);
|
|
STRINGIFY_ENUM_CASE(ELF, SHT_SHLIB);
|
|
STRINGIFY_ENUM_CASE(ELF, SHT_DYNSYM);
|
|
STRINGIFY_ENUM_CASE(ELF, SHT_INIT_ARRAY);
|
|
STRINGIFY_ENUM_CASE(ELF, SHT_FINI_ARRAY);
|
|
STRINGIFY_ENUM_CASE(ELF, SHT_PREINIT_ARRAY);
|
|
STRINGIFY_ENUM_CASE(ELF, SHT_GROUP);
|
|
STRINGIFY_ENUM_CASE(ELF, SHT_SYMTAB_SHNDX);
|
|
STRINGIFY_ENUM_CASE(ELF, SHT_LLVM_ODRTAB);
|
|
STRINGIFY_ENUM_CASE(ELF, SHT_GNU_ATTRIBUTES);
|
|
STRINGIFY_ENUM_CASE(ELF, SHT_GNU_HASH);
|
|
STRINGIFY_ENUM_CASE(ELF, SHT_GNU_verdef);
|
|
STRINGIFY_ENUM_CASE(ELF, SHT_GNU_verneed);
|
|
STRINGIFY_ENUM_CASE(ELF, SHT_GNU_versym);
|
|
default:
|
|
return "Unknown";
|
|
}
|
|
}
|