Fix usage of _te32/_te64/_te16 for Elf classes
How did it ever work? UPX_RSIZE_MAX_MEM of 768MiB, Elf32_Off of only 32-bits, and preponderance of little-endian and small positive integers hides many mis-uses of _te64/_te32. ELF does not help: e_phnum, e_shnum, Elf32_Section, Elf64_Section are all 16-bit, but sh_info and sh_link are 32-bit. Templatizing p_elf.h (following the example of p_mach.h) failed because of complexity. (Plus too many special cases of ELF where 32-bit and 64-bit are not parallel.) modified: p_lx_elf.cpp modified: p_lx_sh.cpp modified: p_mach.cpp
This commit is contained in:
+1
-1
@@ -91,7 +91,7 @@ PackLinuxI386sh::buildLoader(Filter const *ft)
|
||||
// filter
|
||||
optimizeFilter(&fold_ft, buf, sz_fold);
|
||||
unsigned fold_hdrlen = sizeof(l_info) + sizeof(Elf32_Ehdr) +
|
||||
sizeof(Elf32_Phdr) * get_te32(&((Elf32_Ehdr const *)(void *)buf)->e_phnum);
|
||||
sizeof(Elf32_Phdr) * get_te16(&((Elf32_Ehdr const *)(void *)buf)->e_phnum);
|
||||
if (0 == get_le32(buf + fold_hdrlen)) {
|
||||
// inconsistent SIZEOF_HEADERS in *.lds (ld, binutils)
|
||||
fold_hdrlen = umax(0x80, fold_hdrlen);
|
||||
|
||||
Reference in New Issue
Block a user