1
0
mirror of https://github.com/upx/upx synced 2025-09-28 19:06:07 +08:00

armel-eabi-linux.elf (Debian) new protocol for system calls

This commit is contained in:
John Reiser 2008-07-20 05:41:51 -07:00
parent bf046a8ccb
commit f0c8dbe0ec
14 changed files with 1430 additions and 44 deletions

View File

@ -45,6 +45,8 @@
#define PT_LOAD32 Elf32_Phdr::PT_LOAD
#define PT_LOAD64 Elf64_Phdr::PT_LOAD
static unsigned const EF_ARM_HASENTRY = 0x02;
static unsigned const EF_ARM_EABI_VER4 = 0x04000000;
int
PackLinuxElf32::checkEhdr(Elf32_Ehdr const *ehdr) const
@ -720,6 +722,11 @@ PackOpenBSDElf32x86::buildLoader(const Filter *ft)
tmp, sizeof(stub_i386_openbsd_elf_fold), ft);
}
static const
#include "stub/armel-eabi-linux.elf-entry.h"
static const
#include "stub/armel-eabi-linux.elf-fold.h"
static const
#include "stub/arm-linux.elf-entry.h"
static const
@ -743,9 +750,16 @@ PackLinuxElf32armBe::buildLoader(Filter const *ft)
void
PackLinuxElf32armLe::buildLoader(Filter const *ft)
{
buildLinuxLoader(
stub_arm_linux_elf_entry, sizeof(stub_arm_linux_elf_entry),
stub_arm_linux_elf_fold, sizeof(stub_arm_linux_elf_fold), ft);
if (Elf32_Ehdr::ELFOSABI_LINUX==ei_osabi) {
buildLinuxLoader(
stub_armel_eabi_linux_elf_entry, sizeof(stub_armel_eabi_linux_elf_entry),
stub_armel_eabi_linux_elf_fold, sizeof(stub_armel_eabi_linux_elf_fold), ft);
}
else {
buildLinuxLoader(
stub_arm_linux_elf_entry, sizeof(stub_arm_linux_elf_entry),
stub_arm_linux_elf_fold, sizeof(stub_arm_linux_elf_fold), ft);
}
}
static const
@ -887,7 +901,15 @@ bool PackLinuxElf32::canPack()
}
}
if (Elf32_Ehdr::ELFOSABI_NONE==osabi0) { // No EI_OSBAI, no PT_NOTE.
osabi0 = opt->o_unix.osabi0; // Possibly specified by command-line.
if (Elf32_Ehdr::EM_ARM==e_machine
&& Elf32_Ehdr::ELFDATA2LSB==ei_data
&& EF_ARM_EABI_VER4==(0xff000000 & get_te32(&ehdr->e_flags))) {
// armel-eabi ARM little-endian Linux EABI version 4 is a mess.
ei_osabi = osabi0 = Elf32_Ehdr::ELFOSABI_LINUX;
}
else {
osabi0 = opt->o_unix.osabi0; // Possibly specified by command-line.
}
}
if (osabi0!=ei_osabi) {
return false;
@ -1298,7 +1320,15 @@ void PackLinuxElf32armLe::pack1(OutputFile *fo, Filter &ft)
{
super::pack1(fo, ft);
cprElfHdr3 h3;
memcpy(&h3, stub_arm_linux_elf_fold, sizeof(Elf32_Ehdr) + 2*sizeof(Elf32_Phdr));
if (Elf32_Ehdr::ELFOSABI_LINUX==ei_osabi) {
ei_osabi = Elf32_Ehdr::ELFOSABI_NONE;
memcpy(&h3, stub_armel_eabi_linux_elf_fold, sizeof(Elf32_Ehdr) + 2*sizeof(Elf32_Phdr));
set_te32(&h3.ehdr.e_flags, EF_ARM_EABI_VER4 | EF_ARM_HASENTRY);
}
else {
memcpy(&h3, stub_arm_linux_elf_fold, sizeof(Elf32_Ehdr) + 2*sizeof(Elf32_Phdr));
}
generateElfHdr(fo, &h3, getbrk(phdri, get_te16(&ehdri.e_phnum)) );
}

View File

@ -50,6 +50,8 @@ STUBS += amd64-linux.elf-entry.h
STUBS += amd64-linux.elf-fold.h
STUBS += amd64-linux.kernel.vmlinux.h
STUBS += amd64-linux.kernel.vmlinux-head.h
STUBS += armel-eabi-linux.elf-entry.h
STUBS += armel-eabi-linux.elf-fold.h
STUBS += arm-linux.elf-entry.h
STUBS += arm-linux.elf-fold.h
STUBS += arm-linux.kernel.vmlinux.h
@ -292,6 +294,32 @@ amd64-linux.kernel.vmlinux-head.h : $(srcdir)/src/$$T.S
$(call tc,bin2h) tmp/$T.bin $@
# /***********************************************************************
# // armel-eabi-linux.elf
# ************************************************************************/
armel-eabi-linux.elf%.h : tc_list = armel-eabi-linux.elf default
armel-eabi-linux.elf%.h : tc_bfdname = elf32-littlearm
tc.armel-eabi-linux.elf.gcc = arm-linux-gcc-4.1.0 -march=armv5 -nostdinc -MMD -MT $@
tc.armel-eabi-linux.elf.gcc += -fno-exceptions -fno-asynchronous-unwind-tables
tc.armel-eabi-linux.elf.gcc += -Wall -W -Wcast-align -Wcast-qual -Wstrict-prototypes -Wwrite-strings -Werror
armel-eabi-linux.elf-entry.h : $(srcdir)/src/$$T.S
$(call tc,gcc) -march=armv5 -c $< -o tmp/$T.bin
$(call tc,f-embed_objinfo,tmp/$T.bin)
$(call tc,bin2h) tmp/$T.bin $@
armel-eabi-linux.elf-fold.h : tmp/$$T.o tmp/arm-linux.elf-main.o $(srcdir)/src/arm-linux.elf-fold.lds
$(call tc,ld) --strip-all -T $(srcdir)/src/arm-linux.elf-fold.lds -Map tmp/$T.map $(filter %.o,$^) -o tmp/$T.bin
$(call tc,f-objstrip,tmp/$T.bin)
$(call tc,sstrip) tmp/$T.bin
$(call tc,bin2h) tmp/$T.bin $@
tmp/armel-eabi-linux.elf-fold.o : $(srcdir)/src/$$T.S
$(call tc,gcc) -c $< -o $@
$(call tc,f-objstrip,$@)
# /***********************************************************************
# // arm-linux.elf
# ************************************************************************/

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,179 @@
/* armel-eabi-linux.elf-fold.h
created from armel-eabi-linux.elf-fold.bin, 2236 (0x8bc) bytes
This file is part of the UPX executable compressor.
Copyright (C) 1996-2008 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2008 Laszlo Molnar
Copyright (C) 2000-2008 John F. Reiser
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
and/or modify them under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING.
If not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Markus F.X.J. Oberhumer Laszlo Molnar
<markus@oberhumer.com> <ml1050@users.sourceforge.net>
John F. Reiser
<jreiser@users.sourceforge.net>
*/
#define STUB_ARMEL_EABI_LINUX_ELF_FOLD_SIZE 2236
#define STUB_ARMEL_EABI_LINUX_ELF_FOLD_ADLER32 0x354c9303
#define STUB_ARMEL_EABI_LINUX_ELF_FOLD_CRC32 0x4060470c
unsigned char stub_armel_eabi_linux_elf_fold[2236] = {
/* 0x0000 */ 127, 69, 76, 70, 1, 1, 1, 97, 0, 0, 0, 0, 0, 0, 0, 0,
/* 0x0010 */ 2, 0, 40, 0, 1, 0, 0, 0,128,128, 0, 0, 52, 0, 0, 0,
/* 0x0020 */ 0, 0, 0, 0, 2, 0, 0, 0, 52, 0, 32, 0, 2, 0, 0, 0,
/* 0x0030 */ 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,128, 0, 0,
/* 0x0040 */ 0,128, 0, 0,188, 8, 0, 0,188, 8, 0, 0, 5, 0, 0, 0,
/* 0x0050 */ 0,128, 0, 0, 1, 0, 0, 0,188, 8, 0, 0, 0, 0, 0, 0,
/* 0x0060 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 0x0070 */ 0,128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 0x0080 */ 12, 48,157,229, 3, 49,141,224, 20, 48,131,226, 4, 0,147,228,
/* 0x0090 */ 0, 0, 80,227,252,255,255, 26, 3, 32,160,225, 8, 0,146,228,
/* 0x00a0 */ 0, 0, 80,227,252,255,255, 26, 8, 32,141,229, 10,220, 77,226,
/* 0x00b0 */ 9, 64,160,225, 4,144,154,229, 13,128,160,225, 0,112,154,229,
/* 0x00c0 */ 36, 96,143,226, 12,144,137,226, 0,176,160,227,248, 15, 45,233,
/* 0x00d0 */ 15, 0,189,232,158, 1, 0,235, 0,224,160,225, 20,208,141,226,
/* 0x00e0 */ 10,220,141,226, 7, 0,189,232, 4,240, 18,229,255, 48, 3,226,
/* 0x00f0 */ 80, 0, 83,227, 14,240,160, 17, 33, 17,176,225, 0, 0, 80, 19,
/* 0x0100 */ 14,240,160, 1, 1, 16, 65,226, 1, 33,144,231, 15, 52, 2,226,
/* 0x0110 */ 11, 4, 83,227, 4, 0, 0, 26,255, 52, 2,226, 1, 32, 66,224,
/* 0x0120 */ 255, 36,194,227, 3, 32,130,225, 1, 33,128,231, 0, 0, 81,227,
/* 0x0130 */ 243,255,255, 26, 14,240,160,225, 7,192,160,225, 1,112,160,227,
/* 0x0140 */ 0, 0, 0,239, 12,112,160,225, 7,192,160,225, 3,112,160,227,
/* 0x0150 */ 0, 0, 0,239, 12,112,160,225, 14,240,160,225, 7,192,160,225,
/* 0x0160 */ 4,112,160,227, 0, 0, 0,239, 12,112,160,225, 14,240,160,225,
/* 0x0170 */ 7,192,160,225, 5,112,160,227, 0, 0, 0,239, 12,112,160,225,
/* 0x0180 */ 14,240,160,225, 7,192,160,225, 6,112,160,227, 0, 0, 0,239,
/* 0x0190 */ 12,112,160,225, 14,240,160,225, 7,192,160,225, 45,112,160,227,
/* 0x01a0 */ 0, 0, 0,239, 12,112,160,225, 14,240,160,225, 7,192,160,225,
/* 0x01b0 */ 91,112,160,227, 0, 0, 0,239, 12,112,160,225, 14,240,160,225,
/* 0x01c0 */ 7,192,160,225,125,112,160,227, 0, 0, 0,239, 12,112,160,225,
/* 0x01d0 */ 14,240,160,225, 4, 80, 45,229, 8, 80,157,229, 4, 64, 45,229,
/* 0x01e0 */ 8, 64,157,229, 37, 86,160,225, 7,192,160,225,192,112,160,227,
/* 0x01f0 */ 0, 0, 0,239, 12,112,160,225, 4, 64,157,228, 4, 80,157,228,
/* 0x0200 */ 14,240,160,225, 0, 0, 80,227, 14,240,160, 1, 0, 48,144,229,
/* 0x0210 */ 1, 0, 83,225, 6, 0, 0, 10, 1, 0, 83,227, 0, 48,160, 19,
/* 0x0220 */ 1, 48,160, 3, 0, 0, 81,227, 0, 48,160, 3, 0, 0, 83,227,
/* 0x0230 */ 1, 0, 0, 10, 6, 0,128,232, 14,240,160,225, 8, 0,128,226,
/* 0x0240 */ 241,255,255,234, 0, 48,144,229, 2, 0, 83,225, 4, 48,144,229,
/* 0x0250 */ 4,224, 45,229, 3,192,160, 33, 2,224,160,225, 2, 32,160, 33,
/* 0x0260 */ 3, 0, 0, 42,127, 0,160,227,178,255,255,235, 1, 48, 92,229,
/* 0x0270 */ 1, 48, 65,229, 1, 32, 66,226, 1, 0,114,227, 1,192,140,226,
/* 0x0280 */ 1, 16,129,226,248,255,255, 26, 4, 32,144,229, 0, 48,144,229,
/* 0x0290 */ 14, 32,130,224, 3, 48,110,224, 0, 48,128,229, 4, 32,128,229,
/* 0x02a0 */ 4,240,157,228,240, 64, 45,233, 0, 80,160,225, 20,208, 77,226,
/* 0x02b0 */ 1, 64,160,225, 2,112,160,225, 3, 96,160,225, 68, 0, 0,234,
/* 0x02c0 */ 4, 16,141,226, 5, 0,160,225, 12, 32,160,227,220,255,255,235,
/* 0x02d0 */ 4,192,157,229, 0, 0, 92,227, 8, 16,157,229, 6, 0, 0, 26,
/* 0x02e0 */ 0, 49,159,229, 3, 0, 81,225, 5, 0, 0, 26, 0, 48,149,229,
/* 0x02f0 */ 0, 0, 83,227, 2, 0, 0, 26, 56, 0, 0,234, 0, 0, 81,227,
/* 0x0300 */ 1, 0, 0, 26,127, 0,160,227,138,255,255,235, 12, 0, 81,225,
/* 0x0310 */ 251,255,255,138, 0, 48,148,229, 3, 0, 92,225,248,255,255,138,
/* 0x0320 */ 12, 0, 81,225, 33, 0, 0, 42, 16,192,141,229, 12,192,157,229,
/* 0x0330 */ 4, 0,149,229, 4, 32,148,229, 16, 48,141,226, 0,192,141,229,
/* 0x0340 */ 15,224,160,225, 7,240,160,225, 0, 0, 80,227,236,255,255, 26,
/* 0x0350 */ 16, 16,157,229, 4, 48,157,229, 3, 0, 81,225,232,255,255, 26,
/* 0x0360 */ 13, 32,221,229, 0, 0, 82,227, 0, 0, 86, 19, 9, 0, 0, 10,
/* 0x0370 */ 2, 12, 81,227, 2, 0, 0,138, 0, 48,148,229, 1, 0, 83,225,
/* 0x0380 */ 4, 0, 0, 26, 2, 48,160,225, 4, 0,148,229, 14, 32,221,229,
/* 0x0390 */ 15,224,160,225, 6,240,160,225, 8, 48,157,229, 6, 0,149,232,
/* 0x03a0 */ 3, 32,130,224, 1, 16, 99,224, 6, 0,133,232, 3, 0, 0,234,
/* 0x03b0 */ 1, 32,160,225, 5, 0,160,225, 4, 16,148,229,160,255,255,235,
/* 0x03c0 */ 4, 48,157,229, 6, 0,148,232, 3, 32,130,224, 1, 16, 99,224,
/* 0x03d0 */ 6, 0,132,232, 0, 48,148,229, 0, 0, 83,227,183,255,255, 26,
/* 0x03e0 */ 20,208,141,226,240,128,189,232, 85, 80, 88, 33,240, 79, 45,233,
/* 0x03f0 */ 1,160,160,225,176,193,218,225, 28, 16,145,229,188,226,218,225,
/* 0x0400 */ 48,208, 77,226, 2, 0, 92,227, 1, 96,138,224, 16, 0,141,229,
/* 0x0410 */ 50,192,160, 3, 34,192,160, 19, 1,224, 78,226, 6, 16,160,225,
/* 0x0420 */ 0, 0,224,227, 0, 80,160,227, 12, 32,141,229, 8, 48,141,229,
/* 0x0430 */ 11, 0, 0,234, 0, 48,145,229, 1, 0, 83,227, 6, 0, 0, 26,
/* 0x0440 */ 8, 32,145,229, 20, 48,145,229, 3, 48,130,224, 3, 0, 85,225,
/* 0x0450 */ 3, 80,160, 49, 2, 0, 80,225, 2, 0,160, 33, 32, 16,129,226,
/* 0x0460 */ 1,224, 78,226, 0, 0, 94,227,241,255,255,170,255, 78,192,227,
/* 0x0470 */ 15, 64,196,227, 5, 48,100,224,255, 62,131,226, 15, 48,131,226,
/* 0x0480 */ 255, 62,195,227, 16,224, 28,226, 15, 48,195,227, 36, 48,141,229,
/* 0x0490 */ 28, 64,141, 21, 7, 0, 0, 26, 12, 48,160,225, 14, 32,160,225,
/* 0x04a0 */ 0,192,224,227, 4, 0,160,225, 36, 16,157,229, 0, 80,141,232,
/* 0x04b0 */ 71,255,255,235, 28, 0,141,229, 28, 16,157,229, 52, 48,160,227,
/* 0x04c0 */ 1,176,100,224,155, 3, 3,224, 0, 32,160,227, 32, 80,134,226,
/* 0x04d0 */ 32, 48,141,229, 24, 32,141,229,127, 0, 0,234, 12, 48,157,229,
/* 0x04e0 */ 0, 0, 83,227, 8, 0, 0, 10, 32, 48, 21,229, 6, 0, 83,227,
/* 0x04f0 */ 5, 0, 0, 26, 24, 32, 21,229, 8, 0,157,229, 2, 32,139,224,
/* 0x0500 */ 3, 16,160,227, 62,255,255,235,111, 0, 0,234, 32, 48, 21,229,
/* 0x0510 */ 1, 0, 83,227,108, 0, 0, 26, 8, 48, 21,229, 36, 34,159,229,
/* 0x0520 */ 7, 48, 3,226, 3, 49,160,225, 50, 35,160,225, 24, 48, 21,229,
/* 0x0530 */ 3,144,139,224, 12, 48,157,229, 16,224, 21,229, 9, 26,160,225,
/* 0x0540 */ 0, 0, 83,227, 33, 26,160,225, 28,192, 21,229, 7, 96, 2,226,
/* 0x0550 */ 12, 32, 21,229, 9,128, 97,224, 16, 64,157, 5, 1,112,142,224,
/* 0x0560 */ 20, 32,141,229, 0, 64,224, 19, 12,192, 97,224, 6, 32,160, 1,
/* 0x0570 */ 18, 48,160, 3, 2, 32,134, 19, 50, 48,160, 19, 8, 0,160,225,
/* 0x0580 */ 7, 16,160,225, 40,224,141,229, 16, 16,141,232, 44,144,141,229,
/* 0x0590 */ 15,255,255,235, 0, 0, 88,225, 56, 0, 0, 26, 12, 48,157,229,
/* 0x05a0 */ 0, 0, 83,227, 6, 0, 0, 10, 88, 16,157,229, 4, 48, 22,226,
/* 0x05b0 */ 1, 48,160, 17, 12, 0,157,229, 40, 16,141,226, 16, 32,157,229,
/* 0x05c0 */ 55,255,255,235, 0, 48,103,226, 3, 74,160,225, 2, 0, 22,227,
/* 0x05d0 */ 36, 74,160,225, 7, 0, 0, 10, 0, 0, 84,227, 5, 0, 0, 10,
/* 0x05e0 */ 7, 16,136,224, 4, 32,160,225, 0, 48,160,227, 1, 32, 82,226,
/* 0x05f0 */ 1, 48,193,228,251,255,255, 26, 12, 32,157,229, 0, 0, 82,227,
/* 0x0600 */ 32, 0, 0, 10, 32, 48, 21,229, 1, 0, 83,227, 21, 0, 0, 26,
/* 0x0610 */ 8, 48, 21,229, 1, 0, 19,227, 18, 0, 0, 10, 12, 32, 21,229,
/* 0x0620 */ 16, 48, 21,229, 3, 0, 82,225, 24, 16, 21,229, 62, 0, 0, 26,
/* 0x0630 */ 1, 48,130,224, 11, 32,131,224, 0, 48, 98,226, 3, 58,160,225,
/* 0x0640 */ 35, 58,160,225, 7, 0, 83,227, 55, 0, 0,154,248, 48,159,229,
/* 0x0650 */ 0, 48,130,229,244, 48,159,229, 8, 0,157,229, 4, 48,130,229,
/* 0x0660 */ 0, 16,160,227,230,254,255,235, 8, 0,160,225, 7, 16,160,225,
/* 0x0670 */ 6, 32,160,225,209,254,255,235, 0, 0, 80,227, 1, 0, 0, 10,
/* 0x0680 */ 127, 0,160,227,171,254,255,235, 20, 32,157,229, 4, 48,135,224,
/* 0x0690 */ 2, 16,137,224, 3, 64,136,224, 1, 0, 84,225, 10, 0, 0, 42,
/* 0x06a0 */ 0,192,224,227, 0,192,141,229, 1, 16,100,224, 1,192,140,226,
/* 0x06b0 */ 6, 32,160,225, 4, 0,160,225, 50, 48,160,227, 4,192,141,229,
/* 0x06c0 */ 195,254,255,235, 0, 0, 84,225,236,255,255, 26, 24, 48,157,229,
/* 0x06d0 */ 1, 48,131,226, 24, 48,141,229, 32, 80,133,226,188, 50,218,225,
/* 0x06e0 */ 24, 16,157,229, 3, 0, 81,225,123,255,255,186, 12, 32,157,229,
/* 0x06f0 */ 0, 0, 82,227, 5, 0, 0, 10,176, 49,218,225, 3, 0, 83,227,
/* 0x0700 */ 28, 48,157, 21, 36, 16,157, 21, 1, 0,131, 16,161,254,255, 27,
/* 0x0710 */ 84, 32,157,229, 0, 0, 82,227, 0,176,130, 21, 24, 0,154,229,
/* 0x0720 */ 0, 0,139,224, 48,208,141,226,240,143,189,232, 28, 48, 21,229,
/* 0x0730 */ 0, 0, 83,227, 32, 32,157, 5, 2, 48,129, 0, 8, 32,131, 2,
/* 0x0740 */ 193,255,255, 10,199,255,255,234, 64, 98, 81,115, 91, 0,144,239,
/* 0x0750 */ 14,240,160,225,240, 71, 45,233, 12,208, 77,226, 52, 96,141,226,
/* 0x0760 */ 0,144,160,225, 1, 80,160,225, 3,128,160,225, 6, 0,160,225,
/* 0x0770 */ 0, 48,160,227, 44, 16,141,226, 48,160,157,229, 2,112,160,225,
/* 0x0780 */ 52, 64,157,229,198,254,255,235, 56, 48,157,229, 5, 16,160,227,
/* 0x0790 */ 3, 48,100,224,188, 34,218,225, 9, 0,160,225, 56, 48,141,229,
/* 0x07a0 */ 52, 80,141,229,150,254,255,235, 9, 0,160,225, 4, 16,160,227,
/* 0x07b0 */ 186, 34,218,225,146,254,255,235, 52, 64,138,226, 60, 32,157,229,
/* 0x07c0 */ 8, 48,148,229, 52, 32,130,226, 3, 32,130,224, 9, 0,160,225,
/* 0x07d0 */ 3, 16,160,227,138,254,255,235, 8,192,141,226, 6, 32,160,225,
/* 0x07e0 */ 10, 16,160,225, 9, 48,160,225, 7, 0,160,225, 0,192,141,229,
/* 0x07f0 */ 4,128,141,229,252,254,255,235, 0, 80,160,225, 9, 16,160,227,
/* 0x0800 */ 5, 32,160,225, 9, 0,160,225,125,254,255,235,188, 18,218,225,
/* 0x0810 */ 0, 32,160,227, 35, 0, 0,234, 0, 48,148,229, 3, 0, 83,227,
/* 0x0820 */ 30, 0, 0, 26, 8, 48,148,229, 8, 0,157,229, 0, 16,160,227,
/* 0x0830 */ 0, 0,131,224, 1, 32,160,225, 76,254,255,235, 0, 64, 80,226,
/* 0x0840 */ 4, 0, 0,186, 10, 16,160,225, 2, 44,160,227, 61,254,255,235,
/* 0x0850 */ 2, 12, 80,227, 1, 0, 0, 10,127, 0,160,227, 53,254,255,235,
/* 0x0860 */ 0,224,160,227, 14, 32,160,225, 8,192,141,226, 10, 16,160,225,
/* 0x0870 */ 9, 48,160,225, 4, 0,160,225, 0, 80,141,232,218,254,255,235,
/* 0x0880 */ 7, 16,160,227, 0, 80,160,225, 8, 32,157,229, 9, 0,160,225,
/* 0x0890 */ 91,254,255,235, 4, 0,160,225, 57,254,255,235, 3, 0, 0,234,
/* 0x08a0 */ 32, 64,132,226, 1, 32,130,226, 1, 0, 82,225,217,255,255,186,
/* 0x08b0 */ 5, 0,160,225, 12,208,141,226,240,135,189,232
};

View File

@ -108,16 +108,12 @@
mov sp,fp
#if defined(LINUX_ARM_CACHEFLUSH) /*{*/
/* linux/include/asm-arm/unistd.h */
#define __NR_SYSCALL_BASE 0x900000
#define __ARM_NR_BASE (__NR_SYSCALL_BASE+0x0f0000)
#define __ARM_NR_cacheflush (__ARM_NR_BASE+2)
mov r3,r0 // save result value
POP {r0,r1} // dst, ldst
ldr r1,[r1] // ldst by reference
add r1,r1,r0 // just beyond what was written
mov r2,#0
swi __ARM_NR_cacheflush // decompressed region
do_sys2 __ARM_NR_cacheflush // decompressed region
mov r0,r3 // result value
#endif /*}*/

View File

@ -34,4 +34,37 @@
.section \name
.endm
#if defined(ARMEL_EABI4) /*{*/
__NR_SYSCALL_BASE = 0
.macro do_sys N
mov r12,r7 // save r7 in ip
mov r7,#\N // syscall number
swi 0
mov r7,r12 // restore r7 from ip
.endm
.macro do_sys2 N
mov r12,r7 // save r7 in ip
mov r7, #(\N) & 0xff // syscall number
orr r7,r7,#(\N) &~0xff // high bits
swi 0
mov r7,r12 // restore r7 from ip
.endm
#else /*}{*/
__NR_SYSCALL_BASE = 0x900000
.macro do_sys N
swi \N
.endm
.macro do_sys2 N
swi \N
.endm
#endif /*}*/
.macro ret
mov pc,lr /* armv4 fails for thumb interworking */
.endm
// vi:ts=8:et:nowrap

View File

@ -71,15 +71,11 @@ eof_n2b:
str dst,[r4]
#if defined(LINUX_ARM_CACHEFLUSH) /*{*/
/* linux/include/asm-arm/unistd.h */
#define __NR_SYSCALL_BASE 0x900000
#define __ARM_NR_BASE (__NR_SYSCALL_BASE+0x0f0000)
#define __ARM_NR_cacheflush (__ARM_NR_BASE+2)
mov r4,r0 // save result value
mov r0,r3 // orig_dst
add r1,r3,dst // orig_dst + dst_len
mov r2,#0
swi __ARM_NR_cacheflush // decompressed region
do_sys2 __ARM_NR_cacheflush // decompressed region
mov r0,r4 // result value
#endif /*}*/

View File

@ -111,15 +111,11 @@ eof_n2d:
str dst,[r4]
#if defined(LINUX_ARM_CACHEFLUSH) /*{*/
/* linux/include/asm-arm/unistd.h */
#define __NR_SYSCALL_BASE 0x900000
#define __ARM_NR_BASE (__NR_SYSCALL_BASE+0x0f0000)
#define __ARM_NR_cacheflush (__ARM_NR_BASE+2)
mov r4,r0 // save result value
mov r0,r3 // orig_dst
add r1,r3,dst // orig_dst + dst_len
mov r2,#0
swi __ARM_NR_cacheflush // decompressed region
do_sys2 __ARM_NR_cacheflush // decompressed region
mov r0,r4 // result value
#endif /*}*/

View File

@ -111,15 +111,11 @@ eof_n2e:
str dst,[r4]
#if defined(LINUX_ARM_CACHEFLUSH) /*{*/
/* linux/include/asm-arm/unistd.h */
#define __NR_SYSCALL_BASE 0x900000
#define __ARM_NR_BASE (__NR_SYSCALL_BASE+0x0f0000)
#define __ARM_NR_cacheflush (__ARM_NR_BASE+2)
mov r4,r0 // save result value
mov r0,r3 // orig_dst
add r1,r3,dst // orig_dst + dst_len
mov r2,#0
swi __ARM_NR_cacheflush // decompressed region
do_sys2 __ARM_NR_cacheflush // decompressed region
mov r0,r4 // result value
#endif /*}*/

View File

@ -34,6 +34,39 @@
.section \name
.endm
#if defined(ARMEL_EABI4) /*{*/
__NR_SYSCALL_BASE = 0
.macro do_sys N
mov r12,r7 // save r7 in ip
mov r7,#\N // syscall number
swi 0
mov r7,r12 // restore r7 from ip
.endm
.macro do_sys2 N
mov r12,r7 // save r7 in ip
mov r7, #(\N) & 0xff // syscall number
orr r7,r7,#(\N) &~0xff // high bits
swi 0
mov r7,r12 // restore r7 from ip
.endm
#else /*}{*/
__NR_SYSCALL_BASE = 0x900000
.macro do_sys N
swi \N
.endm
.macro do_sys2 N
swi \N
.endm
#endif /*}*/
.macro ret
bx lr /* armv5 for thumb interworking */
.endm
.macro loadcon8 reg,val8
.long (0xe3<<24)|(0xa0<<16)|((\reg<<4)<<8)+(\val8) /* mov \reg,#\val8 */
.endm

View File

@ -53,6 +53,13 @@ MAP_ANONYMOUS= 0x20
PAGE_SHIFT= 12
PAGE_SIZE = -(~0<<PAGE_SHIFT)
__NR_exit = 1 + __NR_SYSCALL_BASE
__NR_write = 4 + __NR_SYSCALL_BASE
__NR_mmap64 = 0xc0 + __NR_SYSCALL_BASE
__ARM_NR_BASE = 0xf0000 + __NR_SYSCALL_BASE
__ARM_NR_cacheflush = 2 + __ARM_NR_BASE
//.long sz_pack2 // placed there by ::pack3()
section ELFMAINX
start_params:
@ -77,7 +84,12 @@ D_sz_unc=2*4 // stack displacement to sz_unc
mov r2,#PROT_READ | PROT_WRITE | PROT_EXEC
mov r3,#MAP_PRIVATE | MAP_FIXED | MAP_ANONYMOUS
mvn r4,#0 // -1; cater to *BSD for fd when MAP_ANON
swi 0x009000c0 // mmap64
#if defined(ARMEL_EABI4) /*{*/
mov r7,#__NR_mmap64
swi 0
#else /*}{*/
swi __NR_mmap64
#endif /*}*/
cmn r0,#4096
bcs msg_SELinux
copy:
@ -89,15 +101,16 @@ copy:
mov lr,r0 // dst for unfolded code
add r5,r5,r4 // relocated f_decompress
/* linux/include/asm-arm/unistd.h */
#define __NR_SYSCALL_BASE 0x900000
#define __ARM_NR_BASE (__NR_SYSCALL_BASE+0x0f0000)
#define __ARM_NR_cacheflush (__ARM_NR_BASE+2)
mov r0,r5
add r1,r9,r4 // relocated end_decompress
mov r2,#0
swi __ARM_NR_cacheflush // relocated decompressor
#if defined(ARMEL_EABI4) /*{*/
mov r7, #__ARM_NR_cacheflush& 0xff
orr r7,r7,#__ARM_NR_cacheflush&~0xff
swi 0
#else /*}{*/
swi __ARM_NR_cacheflush
#endif /*}*/
ldr r9,[r12] // sz_pack2
sub r9,r9,#sz_Elf32_Ehdr + 2*sz_Elf32_Phdr + sz_l_info + sz_p_info
@ -142,10 +155,20 @@ msg_SELinux:
mov r2,#L71 - L70 // length
adr r1,L70 // message text
mov r0,#2 // fd stderr
swi 0x00900004 // write
#if defined(ARMEL_EABI4) /*{*/
mov r7,#__NR_write
swi 0
#else /*}{*/
swi __NR_write
#endif /*}*/
die:
mov r0,#127
swi 0x00900001 // exit
#if defined(ARMEL_EABI4) /*{*/
mov r7,#__NR_exit
swi 0
#else /*}{*/
swi __NR_exit
#endif /*}*/
L70:
.asciz "PROT_EXEC|PROT_WRITE failed.\n"
L71:

View File

@ -123,47 +123,58 @@ tst_unf:
.unreq cto
.unreq fid
__NR_exit = 1 + __NR_SYSCALL_BASE
__NR_read = 3 + __NR_SYSCALL_BASE
__NR_write = 4 + __NR_SYSCALL_BASE
__NR_open = 5 + __NR_SYSCALL_BASE
__NR_close = 6 + __NR_SYSCALL_BASE
__NR_brk = 45 + __NR_SYSCALL_BASE
__NR_mmap2 = 192 + __NR_SYSCALL_BASE
__NR_mprotect = 125 + __NR_SYSCALL_BASE
__NR_munmap = 91 + __NR_SYSCALL_BASE
.globl exit
exit:
swi 0x00900001
do_sys __NR_exit
.globl read
read:
swi 0x00900003; mov pc,lr
do_sys __NR_read; ret
.globl write
write:
swi 0x00900004; mov pc,lr
do_sys __NR_write; ret
.globl open
open:
swi 0x00900005; mov pc,lr
do_sys __NR_open; ret
.globl close
close:
swi 0x00900006; mov pc,lr
do_sys __NR_close; ret
.globl brk
brk:
swi 0x0090002d; mov pc,lr
do_sys __NR_brk; ret
.globl munmap
munmap:
swi 0x0090005b; mov pc,lr
do_sys __NR_munmap; ret
.globl mprotect
mprotect:
swi 0x0090007d; mov pc,lr
do_sys __NR_mprotect; ret
.globl mmap
mmap:
str r5,[sp,#-4]!; ldr r5,[sp,#4+4]
str r4,[sp,#-4]!; ldr r4,[sp,#4+4]
mov r5,r5,lsr #12 @ convert to page number
swi 0x009000c0 @ mmap64
do_sys __NR_mmap2
ldr r4,[sp],#4
ldr r5,[sp],#4
mov pc,lr
ret
#if 0 /*{ "gcc-3.4 -fPIC" botches string constants when code moves! */
.globl STR_0x

View File

@ -0,0 +1,2 @@
#define ARMEL_EABI4 1
#include "arm-linux.elf-entry.S"

View File

@ -0,0 +1,2 @@
#define ARMEL_EABI4 1
#include "arm-linux.elf-fold.S"