Start using the new intergral type names.

This commit is contained in:
Markus F.X.J. Oberhumer
2013-09-20 08:19:18 +02:00
parent 07b65ca069
commit b2643b6926
19 changed files with 177 additions and 178 deletions
+33 -33
View File
@@ -63,8 +63,8 @@ umin(unsigned a, unsigned b)
return (a < b) ? a : b;
}
static acc_uint64l_t
umin64(acc_uint64l_t a, acc_uint64l_t b)
static upx_uint64_t
umin64(upx_uint64_t a, upx_uint64_t b)
{
return (a < b) ? a : b;
}
@@ -173,7 +173,7 @@ PackLinuxElf64::checkEhdr(Elf64_Ehdr const *ehdr) const
if (type == Elf64_Ehdr::ET_EXEC) {
// check for Linux kernels
acc_uint64l_t const entry = get_te64(&ehdr->e_entry);
upx_uint64_t const entry = get_te64(&ehdr->e_entry);
if (entry == 0xC0100000) // uncompressed vmlinux
return 1000;
if (entry == 0x00001000) // compressed vmlinux
@@ -364,13 +364,13 @@ void PackLinuxElf64::pack3(OutputFile *fo, Filter &ft)
Elf64_Phdr *phdr = phdri;
unsigned off = fo->st_size();
unsigned off_init = 0; // where in file
acc_uint64l_t va_init = sz_pack2; // virtual address
acc_uint64l_t rel = 0;
acc_uint64l_t old_dtinit = 0;
upx_uint64_t va_init = sz_pack2; // virtual address
upx_uint64_t rel = 0;
upx_uint64_t old_dtinit = 0;
for (int j = e_phnum; --j>=0; ++phdr) {
acc_uint64l_t const len = get_te64(&phdr->p_filesz);
acc_uint64l_t const ioff = get_te64(&phdr->p_offset);
acc_uint64l_t align= get_te64(&phdr->p_align);
upx_uint64_t const len = get_te64(&phdr->p_filesz);
upx_uint64_t const ioff = get_te64(&phdr->p_offset);
upx_uint64_t align= get_te64(&phdr->p_align);
unsigned const type = get_te32(&phdr->p_type);
if (phdr->PT_INTERP==type) {
// Rotate to highest position, so it can be lopped
@@ -428,7 +428,7 @@ void PackLinuxElf64::pack3(OutputFile *fo, Filter &ft)
}
if (off_init) { // change DT_INIT.d_val
fo->seek(off_init, SEEK_SET);
acc_uint64l_t word; set_te64(&word, va_init);
upx_uint64_t word; set_te64(&word, va_init);
fo->rewrite(&word, sizeof(word));
fo->seek(0, SEEK_END);
}
@@ -860,22 +860,22 @@ PackLinuxElf64amd::defineSymbols(Filter const *)
// know the final total compressed size yet, so use the uncompressed
// size (total over all PT_LOAD64) as an upper bound.
unsigned len = 0;
acc_uint64l_t lo_va_user = ~0ull; // infinity
upx_uint64_t lo_va_user = ~0ull; // infinity
for (int j= e_phnum; --j>=0; ) {
if (PT_LOAD64 == get_te32(&phdri[j].p_type)) {
len += (unsigned)get_te64(&phdri[j].p_filesz);
acc_uint64l_t const va = get_te64(&phdri[j].p_vaddr);
upx_uint64_t const va = get_te64(&phdri[j].p_vaddr);
if (va < lo_va_user) {
lo_va_user = va;
}
}
}
lsize = /*getLoaderSize()*/ 64 * 1024; // XXX: upper bound; avoid circularity
acc_uint64l_t lo_va_stub = get_te64(&elfout.phdr[0].p_vaddr);
acc_uint64l_t adrc;
acc_uint64l_t adrm;
acc_uint64l_t adru;
acc_uint64l_t adrx;
upx_uint64_t lo_va_stub = get_te64(&elfout.phdr[0].p_vaddr);
upx_uint64_t adrc;
upx_uint64_t adrm;
upx_uint64_t adru;
upx_uint64_t adrx;
unsigned cntc;
unsigned lenm;
unsigned lenu;
@@ -1479,8 +1479,8 @@ PackLinuxElf64amd::canPack()
throwCantPack("invalid Ehdr e_ehsize; try '--force-execve'");
return false;
}
acc_uint64l_t const e_shoff = get_te64(&ehdr->e_shoff);
acc_uint64l_t const e_phoff = get_te64(&ehdr->e_phoff);
upx_uint64_t const e_shoff = get_te64(&ehdr->e_shoff);
upx_uint64_t const e_phoff = get_te64(&ehdr->e_phoff);
if (e_phoff != sizeof(*ehdr)) {// Phdrs not contiguous with Ehdr
throwCantPack("non-contiguous Ehdr/Phdr; try '--force-execve'");
return false;
@@ -1588,8 +1588,8 @@ PackLinuxElf64amd::canPack()
}
}
// Rely on 0==elf_unsigned_dynamic(tag) if no such tag.
acc_uint64l_t const va_gash = elf_unsigned_dynamic(Elf64_Dyn::DT_GNU_HASH);
acc_uint64l_t const va_hash = elf_unsigned_dynamic(Elf64_Dyn::DT_HASH);
upx_uint64_t const va_gash = elf_unsigned_dynamic(Elf64_Dyn::DT_GNU_HASH);
upx_uint64_t const va_hash = elf_unsigned_dynamic(Elf64_Dyn::DT_HASH);
if (xct_va < va_gash || (0==va_gash && xct_va < va_hash)
|| xct_va < elf_unsigned_dynamic(Elf64_Dyn::DT_STRTAB)
|| xct_va < elf_unsigned_dynamic(Elf64_Dyn::DT_SYMTAB)
@@ -1605,7 +1605,7 @@ PackLinuxElf64amd::canPack()
goto abandon;
}
for ((shdr= shdri), (j= n_elf_shnum); --j>=0; ++shdr) {
acc_uint64l_t const sh_addr = get_te64(&shdr->sh_addr);
upx_uint64_t const sh_addr = get_te64(&shdr->sh_addr);
if ( sh_addr==va_gash
|| (sh_addr==va_hash && 0==va_gash) ) {
shdr= &shdri[get_te32(&shdr->sh_link)]; // the associated SHT_SYMTAB
@@ -2871,7 +2871,7 @@ void PackLinuxElf64::pack4(OutputFile *fo, Filter &ft)
// rewrite Elf header
if (Elf64_Ehdr::ET_DYN==get_te16(&ehdri.e_type)) {
acc_uint64l_t const base= get_te64(&elfout.phdr[0].p_vaddr);
upx_uint64_t const base= get_te64(&elfout.phdr[0].p_vaddr);
set_te16(&elfout.ehdr.e_type, Elf64_Ehdr::ET_DYN);
set_te16(&elfout.ehdr.e_phnum, 1);
set_te64( &elfout.ehdr.e_entry,
@@ -2889,7 +2889,7 @@ void PackLinuxElf64::pack4(OutputFile *fo, Filter &ft)
}
else {
if (Elf64_Phdr::PT_NOTE==get_te64(&elfout.phdr[2].p_type)) {
acc_uint64l_t const reloc = get_te64(&elfout.phdr[0].p_vaddr);
upx_uint64_t const reloc = get_te64(&elfout.phdr[0].p_vaddr);
set_te64( &elfout.phdr[2].p_vaddr,
reloc + get_te64(&elfout.phdr[2].p_vaddr));
set_te64( &elfout.phdr[2].p_paddr,
@@ -2918,7 +2918,7 @@ void PackLinuxElf64::unpack(OutputFile *fo)
{
fi->seek(0, SEEK_SET);
fi->readx(u.buf, MAX_ELF_HDR);
acc_uint64l_t const e_entry = get_te64(&ehdr->e_entry);
upx_uint64_t const e_entry = get_te64(&ehdr->e_entry);
if (e_entry < 0x401180
&& ehdr->e_machine==Elf64_Ehdr::EM_386) { /* old style, 8-byte b_info */
szb_info = 2*sizeof(unsigned);
@@ -2961,8 +2961,8 @@ void PackLinuxElf64::unpack(OutputFile *fo)
fi->seek(- (off_t) (szb_info + ph.c_len), SEEK_CUR);
for (unsigned j=0; j < u_phnum; ++phdr, ++j) {
if (PT_LOAD64==get_te32(&phdr->p_type)) {
acc_uint64l_t const filesz = get_te64(&phdr->p_filesz);
acc_uint64l_t const offset = get_te64(&phdr->p_offset);
upx_uint64_t const filesz = get_te64(&phdr->p_filesz);
upx_uint64_t const offset = get_te64(&phdr->p_offset);
if (fo)
fo->seek(offset, SEEK_SET);
if (Elf64_Phdr::PF_X & get_te32(&phdr->p_flags)) {
@@ -3221,7 +3221,7 @@ PackLinuxElf32::elf_find_dynamic(unsigned int const key) const
return 0;
}
acc_uint64l_t
upx_uint64_t
PackLinuxElf32::elf_unsigned_dynamic(unsigned int const key) const
{
Elf32_Dyn const *dynp= dynseg;
@@ -3232,13 +3232,13 @@ PackLinuxElf32::elf_unsigned_dynamic(unsigned int const key) const
return 0;
}
acc_uint64l_t
PackLinuxElf64::elf_get_offset_from_address(acc_uint64l_t const addr) const
upx_uint64_t
PackLinuxElf64::elf_get_offset_from_address(upx_uint64_t const addr) const
{
Elf64_Phdr const *phdr = phdri;
int j = e_phnum;
for (; --j>=0; ++phdr) if (PT_LOAD64 == get_te32(&phdr->p_type)) {
acc_uint64l_t const t = addr - get_te64(&phdr->p_vaddr);
upx_uint64_t const t = addr - get_te64(&phdr->p_vaddr);
if (t < get_te64(&phdr->p_filesz)) {
return t + get_te64(&phdr->p_offset);
}
@@ -3263,7 +3263,7 @@ PackLinuxElf64::elf_find_dynamic(unsigned int const key) const
Elf64_Dyn const *dynp= dynseg;
if (dynp)
for (; Elf64_Dyn::DT_NULL!=dynp->d_tag; ++dynp) if (get_te64(&dynp->d_tag)==key) {
acc_uint64l_t const t= elf_get_offset_from_address(get_te64(&dynp->d_val));
upx_uint64_t const t= elf_get_offset_from_address(get_te64(&dynp->d_val));
if (t) {
return (size_t)t + file_image;
}
@@ -3272,7 +3272,7 @@ PackLinuxElf64::elf_find_dynamic(unsigned int const key) const
return 0;
}
acc_uint64l_t
upx_uint64_t
PackLinuxElf64::elf_unsigned_dynamic(unsigned int const key) const
{
Elf64_Dyn const *dynp= dynseg;