mirror of
https://github.com/0O0o0oOoO00/Alas.git
synced 2026-05-14 12:19:24 +08:00
add: add judgments for 32-bit and 64-bit for patchelf
This commit is contained in:
@@ -6,4 +6,10 @@ file(GLOB_RECURSE PATCHELF_SRCS
|
||||
)
|
||||
add_executable(${PATCHELF} ${PATCHELF_SRCS})
|
||||
target_link_libraries(${PATCHELF} PRIVATE cxxopts::cxxopts)
|
||||
target_link_options(${PATCHELF} PRIVATE -Wl,--version-script=${CMAKE_CURRENT_LIST_DIR}/patchelf.map)
|
||||
target_link_options(${PATCHELF} PRIVATE -Wl,--version-script=${CMAKE_CURRENT_LIST_DIR}/patchelf.map)
|
||||
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
target_compile_definitions(${PATCHELF} PRIVATE USE_64)
|
||||
else()
|
||||
target_compile_definitions(${PATCHELF} PRIVATE USE_32)
|
||||
endif()
|
||||
|
||||
@@ -2732,14 +2732,19 @@ static void patchElf() {
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
using ElfFile32 = ElfFile<Elf32_Ehdr, Elf32_Phdr, Elf32_Shdr, Elf32_Addr, Elf32_Off, Elf32_Dyn, Elf32_Sym, Elf32_Versym, Elf32_Verdef, Elf32_Verdaux, Elf32_Verneed, Elf32_Vernaux, Elf32_Rel, Elf32_Rela, 32>;
|
||||
#ifdef USE_64
|
||||
using Elf = ElfFile<Elf64_Ehdr, Elf64_Phdr, Elf64_Shdr, Elf64_Addr, Elf64_Off, Elf64_Dyn, Elf64_Sym, Elf64_Versym, Elf64_Verdef, Elf64_Verdaux, Elf64_Verneed, Elf64_Vernaux, Elf64_Rel, Elf64_Rela, 64>;
|
||||
#endif // USE_64
|
||||
#ifdef USE_32
|
||||
using Elf = ElfFile<Elf32_Ehdr, Elf32_Phdr, Elf32_Shdr, Elf32_Addr, Elf32_Off, Elf32_Dyn, Elf32_Sym, Elf32_Versym, Elf32_Verdef, Elf32_Verdaux, Elf32_Verneed, Elf32_Vernaux, Elf32_Rel, Elf32_Rela, 32>;
|
||||
#endif // USE_32
|
||||
|
||||
void do_local_patch(const std::string& game_lib_dir) {
|
||||
fs::path lib_dir(game_lib_dir);
|
||||
auto libtolua_file = lib_dir / "libtolua.so";
|
||||
auto libtolua_backup_file = lib_dir / "libtolua.so.bak";
|
||||
|
||||
ElfFile32 libtolua(readFile(libtolua_file));
|
||||
Elf libtolua(readFile(libtolua_file));
|
||||
|
||||
auto curr_needed = libtolua.getNeededLibs();
|
||||
for (const auto& lib : curr_needed) {
|
||||
@@ -2765,7 +2770,7 @@ void do_local_depatch(const std::string& game_lib_dir) {
|
||||
return;
|
||||
}
|
||||
|
||||
ElfFile32 libtolua(readFile(libtolua_file));
|
||||
Elf libtolua(readFile(libtolua_file));
|
||||
|
||||
auto curr_needed = libtolua.getNeededLibs();
|
||||
for (const auto& lib : curr_needed) {
|
||||
|
||||
Reference in New Issue
Block a user