fix(libs): drop std name collisions via nid postfix + remove custom entry point
This commit is contained in:
parent
ca38455917
commit
8627076df5
|
|
@ -26,10 +26,6 @@ foreach(LIB_DIR ${LIBS_DIRS})
|
|||
set(RPX_FILE ${CMAKE_CURRENT_BINARY_DIR}/libs/${LIB_NAME}.prx)
|
||||
set(STAMP_FILE ${CMAKE_CURRENT_BINARY_DIR}/libs/${LIB_NAME}.patched)
|
||||
|
||||
if(${LIB_NAME} STREQUAL "libSceLibcInternal")
|
||||
target_link_options(${LIB_NAME} PRIVATE -nostartfiles -Wl,--allow-multiple-definition)
|
||||
endif()
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${STAMP_FILE}
|
||||
COMMAND $<TARGET_FILE:nid_patcher> ${LIB_NAME} ${RPX_FILE}
|
||||
|
|
|
|||
|
|
@ -52,6 +52,14 @@ struct Elf64_Sym {
|
|||
|
||||
constexpr std::uint32_t SHT_DYNSYM = 11u;
|
||||
constexpr std::uint8_t STB_LOCAL = 0u;
|
||||
constexpr char kNidPostfix[] = "_nid_postfix";
|
||||
constexpr std::size_t kNidPostfixLen = sizeof(kNidPostfix) - 1u;
|
||||
|
||||
std::string _stripNidPostfix(const std::string& name) {
|
||||
if (name.size() < kNidPostfixLen) return name;
|
||||
if (name.compare(name.size() - kNidPostfixLen, kNidPostfixLen, kNidPostfix) != 0) return name;
|
||||
return name.substr(0u, name.size() - kNidPostfixLen);
|
||||
}
|
||||
|
||||
struct PeDataDirectory {
|
||||
std::uint32_t VirtualAddress;
|
||||
|
|
@ -194,7 +202,7 @@ void _patchNidsElf(std::vector<std::uint8_t>& elf, const std::string& libraryNam
|
|||
const std::string symName = _readCStr(newDynStr, sym.st_name);
|
||||
if (symName.empty()) continue;
|
||||
|
||||
const std::string nid = Nid::ComputeNid(symName, libraryName);
|
||||
const std::string nid = Nid::ComputeNid(_stripNidPostfix(symName), libraryName);
|
||||
|
||||
const auto existingIt = [&]() {
|
||||
for (const auto& [orig, newIdx] : nameRemap)
|
||||
|
|
@ -315,7 +323,7 @@ void _patchNidsPe(std::vector<std::uint8_t>& pe, const std::string& libraryName)
|
|||
usedEnd = std::max(usedEnd, nameRvas[i] - edataSection.VirtualAddress + static_cast<std::uint32_t>(names[i].size()) + 1u);
|
||||
|
||||
for (std::uint32_t i = 0u; i < exportTable.NumberOfNames; ++i) {
|
||||
const std::string nid = Nid::ComputeNid(names[i], libraryName);
|
||||
const std::string nid = Nid::ComputeNid(_stripNidPostfix(names[i]), libraryName);
|
||||
const std::size_t oldNameOffset = _peRvaToOffset(pe, nameRvas[i], peHeaderOffset, numberOfSections, sizeOfOptionalHeader);
|
||||
|
||||
if (nid.size() <= names[i].size()) {
|
||||
|
|
|
|||
|
|
@ -2,16 +2,9 @@
|
|||
#include <cstddef>
|
||||
#include "SceTypes.hpp"
|
||||
|
||||
extern "C" int __stdcall DllMainCRTStartup(void* hinstDLL, unsigned long fdwReason, void* lpReserved) {
|
||||
(void)hinstDLL;
|
||||
(void)fdwReason;
|
||||
(void)lpReserved;
|
||||
return 1;
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
||||
[[noreturn]] void abort(uint64_t arg0, uint64_t arg1, uint64_t arg2, uint64_t arg3, uint64_t arg4, uint64_t arg5) {
|
||||
[[noreturn]] void abort_nid_postfix(uint64_t arg0, uint64_t arg1, uint64_t arg2, uint64_t arg3, uint64_t arg4, uint64_t arg5) {
|
||||
(void)arg0;
|
||||
(void)arg1;
|
||||
(void)arg2;
|
||||
|
|
@ -21,194 +14,194 @@ extern "C" {
|
|||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
int atexit(atexit_func_t func) {
|
||||
int atexit_nid_postfix(atexit_func_t func) {
|
||||
(void)func;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int atoi(const char* str) {
|
||||
int atoi_nid_postfix(const char* str) {
|
||||
(void)str;
|
||||
return 0;
|
||||
}
|
||||
|
||||
double cos(double x) {
|
||||
double cos_nid_postfix(double x) {
|
||||
(void)x;
|
||||
return 0;
|
||||
}
|
||||
|
||||
float cosf(float x) {
|
||||
float cosf_nid_postfix(float x) {
|
||||
(void)x;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Exit(int code) {
|
||||
void Exit_nid_postfix(int code) {
|
||||
(void)code;
|
||||
}
|
||||
|
||||
void exit(int code) {
|
||||
void exit_nid_postfix(int code) {
|
||||
(void)code;
|
||||
}
|
||||
|
||||
int fflush(FILE* stream) {
|
||||
int fflush_nid_postfix(FILE* stream) {
|
||||
(void)stream;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void init_env(const InitEnvParams* params) {
|
||||
void init_env_nid_postfix(const InitEnvParams* params) {
|
||||
(void)params;
|
||||
}
|
||||
|
||||
int memcmp(const void* s1, const void* s2, size_t n) {
|
||||
int memcmp_nid_postfix(const void* s1, const void* s2, size_t n) {
|
||||
(void)s1;
|
||||
(void)s2;
|
||||
(void)n;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void* memcpy(void* dest, const void* src, size_t n) {
|
||||
void* memcpy_nid_postfix(void* dest, const void* src, size_t n) {
|
||||
(void)dest;
|
||||
(void)src;
|
||||
(void)n;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void* memmove(void* dest, const void* src, size_t n) {
|
||||
void* memmove_nid_postfix(void* dest, const void* src, size_t n) {
|
||||
(void)dest;
|
||||
(void)src;
|
||||
(void)n;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void* memset(void* s, int c, size_t n) {
|
||||
void* memset_nid_postfix(void* s, int c, size_t n) {
|
||||
(void)s;
|
||||
(void)c;
|
||||
(void)n;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int puts(const char* s) {
|
||||
int puts_nid_postfix(const char* s) {
|
||||
(void)s;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void sceLibcHeapGetTraceInfo(Info* info) {
|
||||
void sceLibcHeapGetTraceInfo_nid_postfix(Info* info) {
|
||||
(void)info;
|
||||
}
|
||||
|
||||
int setenv(const char* name, const char* value, int overwrite) {
|
||||
int setenv_nid_postfix(const char* name, const char* value, int overwrite) {
|
||||
(void)name;
|
||||
(void)value;
|
||||
(void)overwrite;
|
||||
return 0;
|
||||
}
|
||||
|
||||
double Sin(double x) {
|
||||
double Sin_nid_postfix(double x) {
|
||||
(void)x;
|
||||
return 0;
|
||||
}
|
||||
|
||||
double sin(double x) {
|
||||
double sin_nid_postfix(double x) {
|
||||
(void)x;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Sincos(double x, double* sinp, double* cosp) {
|
||||
void Sincos_nid_postfix(double x, double* sinp, double* cosp) {
|
||||
(void)x;
|
||||
(void)sinp;
|
||||
(void)cosp;
|
||||
}
|
||||
|
||||
void sincos(double x, double* sinp, double* cosp) {
|
||||
void sincos_nid_postfix(double x, double* sinp, double* cosp) {
|
||||
(void)x;
|
||||
(void)sinp;
|
||||
(void)cosp;
|
||||
}
|
||||
|
||||
void sincosf(float x, float* sinp, float* cosp) {
|
||||
void sincosf_nid_postfix(float x, float* sinp, float* cosp) {
|
||||
(void)x;
|
||||
(void)sinp;
|
||||
(void)cosp;
|
||||
}
|
||||
|
||||
float sinf(float x) {
|
||||
float sinf_nid_postfix(float x) {
|
||||
(void)x;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int snprintf(VA_ARGS) {
|
||||
int snprintf_nid_postfix(VA_ARGS) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
char* strcat(char* dest, const char* src) {
|
||||
char* strcat_nid_postfix(char* dest, const char* src) {
|
||||
(void)dest;
|
||||
(void)src;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char* strchr(const char* s, int c) {
|
||||
const char* strchr_nid_postfix(const char* s, int c) {
|
||||
(void)s;
|
||||
(void)c;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int strcmp(const char* s1, const char* s2) {
|
||||
int strcmp_nid_postfix(const char* s1, const char* s2) {
|
||||
(void)s1;
|
||||
(void)s2;
|
||||
return 0;
|
||||
}
|
||||
|
||||
char* strcpy(char* dest, const char* src) {
|
||||
char* strcpy_nid_postfix(char* dest, const char* src) {
|
||||
(void)dest;
|
||||
(void)src;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
size_t strlen(const char* s) {
|
||||
size_t strlen_nid_postfix(const char* s) {
|
||||
(void)s;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int strncmp(const char* s1, const char* s2, size_t n) {
|
||||
int strncmp_nid_postfix(const char* s1, const char* s2, size_t n) {
|
||||
(void)s1;
|
||||
(void)s2;
|
||||
(void)n;
|
||||
return 0;
|
||||
}
|
||||
|
||||
char* strncpy(char* dest, const char* src, size_t count) {
|
||||
char* strncpy_nid_postfix(char* dest, const char* src, size_t count) {
|
||||
(void)dest;
|
||||
(void)src;
|
||||
(void)count;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
char* strrchr(const char* s, int c) {
|
||||
char* strrchr_nid_postfix(const char* s, int c) {
|
||||
(void)s;
|
||||
(void)c;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
char* strstr(const char* haystack, const char* needle) {
|
||||
char* strstr_nid_postfix(const char* haystack, const char* needle) {
|
||||
(void)haystack;
|
||||
(void)needle;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
long strtol(const char* str, char** endptr, int base) {
|
||||
long strtol_nid_postfix(const char* str, char** endptr, int base) {
|
||||
(void)str;
|
||||
(void)endptr;
|
||||
(void)base;
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned long strtoul(const char* str, char** endptr, int base) {
|
||||
unsigned long strtoul_nid_postfix(const char* str, char** endptr, int base) {
|
||||
(void)str;
|
||||
(void)endptr;
|
||||
(void)base;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int vprintf(const char* str, VaList* c) {
|
||||
int vprintf_nid_postfix(const char* str, VaList* c) {
|
||||
(void)str;
|
||||
(void)c;
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -11,14 +11,14 @@ int accept(int s, void* addr, uint32_t* addrlen) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int bind(int s, const void* addr, uint32_t addrlen) {
|
||||
int bind_nid_postfix(int s, const void* addr, uint32_t addrlen) {
|
||||
(void)s;
|
||||
(void)addr;
|
||||
(void)addrlen;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int chmod(const char* path, int mode) {
|
||||
int chmod_nid_postfix(const char* path, int mode) {
|
||||
(void)path;
|
||||
(void)mode;
|
||||
return 0;
|
||||
|
|
@ -36,7 +36,7 @@ int clock_gettime(int clock_id, KernelTimespec* time) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int close(int d) {
|
||||
int close_nid_postfix(int d) {
|
||||
(void)d;
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -48,17 +48,17 @@ int connect(int s, const void* addr, uint32_t addrlen) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
void exit(int code) {
|
||||
void exit_nid_postfix(int code) {
|
||||
(void)code;
|
||||
}
|
||||
|
||||
int flock(int d, int operation) {
|
||||
int flock_nid_postfix(int d, int operation) {
|
||||
(void)d;
|
||||
(void)operation;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int64_t fstat(int d, FileStat* sb) {
|
||||
int64_t fstat_nid_postfix(int d, FileStat* sb) {
|
||||
(void)d;
|
||||
(void)sb;
|
||||
return 0;
|
||||
|
|
@ -148,14 +148,14 @@ int nanosleep(const KernelTimespec* rqtp, KernelTimespec* rmtp) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int open(const char* path, int flags, int mode) {
|
||||
int open_nid_postfix(const char* path, int flags, int mode) {
|
||||
(void)path;
|
||||
(void)flags;
|
||||
(void)mode;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int64_t pread(int d, void* buf, size_t nbytes, int64_t offset) {
|
||||
int64_t pread_nid_postfix(int d, void* buf, size_t nbytes, int64_t offset) {
|
||||
(void)d;
|
||||
(void)buf;
|
||||
(void)nbytes;
|
||||
|
|
|
|||
|
|
@ -11,14 +11,14 @@ int accept(int s, void* addr, uint32_t* addrlen) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int bind(int s, const void* addr, uint32_t addrlen) {
|
||||
int bind_nid_postfix(int s, const void* addr, uint32_t addrlen) {
|
||||
(void)s;
|
||||
(void)addr;
|
||||
(void)addrlen;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int chmod(const char* path, int mode) {
|
||||
int chmod_nid_postfix(const char* path, int mode) {
|
||||
(void)path;
|
||||
(void)mode;
|
||||
return 0;
|
||||
|
|
@ -36,7 +36,7 @@ int clock_gettime(int clock_id, KernelTimespec* time) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int close(int d) {
|
||||
int close_nid_postfix(int d) {
|
||||
(void)d;
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -48,17 +48,17 @@ int connect(int s, const void* addr, uint32_t addrlen) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
void exit(int code) {
|
||||
void exit_nid_postfix(int code) {
|
||||
(void)code;
|
||||
}
|
||||
|
||||
int flock(int d, int operation) {
|
||||
int flock_nid_postfix(int d, int operation) {
|
||||
(void)d;
|
||||
(void)operation;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int64_t fstat(int d, FileStat* sb) {
|
||||
int64_t fstat_nid_postfix(int d, FileStat* sb) {
|
||||
(void)d;
|
||||
(void)sb;
|
||||
return 0;
|
||||
|
|
@ -148,14 +148,14 @@ int nanosleep(const KernelTimespec* rqtp, KernelTimespec* rmtp) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int open(const char* path, int flags, int mode) {
|
||||
int open_nid_postfix(const char* path, int flags, int mode) {
|
||||
(void)path;
|
||||
(void)flags;
|
||||
(void)mode;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int64_t pread(int d, void* buf, size_t nbytes, int64_t offset) {
|
||||
int64_t pread_nid_postfix(int d, void* buf, size_t nbytes, int64_t offset) {
|
||||
(void)d;
|
||||
(void)buf;
|
||||
(void)nbytes;
|
||||
|
|
|
|||
|
|
@ -11,14 +11,14 @@ int accept(int s, void* addr, uint32_t* addrlen) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int bind(int s, const void* addr, uint32_t addrlen) {
|
||||
int bind_nid_postfix(int s, const void* addr, uint32_t addrlen) {
|
||||
(void)s;
|
||||
(void)addr;
|
||||
(void)addrlen;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int chmod(const char* path, int mode) {
|
||||
int chmod_nid_postfix(const char* path, int mode) {
|
||||
(void)path;
|
||||
(void)mode;
|
||||
return 0;
|
||||
|
|
@ -36,7 +36,7 @@ int clock_gettime(int clock_id, KernelTimespec* time) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int close(int d) {
|
||||
int close_nid_postfix(int d) {
|
||||
(void)d;
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -48,17 +48,17 @@ int connect(int s, const void* addr, uint32_t addrlen) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
void exit(int code) {
|
||||
void exit_nid_postfix(int code) {
|
||||
(void)code;
|
||||
}
|
||||
|
||||
int flock(int d, int operation) {
|
||||
int flock_nid_postfix(int d, int operation) {
|
||||
(void)d;
|
||||
(void)operation;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int64_t fstat(int d, FileStat* sb) {
|
||||
int64_t fstat_nid_postfix(int d, FileStat* sb) {
|
||||
(void)d;
|
||||
(void)sb;
|
||||
return 0;
|
||||
|
|
@ -148,14 +148,14 @@ int nanosleep(const KernelTimespec* rqtp, KernelTimespec* rmtp) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int open(const char* path, int flags, int mode) {
|
||||
int open_nid_postfix(const char* path, int flags, int mode) {
|
||||
(void)path;
|
||||
(void)flags;
|
||||
(void)mode;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int64_t pread(int d, void* buf, size_t nbytes, int64_t offset) {
|
||||
int64_t pread_nid_postfix(int d, void* buf, size_t nbytes, int64_t offset) {
|
||||
(void)d;
|
||||
(void)buf;
|
||||
(void)nbytes;
|
||||
|
|
|
|||
Loading…
Reference in New Issue