4
0
mirror of https://github.com/QuasarApp/LIEF.git synced 2025-05-11 03:09:32 +00:00

Merge pull request from mkomet/android_enums

added ELF enums for Android relocations and special compiler sections
This commit is contained in:
Romain 2020-12-16 16:20:46 +01:00 committed by GitHub
commit 1feefec9f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 64 additions and 5 deletions
api/python/ELF
include/LIEF/ELF
src/ELF

@ -282,6 +282,10 @@ void init_enums(py::module& m) {
.value(PY_ENUM(ELF_SECTION_TYPES::SHT_GNU_verdef))
.value(PY_ENUM(ELF_SECTION_TYPES::SHT_GNU_verneed))
.value(PY_ENUM(ELF_SECTION_TYPES::SHT_GNU_versym))
.value(PY_ENUM(ELF_SECTION_TYPES::SHT_ANDROID_REL))
.value(PY_ENUM(ELF_SECTION_TYPES::SHT_ANDROID_RELA))
.value(PY_ENUM(ELF_SECTION_TYPES::SHT_LLVM_ADDRSIG))
.value(PY_ENUM(ELF_SECTION_TYPES::SHT_RELR))
.value(PY_ENUM(ELF_SECTION_TYPES::SHT_ARM_EXIDX))
.value(PY_ENUM(ELF_SECTION_TYPES::SHT_ARM_PREEMPTMAP))
@ -430,7 +434,17 @@ void init_enums(py::module& m) {
.value(PY_ENUM(DYNAMIC_TAGS::DT_MIPS_GP_VALUE))
.value(PY_ENUM(DYNAMIC_TAGS::DT_MIPS_AUX_DYNAMIC))
.value(PY_ENUM(DYNAMIC_TAGS::DT_MIPS_PLTGOT))
.value(PY_ENUM(DYNAMIC_TAGS::DT_MIPS_RWPLT));
.value(PY_ENUM(DYNAMIC_TAGS::DT_MIPS_RWPLT))
.value(PY_ENUM(DYNAMIC_TAGS::DT_ANDROID_REL_OFFSET))
.value(PY_ENUM(DYNAMIC_TAGS::DT_ANDROID_REL_SIZE))
.value(PY_ENUM(DYNAMIC_TAGS::DT_ANDROID_REL))
.value(PY_ENUM(DYNAMIC_TAGS::DT_ANDROID_RELSZ))
.value(PY_ENUM(DYNAMIC_TAGS::DT_ANDROID_RELA))
.value(PY_ENUM(DYNAMIC_TAGS::DT_ANDROID_RELASZ))
.value(PY_ENUM(DYNAMIC_TAGS::DT_RELR))
.value(PY_ENUM(DYNAMIC_TAGS::DT_RELRSZ))
.value(PY_ENUM(DYNAMIC_TAGS::DT_RELRENT))
.value(PY_ENUM(DYNAMIC_TAGS::DT_RELRCOUNT));
LIEF::enum_<ELF_SYMBOL_TYPES>(m, "SYMBOL_TYPES")

@ -460,6 +460,10 @@ enum _LIEF_EN(ELF_SECTION_TYPES) {
_LIEF_EI(SHT_GROUP) = 17, /**< Section group. */
_LIEF_EI(SHT_SYMTAB_SHNDX) = 18, /**< Indices for SHN_XINDEX entries. */
_LIEF_EI(SHT_LOOS) = 0x60000000, /**< Lowest operating system-specific type. */
_LIEF_EI(SHT_ANDROID_REL) = 0x60000001, /**< Packed relocations (Android specific). */
_LIEF_EI(SHT_ANDROID_RELA) = 0x60000002, /**< Packed relocations (Android specific). */
_LIEF_EI(SHT_LLVM_ADDRSIG) = 0x6fff4c03, /**< This section is used to mark symbols as address-significant. */
_LIEF_EI(SHT_RELR) = 0x6fffff00, /**< New relr relocations (Android specific). */
_LIEF_EI(SHT_GNU_ATTRIBUTES) = 0x6ffffff5, /**< Object attributes. */
_LIEF_EI(SHT_GNU_HASH) = 0x6ffffff6, /**< GNU-style hash table. */
_LIEF_EI(SHT_GNU_verdef) = 0x6ffffffd, /**< GNU version definitions. */
@ -734,7 +738,19 @@ enum _LIEF_EN(DYNAMIC_TAGS) {
_LIEF_EI(DT_MIPS_GP_VALUE) = 0x70000030, /**< GP value for auxiliary GOTs. */
_LIEF_EI(DT_MIPS_AUX_DYNAMIC) = 0x70000031, /**< Address of auxiliary .dynamic. */
_LIEF_EI(DT_MIPS_PLTGOT) = 0x70000032, /**< Address of the base of the PLTGOT. */
_LIEF_EI(DT_MIPS_RWPLT) = 0x70000034 /**< Points to the base of a writable PLT. */
_LIEF_EI(DT_MIPS_RWPLT) = 0x70000034, /**< Points to the base of a writable PLT. */
/* Android specific dynamic table entry tags. */
_LIEF_EI(DT_ANDROID_REL_OFFSET) = 0x6000000D, /**< The offset of packed relocation data (older version < M) (Android specific). */
_LIEF_EI(DT_ANDROID_REL_SIZE) = 0x6000000E, /**< The size of packed relocation data in bytes (older version < M) (Android specific). */
_LIEF_EI(DT_ANDROID_REL) = 0x6000000F, /**< The offset of packed relocation data (Android specific). */
_LIEF_EI(DT_ANDROID_RELSZ) = 0x60000010, /**< The size of packed relocation data in bytes (Android specific). */
_LIEF_EI(DT_ANDROID_RELA) = 0x60000011, /**< The offset of packed relocation data (Android specific). */
_LIEF_EI(DT_ANDROID_RELASZ) = 0x60000012, /**< The size of packed relocation data in bytes (Android specific). */
_LIEF_EI(DT_RELR) = 0x6FFFE000, /**< The offset of new relr relocation data (Android specific). */
_LIEF_EI(DT_RELRSZ) = 0x6FFFE001, /**< The size of nre relr relocation data in bytes (Android specific). */
_LIEF_EI(DT_RELRENT) = 0x6FFFE003, /**< The size of a new relr relocation entry (Android specific). */
_LIEF_EI(DT_RELRCOUNT) = 0x6FFFE005 /**< Specifies the relative count of new relr relocation entries (Android specific). */
};
/** DT_FLAGS and DT_FLAGS_1 values. */

@ -400,6 +400,10 @@
#undef SHT_LOUSER
#undef SHT_HIUSER
#undef SHT_ANDROID_REL
#undef SHT_ANDROID_RELA
#undef SHT_LLVM_ADDRSIG
#undef SHT_RELR
#undef SHF_NONE
#undef SHF_WRITE
@ -592,6 +596,17 @@
#undef DT_MIPS_PLTGOT
#undef DT_MIPS_RWPLT
#undef DT_ANDROID_REL_OFFSET
#undef DT_ANDROID_REL_SIZE
#undef DT_ANDROID_REL
#undef DT_ANDROID_RELSZ
#undef DT_ANDROID_RELA
#undef DT_ANDROID_RELASZ
#undef DT_RELR
#undef DT_RELRSZ
#undef DT_RELRENT
#undef DT_RELRCOUNT
#undef DF_ORIGIN
#undef DF_SYMBOLIC
#undef DF_TEXTREL

@ -275,7 +275,7 @@ const char* to_string(SEGMENT_TYPES e) {
}
const char* to_string(DYNAMIC_TAGS e) {
CONST_MAP(DYNAMIC_TAGS, const char*, 87) enumStrings {
CONST_MAP(DYNAMIC_TAGS, const char*, 97) enumStrings {
{ DYNAMIC_TAGS::DT_NULL, "NULL"},
{ DYNAMIC_TAGS::DT_NEEDED, "NEEDED"},
{ DYNAMIC_TAGS::DT_PLTRELSZ, "PLTRELSZ"},
@ -363,7 +363,17 @@ const char* to_string(DYNAMIC_TAGS e) {
{ DYNAMIC_TAGS::DT_MIPS_GP_VALUE, "MIPS_GP_VALUE"},
{ DYNAMIC_TAGS::DT_MIPS_AUX_DYNAMIC, "MIPS_AUX_DYNAMIC"},
{ DYNAMIC_TAGS::DT_MIPS_PLTGOT, "MIPS_PLTGOT"},
{ DYNAMIC_TAGS::DT_MIPS_RWPLT, "MIPS_RWPLT"}
{ DYNAMIC_TAGS::DT_MIPS_RWPLT, "MIPS_RWPLT"},
{ DYNAMIC_TAGS::DT_ANDROID_REL_OFFSET, "ANDROID_REL_OFFSET"},
{ DYNAMIC_TAGS::DT_ANDROID_REL_SIZE, "ANDROID_REL_SIZE"},
{ DYNAMIC_TAGS::DT_ANDROID_REL, "ANDROID_REL"},
{ DYNAMIC_TAGS::DT_ANDROID_RELSZ, "ANDROID_RELSZ"},
{ DYNAMIC_TAGS::DT_ANDROID_RELA, "ANDROID_RELA"},
{ DYNAMIC_TAGS::DT_ANDROID_RELASZ, "ANDROID_RELASZ"},
{ DYNAMIC_TAGS::DT_RELR, "RELR"},
{ DYNAMIC_TAGS::DT_RELRSZ, "RELRSZ"},
{ DYNAMIC_TAGS::DT_RELRENT, "RELRENT"},
{ DYNAMIC_TAGS::DT_RELRCOUNT, "RELRCOUNT"}
};
auto it = enumStrings.find(e);
return it == enumStrings.end() ? "UNDEFINED" : it->second;
@ -371,7 +381,7 @@ const char* to_string(DYNAMIC_TAGS e) {
const char* to_string(ELF_SECTION_TYPES e) {
CONST_MAP(ELF_SECTION_TYPES, const char*, 35) enumStrings {
CONST_MAP(ELF_SECTION_TYPES, const char*, 39) enumStrings {
{ ELF_SECTION_TYPES::SHT_NULL, "NULL"},
{ ELF_SECTION_TYPES::SHT_PROGBITS, "PROGBITS"},
{ ELF_SECTION_TYPES::SHT_SYMTAB, "SYMTAB"},
@ -390,6 +400,10 @@ const char* to_string(ELF_SECTION_TYPES e) {
{ ELF_SECTION_TYPES::SHT_GROUP, "GROUP"},
{ ELF_SECTION_TYPES::SHT_SYMTAB_SHNDX, "SYMTAB_SHNDX"},
{ ELF_SECTION_TYPES::SHT_LOOS, "LOOS"},
{ ELF_SECTION_TYPES::SHT_ANDROID_REL, "ANDROID_REL"},
{ ELF_SECTION_TYPES::SHT_ANDROID_RELA, "ANDROID_RELA"},
{ ELF_SECTION_TYPES::SHT_LLVM_ADDRSIG, "LLVM_ADDRSIG"},
{ ELF_SECTION_TYPES::SHT_RELR, "RELR"},
{ ELF_SECTION_TYPES::SHT_GNU_ATTRIBUTES, "GNU_ATTRIBUTES"},
{ ELF_SECTION_TYPES::SHT_GNU_HASH, "GNU_HASH"},
{ ELF_SECTION_TYPES::SHT_GNU_verdef, "GNU_VERDEF"},