Many changes for ELF shared libraries on Linux and Android

Handling more than 2 PT_LOAD (and thus more than 1 executable PT_LOAD)
required extensive changes.  But the bonus is the infrastructure
to support a different (de-)compression algorithm for each PT_LOAD.

https://github.com/upx/upx/issues/341   i386 .so decompression
https://github.com/upx/upx/issues/609   armv7 .so on Android
https://github.com/upx/upx/issues/625   amd64 .so execution
https://github.com/upx/upx/issues/654   armv7 .exe
Not yet: .so on MIPS, PowerPC, PowerPC64
This commit is contained in:
John Reiser
2023-03-04 17:37:25 -08:00
committed by Markus F.X.J. Oberhumer
parent fa56a1d9cd
commit adb0ca8250
121 changed files with 15796 additions and 6036 deletions
+4 -2
View File
@@ -62,8 +62,10 @@ ElfLinker::Section::Section(const char *n, const void *i, unsigned s, unsigned a
assert(name != nullptr);
input = malloc(s + 1);
assert(input != nullptr);
if (s != 0)
if (s != 0) {
assert(i != nullptr);
memcpy(input, i, s);
}
((char *) input)[s] = 0;
}
@@ -197,7 +199,7 @@ void ElfLinker::preprocessSections(char *start, char const *end) {
unsigned offset, size, align;
char name[1024];
if (sscanf(start, "%*d %1023s %x %*d %*d %x 2**%d", name, &size, &offset, &align) == 4) {
if (sscanf(start, "%*d %1023s %x %*x %*x %x 2**%d", name, &size, &offset, &align) == 4) {
char *n = strstr(start, name);
n[strlen(name)] = 0;
addSection(n, input + offset, size, align);