Skip to content

Commit

Permalink
Strip DT_PREINIT_ARRAY
Browse files Browse the repository at this point in the history
  • Loading branch information
yujincheng08 committed Mar 18, 2023
1 parent 7efc050 commit 55b6811
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions elf-cleaner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ bool process_elf(uint8_t* bytes, size_t elf_file_size, char const* file_name)
}
ElfHeaderType* elf_hdr = reinterpret_cast<ElfHeaderType*>(bytes);

bool is_dyn = elf_hdr->e_type == 0x03;

bool is_aarch64 = (elf_hdr->e_machine == 183); /* EM_AARCH64 */

/* Check TLS segment alignment in program headers if api level is < 29 */
Expand Down Expand Up @@ -158,6 +160,7 @@ bool process_elf(uint8_t* bytes, size_t elf_file_size, char const* file_name)
case DT_AARCH64_BTI_PLT: if (is_aarch64 && api_level < 31) removed_name = "DT_AARCH64_BTI_PLT"; break;
case DT_AARCH64_PAC_PLT: if (is_aarch64 && api_level < 31) removed_name = "DT_AARCH64_PAC_PLT"; break;
case DT_AARCH64_VARIANT_PCS: if (is_aarch64 && api_level < 31) removed_name = "DT_AARCH64_VARIANT_PCS"; break;
case DT_PREINIT_ARRAY: if (is_dyn) removed_name = "DT_PREINIT_ARRAY"; break;
}
if (removed_name != nullptr) {
if (!quiet)
Expand Down

0 comments on commit 55b6811

Please sign in to comment.