From b34e20467611d867bd030a8991508bd358d94775 Mon Sep 17 00:00:00 2001 From: John Reiser Date: Sun, 16 Jul 2006 15:04:16 -0700 Subject: [PATCH] PackLinuxElf32ppc conversion; alignment in *::Section --- src/linker.cpp | 62 ++++-- src/linker.h | 11 +- src/p_lx_elf.cpp | 13 +- src/p_lx_exc.cpp | 2 +- src/p_lx_interp.cpp | 2 +- src/p_mach.cpp | 4 +- src/packer.cpp | 2 +- src/stub/Makefile | 8 +- src/stub/powerpc-linux.elf-entry.h | 252 ++++++++++++++++++++----- src/stub/src/arch/powerpc/32/nrv2b_d.S | 112 +++++------ src/stub/src/arch/powerpc/32/nrv2e_d.S | 90 ++++----- src/stub/src/powerpc-linux.elf-entry.S | 105 +++++++---- src/stub/src/powerpc-linux.elf-fold.S | 50 ++--- 13 files changed, 456 insertions(+), 257 deletions(-) diff --git a/src/linker.cpp b/src/linker.cpp index dc92ecb6..a78a544d 100644 --- a/src/linker.cpp +++ b/src/linker.cpp @@ -71,6 +71,7 @@ struct DefaultLinker::Section int istart; int ostart; int len; + unsigned char align; DefaultLinker::Label name; }; @@ -196,13 +197,14 @@ int DefaultLinker::addSection(const char *sname) } -void DefaultLinker::addSection(const char *sname, const void *sdata, int slen) +void DefaultLinker::addSection(const char *sname, const void *sdata, int slen, int align) { assert(!frozen); // add a new section - can be used for adding stuff like ident or header sections[nsections].name.set(sname); sections[nsections].istart = ilen; sections[nsections].len = slen; + sections[nsections].align = align; sections[nsections++].ostart = olen; assert(nsections < NSECTIONS); memcpy(iloader+ilen, sdata, slen); @@ -314,10 +316,10 @@ int SimpleLinker::addSection(const char *sname) } -void SimpleLinker::addSection(const char *sname, const void *sdata, int slen) +void SimpleLinker::addSection(const char *sname, const void *sdata, int slen, int align) { assert(!frozen); - UNUSED(sname); UNUSED(sdata); UNUSED(slen); + UNUSED(sname); UNUSED(sdata); UNUSED(slen); UNUSED(align); assert(0); } @@ -350,8 +352,8 @@ unsigned char *SimpleLinker::getLoader(int *llen) // **************************************************************************/ -ElfLinker::Section::Section(const char *n, const void *i, unsigned s) : - name(strdup(n)), output(NULL), size(s), offset(0), next(NULL) +ElfLinker::Section::Section(const char *n, const void *i, unsigned s, unsigned a) : + name(strdup(n)), output(NULL), size(s), offset(0), align(a), next(NULL) { assert(name); input = malloc(s + 1); @@ -388,24 +390,24 @@ void ElfLinker::preprocessSections(char *start, const char *end) while (start < end) { char name[1024]; - unsigned offset, size; + unsigned offset, size, align; char *nextl = strchr(start, '\n'); assert(nextl != NULL); - if (sscanf(start, "%*d %1023s %x %*d %*d %x", - name, &size, &offset) == 3) + if (sscanf(start, "%*d %1023s %x %*d %*d %x 2**%d", + name, &size, &offset, &align) == 4) { char *n = strstr(start, name); n[strlen(name)] = 0; - addSection(n, input + offset, size); + addSection(n, input + offset, size, align); //printf("section %s preprocessed\n", n); } start = nextl + 1; } - addSection("*ABS*", NULL, 0); - addSection("*UND*", NULL, 0); + addSection("*ABS*", NULL, 0, 0); + addSection("*UND*", NULL, 0, 0); } void ElfLinker::preprocessSymbols(char *start, const char *end) @@ -614,6 +616,15 @@ int ElfLinker::addSection(const char *sname) else { Section *section = findSection(sect); + if (section->align) { + unsigned const v = ~0u << section->align; + assert(tail); + if (unsigned const l = ~v & -(tail->offset + tail->size)) { + align(l); + tail->size += l; + outputlen += l; + } + } memcpy(output + outputlen, section->input, section->size); section->output = output + outputlen; outputlen += section->size; @@ -634,13 +645,13 @@ int ElfLinker::addSection(const char *sname) return outputlen; } -void ElfLinker::addSection(const char *sname, const void *sdata, int slen) +void ElfLinker::addSection(const char *sname, const void *sdata, int slen, int align) { assert(!frozen); sections = static_cast
(realloc(sections, (nsections + 1) * sizeof(Section *))); assert(sections); - sections[nsections++] = new Section(sname, sdata, slen); + sections[nsections++] = new Section(sname, sdata, slen, align); } void ElfLinker::freeze() @@ -823,12 +834,25 @@ void ElfLinkerPpc32::relocate1(Relocation *rel, upx_byte *location, // FIXME: more relocs - if (strcmp(type, "8") == 0) - *location += value; - else if (strcmp(type, "16") == 0) - set_le16(location, get_le16(location) + value); - else if (strcmp(type, "32") == 0) - set_le32(location, get_le32(location) + value); + // Note that original (*location).displ is ignored. + if (strcmp(type, "24") == 0) { + if (3& value) { + printf("unaligned word diplacement"); + abort(); + } + // FIXME: displacment overflow? + set_be32(location, (0xfc000003 & get_be32(location)) + + (0x03fffffc & (rel->add + value))); + } + else if (strcmp(type, "14") == 0) { + if (3& value) { + printf("unaligned word diplacement"); + abort(); + } + // FIXME: displacment overflow? + set_be32(location, (0xffff0003 & get_be32(location)) + + (0x0000fffc & (rel->add + value))); + } else super::relocate1(rel, location, value, type); } diff --git a/src/linker.h b/src/linker.h index 372f6415..27ddb71c 100644 --- a/src/linker.h +++ b/src/linker.h @@ -49,7 +49,7 @@ public: virtual void init(const void *pdata, int plen, int pinfo) = 0; virtual void setLoaderAlignOffset(int phase) = 0; virtual int addSection(const char *sname) = 0; - virtual void addSection(const char *sname, const void *sdata, int slen) = 0; + virtual void addSection(const char *sname, const void *sdata, int slen, int align) = 0; virtual void freeze() = 0; virtual int getSection(const char *sname, int *slen=NULL) = 0; virtual unsigned char *getLoader(int *llen=NULL) = 0; @@ -83,7 +83,7 @@ public: virtual void init(const void *pdata, int plen, int pinfo); virtual void setLoaderAlignOffset(int phase); virtual int addSection(const char *sname); - virtual void addSection(const char *sname, const void *sdata, int slen); + virtual void addSection(const char *sname, const void *sdata, int slen, int align); virtual void freeze(); virtual int getSection(const char *sname, int *slen=NULL); virtual unsigned char *getLoader(int *llen=NULL); @@ -130,7 +130,7 @@ public: virtual void init(const void *pdata, int plen, int pinfo); virtual void setLoaderAlignOffset(int phase); virtual int addSection(const char *sname); - virtual void addSection(const char *sname, const void *sdata, int slen); + virtual void addSection(const char *sname, const void *sdata, int slen, int align); virtual void freeze(); virtual int getSection(const char *sname, int *slen=NULL); virtual unsigned char *getLoader(int *llen=NULL); @@ -199,7 +199,7 @@ protected: virtual void init(const void *pdata, int plen, int); virtual void setLoaderAlignOffset(int phase); virtual int addSection(const char *sname); - virtual void addSection(const char *sname, const void *sdata, int slen); + virtual void addSection(const char *sname, const void *sdata, int slen, int align); virtual void freeze(); virtual int getSection(const char *sname, int *slen=NULL); virtual upx_byte *getLoader(int *llen=NULL); @@ -225,9 +225,10 @@ struct ElfLinker::Section : private nocopy upx_byte *output; unsigned size; unsigned offset; + unsigned char align; // log2 Section *next; - Section(const char *n, const void *i, unsigned s); + Section(const char *n, const void *i, unsigned s, unsigned a=0); ~Section(); }; diff --git a/src/p_lx_elf.cpp b/src/p_lx_elf.cpp index 322a937f..0f3bb7b6 100644 --- a/src/p_lx_elf.cpp +++ b/src/p_lx_elf.cpp @@ -390,6 +390,7 @@ void PackLinuxElf32x86::addStubEntrySections(Filter const *ft) sizeof(p_info) + // compressed data b_len + ph.c_len ); + // entry to stub addLoader("LEXEC000", NULL); @@ -510,7 +511,7 @@ PackLinuxElf32::buildLinuxLoader( memcpy(cprLoader, &h, sizeof(h)); // This adds the definition to the "library", to be used later. - linker->addSection("FOLDEXEC", cprLoader, sizeof(h) + sz_cpr); + linker->addSection("FOLDEXEC", cprLoader, sizeof(h) + sz_cpr, 0); delete [] cprLoader; addStubEntrySections(ft); @@ -560,7 +561,7 @@ PackLinuxElf64::buildLinuxLoader( memcpy(cprLoader, &h, sizeof(h)); // This adds the definition to the "library", to be used later. - linker->addSection("FOLDEXEC", cprLoader, sizeof(h) + sz_cpr); + linker->addSection("FOLDEXEC", cprLoader, sizeof(h) + sz_cpr, 0); delete [] cprLoader; addStubEntrySections(ft); @@ -814,6 +815,14 @@ void PackLinuxElf32ppc::addStubEntrySections(Filter const *) { addLoader("ELFMAINX", NULL); + //addLoader(getDecompressorSections(), NULL); + addLoader( + ( M_IS_NRV2E(ph.method) ? "NRV_COMMON,NRV2E" + : M_IS_NRV2D(ph.method) ? "NRV_COMMON,NRV2D" + : M_IS_NRV2B(ph.method) ? "NRV_COMMON,NRV2B" + : M_IS_LZMA(ph.method) ? "LZMA_ELF00,LZMA_DEC20,LZMA_DEC30" + : NULL), NULL); + addLoader("ELFMAINY,IDENTSTR,ELFMAINZ,FOLDEXEC", NULL); } void diff --git a/src/p_lx_exc.cpp b/src/p_lx_exc.cpp index c6e573e9..637ba1fa 100644 --- a/src/p_lx_exc.cpp +++ b/src/p_lx_exc.cpp @@ -280,7 +280,7 @@ PackLinuxI386::buildLinuxLoader( } // This adds the definition to the "library", to be used later. // NOTE: the stub is NOT compressed! The savings is not worth it. - linker->addSection("FOLDEXEC", fold + fold_hdrlen, szfold - fold_hdrlen); + linker->addSection("FOLDEXEC", fold + fold_hdrlen, szfold - fold_hdrlen, 0); n_mru = ft->n_mru; diff --git a/src/p_lx_interp.cpp b/src/p_lx_interp.cpp index 3f9fc899..d265eadb 100644 --- a/src/p_lx_interp.cpp +++ b/src/p_lx_interp.cpp @@ -148,7 +148,7 @@ void PackLinuxElf32x86interp::pack3(OutputFile *fo, Filter &/*ft*/) elfout.phdr[0].p_paddr = elfout.phdr[0].p_vaddr = base - sz; if (opt->o_unix.make_ptinterp) { initLoader(linux_i386pti_loader, sizeof(linux_i386pti_loader)); - linker->addSection("FOLDEXEC", linux_i386pti_fold, sizeof(linux_i386pti_fold)); + linker->addSection("FOLDEXEC", linux_i386pti_fold, sizeof(linux_i386pti_fold), 0); addLoader("LXPTI000", NULL); diff --git a/src/p_mach.cpp b/src/p_mach.cpp index ae95c5b2..22446431 100644 --- a/src/p_mach.cpp +++ b/src/p_mach.cpp @@ -98,13 +98,13 @@ PackMachPPC32::buildMachLoader( memcpy(cprLoader, &h, sizeof(h)); // This adds the definition to the "library", to be used later. - linker->addSection("FOLDEXEC", cprLoader, sizeof(h) + h.sz_cpr); + linker->addSection("FOLDEXEC", cprLoader, sizeof(h) + h.sz_cpr, 0); delete [] cprLoader; int const GAP = 128; // must match stub/l_mac_ppc.S segcmdo.vmsize += h.sz_unc - h.sz_cpr + GAP + 64; - linker->addSection("MACOS000", proto, szproto); + linker->addSection("MACOS000", proto, szproto, 0); addLoader("MACOS000", NULL); addLoader("FOLDEXEC", NULL); diff --git a/src/packer.cpp b/src/packer.cpp index 794ef0a3..7f186698 100644 --- a/src/packer.cpp +++ b/src/packer.cpp @@ -1069,7 +1069,7 @@ void Packer::initLoader(const void *pdata, int plen, int pinfo, int small) unsigned size; char const * const ident = getIdentstr(&size, small); - linker->addSection("IDENTSTR", ident, size); + linker->addSection("IDENTSTR", ident, size, 0); } diff --git a/src/stub/Makefile b/src/stub/Makefile index f07963b6..b2ab166a 100644 --- a/src/stub/Makefile +++ b/src/stub/Makefile @@ -686,9 +686,11 @@ tc.powerpc-linux.elf.objdump = $(call tc,m-objdump) tc.powerpc-linux.elf.objstrip = $(call tc,objcopy) -R .comment -R .note powerpc-linux.elf-entry.h : $(srcdir)/src/$$T.S - $(call tc,gcc) -c $< -o tmp/$T.o - $(call tc,objstrip) tmp/$T.o - $(call tc,ld) --oformat binary tmp/$T.o -o tmp/$T.bin + $(call tc,gcc) -c $< -o tmp/$T.bin + $(call tc,m-objcopy) --strip-unneeded tmp/$T.bin + $(call tc,m-objcopy) -R .text -R .data -R .bss tmp/$T.bin + $(call tc,m-objcopy) -R .note -R .comment tmp/$T.bin + $(call tc,m-objdump) -trwh tmp/$T.bin >> tmp/$T.bin $(call tc,bin2h) --ident=linux_elfppc32_loader tmp/$T.bin $@ powerpc-linux.elf-fold.h : tmp/$$T.o tmp/powerpc-linux.elf-main.o $(srcdir)/src/$$T.lds diff --git a/src/stub/powerpc-linux.elf-entry.h b/src/stub/powerpc-linux.elf-entry.h index 27ed6640..cb19eb05 100644 --- a/src/stub/powerpc-linux.elf-entry.h +++ b/src/stub/powerpc-linux.elf-entry.h @@ -1,4 +1,4 @@ -/* powerpc-linux.elf-entry.h -- created from powerpc-linux.elf-entry.bin, 604 (0x25c) bytes +/* powerpc-linux.elf-entry.h -- created from powerpc-linux.elf-entry.bin, 3251 (0xcb3) bytes This file is part of the UPX executable compressor. @@ -27,47 +27,213 @@ */ -#define LINUX_ELFPPC32_LOADER_SIZE 604 -#define LINUX_ELFPPC32_LOADER_ADLER32 0x0a8bbdb5 -#define LINUX_ELFPPC32_LOADER_CRC32 0xcfe347e7 +#define LINUX_ELFPPC32_LOADER_SIZE 3251 +#define LINUX_ELFPPC32_LOADER_ADLER32 0xbb8d8b77 +#define LINUX_ELFPPC32_LOADER_CRC32 0xf2bf619c -unsigned char linux_elfppc32_loader[604] = { - 72, 0, 2, 77,124, 0, 41,236,144,166, 0, 0,124,132, 26, 20, /* 0x 0 */ - 60, 0,128, 0, 61, 32,128, 0, 56, 99,255,255, 56,165,255,255, /* 0x 10 */ - 57, 64,255,255,125,168, 2,166, 72, 0, 1, 12, 57, 32, 0, 1, /* 0x 20 */ -125, 41, 28, 44, 56, 99, 0, 4,124, 9, 0, 64,125, 41, 72, 20, /* 0x 30 */ - 97, 41, 0, 1, 78,128, 0, 32,141, 3, 0, 1,157, 5, 0, 1, /* 0x 40 */ -124, 9, 0, 64,125, 41, 74, 20, 65,162,255,213, 65,129,255,236, /* 0x 50 */ - 56,224, 0, 1, 72, 0, 0, 20, 56,231,255,255,125, 41, 72, 21, /* 0x 60 */ - 65,162,255,189,124,231, 57, 20,125, 41, 72, 21, 65,162,255,177, /* 0x 70 */ -124,231, 57, 20,124, 9, 0, 64,125, 41, 74, 20, 65,162,255,161, /* 0x 80 */ - 65,160,255,216, 57, 0, 0, 0, 52,231,255,253, 84,231, 64, 46, /* 0x 90 */ - 65,128, 0, 32,140, 67, 0, 1,124,234, 16,249,125, 74, 14,112, /* 0x a0 */ - 65,130, 0,148,112, 66, 0, 1, 65,162, 0, 80, 72, 0, 0, 20, /* 0x b0 */ -124, 9, 0, 64,125, 41, 74, 20, 65,162,255,101, 65,161, 0, 60, /* 0x c0 */ - 57, 0, 0, 1,124, 9, 0, 64,125, 41, 74, 20, 65,162,255, 81, /* 0x d0 */ - 65,161, 0, 40,125, 41, 72, 21, 65,162,255, 69,125, 8, 65, 20, /* 0x e0 */ -124, 9, 0, 64,125, 41, 74, 20, 65,162,255, 53, 65,160,255,232, /* 0x f0 */ - 57, 8, 0, 2, 72, 0, 0, 16,125, 41, 72, 21, 65,162,255, 33, /* 0x 100 */ -125, 8, 65, 20, 32,234,250,255, 57, 8, 0, 2,125, 8, 1,148, /* 0x 110 */ -124,234, 42, 20,125, 9, 3,166,141, 7, 0, 1,157, 5, 0, 1, /* 0x 120 */ - 66, 0,255,248, 56,224, 1, 0,124, 7, 41,236,124, 7, 26, 44, /* 0x 130 */ - 75,255,255, 16,128, 6, 0, 0,125,168, 3,166, 56,165, 0, 1, /* 0x 140 */ - 56, 99, 0, 1,124,160, 40, 80,124,100, 24, 80,144,166, 0, 0, /* 0x 150 */ - 78,128, 0, 32, 10, 36, 73,100, 58, 32, 85, 80, 88, 32, 40, 67, /* 0x 160 */ - 41, 32, 49, 57, 57, 54, 45, 50, 48, 48, 54, 32,116,104,101, 32, /* 0x 170 */ - 85, 80, 88, 32, 84,101, 97,109, 46, 32, 65,108,108, 32, 82,105, /* 0x 180 */ -103,104,116,115, 32, 82,101,115,101,114,118,101,100, 46, 32,104, /* 0x 190 */ -116,116,112, 58, 47, 47,117,112,120, 46,115,102, 46,110,101,116, /* 0x 1a0 */ - 32, 36, 10, 0, 72, 0, 0, 37, 80, 82, 79, 84, 95, 69, 88, 69, /* 0x 1b0 */ - 67,124, 80, 82, 79, 84, 95, 87, 82, 73, 84, 69, 32,102, 97,105, /* 0x 1c0 */ -108,101,100, 46, 10, 0, 0, 0, 56,160, 0, 32,124,136, 2,166, /* 0x 1d0 */ - 56, 96, 0, 2, 56, 0, 0, 4, 68, 0, 0, 2, 56, 96, 0,127, /* 0x 1e0 */ - 56, 0, 0, 1, 68, 0, 0, 2,127,200, 2,166, 57, 0, 0, 0, /* 0x 1f0 */ - 56,224,255,255,128,126, 0, 4, 56,192, 0, 50, 56,160, 0, 7, /* 0x 200 */ - 56,128, 16, 0,124, 99,242, 20, 56, 0, 0, 90, 56, 99, 16, 11, /* 0x 210 */ - 84, 99, 0, 38, 68, 0, 0, 2, 65,163,255,140,127,233, 3,166, /* 0x 220 */ -136,254, 0, 8, 56,193, 0,124,124,101, 27,120,124,104, 3,166, /* 0x 230 */ -128,158, 0, 4, 56,126, 0, 12, 78,128, 4, 32,148, 33,255,128, /* 0x 240 */ -188, 65, 0, 4,127,232, 2,166, 75,255,255,161 /* 0x 250 */ +unsigned char linux_elfppc32_loader[3251] = { +127, 69, 76, 70, 1, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x 0 */ + 0, 1, 0, 20, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x 10 */ + 0, 0, 3,144, 0, 0, 0, 0, 0, 52, 0, 0, 0, 0, 0, 40, /* 0x 20 */ + 0, 15, 0, 12, 72, 0, 0,117,124, 0, 41,236,144,166, 0, 0, /* 0x 30 */ +124,132, 26, 20, 60, 0,128, 0, 61, 32,128, 0, 56, 99,255,255, /* 0x 40 */ + 56,165,255,255, 57, 64,255,255,125,168, 2,166, 72, 0, 1, 12, /* 0x 50 */ + 57, 32, 0, 1,125, 41, 28, 44, 56, 99, 0, 4,124, 9, 0, 64, /* 0x 60 */ +125, 41, 72, 20, 97, 41, 0, 1, 78,128, 0, 32,141, 3, 0, 1, /* 0x 70 */ +157, 5, 0, 1,124, 9, 0, 64,125, 41, 74, 20, 65,162,255,213, /* 0x 80 */ + 65,129,255,236, 56,224, 0, 1, 72, 0, 0, 20, 56,231,255,255, /* 0x 90 */ +125, 41, 72, 21, 65,162,255,189,124,231, 57, 20,125, 41, 72, 21, /* 0x a0 */ + 65,162,255,177,124,231, 57, 20,124, 9, 0, 64,125, 41, 74, 20, /* 0x b0 */ + 65,162,255,161, 65,160,255,216, 57, 0, 0, 0, 52,231,255,253, /* 0x c0 */ + 84,231, 64, 46, 65,128, 0, 32,140, 67, 0, 1,124,234, 16,249, /* 0x d0 */ +125, 74, 14,112, 65,130, 0, 0,112, 66, 0, 1, 65,162, 0, 80, /* 0x e0 */ + 72, 0, 0, 20,124, 9, 0, 64,125, 41, 74, 20, 65,162,255,101, /* 0x f0 */ + 65,161, 0, 60, 57, 0, 0, 1,124, 9, 0, 64,125, 41, 74, 20, /* 0x 100 */ + 65,162,255, 81, 65,161, 0, 40,125, 41, 72, 21, 65,162,255, 69, /* 0x 110 */ +125, 8, 65, 20,124, 9, 0, 64,125, 41, 74, 20, 65,162,255, 53, /* 0x 120 */ + 65,160,255,232, 57, 8, 0, 2, 72, 0, 0, 16,125, 41, 72, 21, /* 0x 130 */ + 65,162,255, 33,125, 8, 65, 20, 32,234,250,255, 57, 8, 0, 2, /* 0x 140 */ +125, 8, 1,148,124,234, 42, 20,125, 9, 3,166,141, 7, 0, 1, /* 0x 150 */ +157, 5, 0, 1, 66, 0,255,248, 56,224, 1, 0,124, 7, 41,236, /* 0x 160 */ +124, 7, 26, 44, 75,255,255, 16,124, 0, 41,236,144,166, 0, 0, /* 0x 170 */ +124,132, 26, 20, 60, 0,128, 0, 61, 32,128, 0, 56, 99,255,255, /* 0x 180 */ + 56,165,255,255, 57, 64,255,255,125,168, 2,166, 72, 0, 0,180, /* 0x 190 */ +124, 9, 0, 64,125, 41, 72, 20, 76,162, 0, 32, 57, 32, 0, 1, /* 0x 1a0 */ +125, 41, 28, 44, 56, 99, 0, 4,124, 9, 0, 64,125, 41, 73, 20, /* 0x 1b0 */ + 78,128, 0, 32,141, 3, 0, 1,157, 5, 0, 1, 75,255,255,213, /* 0x 1c0 */ + 65,129,255,244, 56,224, 0, 1, 75,255,255,201,124,231, 57, 21, /* 0x 1d0 */ + 75,255,255,193, 65,160,255,244, 52,231,255,253, 57, 0, 0, 0, /* 0x 1e0 */ + 65,128, 0, 20,140, 67, 0, 1, 84,231, 64, 46,124,234, 16,249, /* 0x 1f0 */ + 65,130, 0, 0, 75,255,255,157,125, 8, 65, 21, 75,255,255,149, /* 0x 200 */ +125, 8, 65, 21, 56,224, 0, 1, 64,130, 0, 28, 56,224, 0, 3, /* 0x 210 */ + 57, 0, 0, 1, 75,255,255,125,125, 8, 65, 21, 75,255,255,117, /* 0x 220 */ + 65,160,255,244, 32, 74,242,255,125, 8, 57, 20,124,234, 42, 20, /* 0x 230 */ +125, 9, 3,166,141, 7, 0, 1,157, 5, 0, 1, 66, 0,255,248, /* 0x 240 */ + 56,224, 1, 0,124, 7, 41,236,124, 7, 26, 44, 75,255,255,112, /* 0x 250 */ +128, 6, 0, 0,125,168, 3,166, 56,165, 0, 1, 56, 99, 0, 1, /* 0x 260 */ +124,160, 40, 80,124,100, 24, 80,144,166, 0, 0, 78,128, 0, 32, /* 0x 270 */ + 72, 0, 0, 1, 80, 82, 79, 84, 95, 69, 88, 69, 67,124, 80, 82, /* 0x 280 */ + 79, 84, 95, 87, 82, 73, 84, 69, 32,102, 97,105,108,101,100, 46, /* 0x 290 */ + 10, 0, 0, 0, 56,160, 0, 30,124,136, 2,166, 56, 96, 0, 2, /* 0x 2a0 */ + 56, 0, 0, 4, 68, 0, 0, 2, 56, 96, 0,127, 56, 0, 0, 1, /* 0x 2b0 */ + 68, 0, 0, 2,127,200, 2,166, 57, 0, 0, 0, 56,224,255,255, /* 0x 2c0 */ +128,126, 0, 4, 56,192, 0, 50, 56,160, 0, 7, 56,128, 16, 0, /* 0x 2d0 */ +124, 99,242, 20, 56, 0, 0, 90, 56, 99, 16, 11, 84, 99, 0, 38, /* 0x 2e0 */ + 68, 0, 0, 2, 65,131, 0, 32,127,233, 3,166,136,254, 0, 8, /* 0x 2f0 */ + 56,193, 0,124,124,101, 27,120,124,104, 3,166,128,158, 0, 4, /* 0x 300 */ + 56,126, 0, 12, 78,128, 4, 32,148, 33,255,128,188, 65, 0, 4, /* 0x 310 */ +127,232, 2,166, 75,255,255,161, 0, 46,115,121,109,116, 97, 98, /* 0x 320 */ + 0, 46,115,116,114,116, 97, 98, 0, 46,115,104,115,116,114,116, /* 0x 330 */ + 97, 98, 0, 46,114,101,108, 97, 69, 76, 70, 77, 65, 73, 78, 88, /* 0x 340 */ + 0, 78, 82, 86, 95, 67, 79, 77, 77, 79, 78, 0, 46,114,101,108, /* 0x 350 */ + 97, 78, 82, 86, 50, 69, 0, 46,114,101,108, 97, 78, 82, 86, 50, /* 0x 360 */ + 66, 0, 46,114,101,108, 97, 69, 76, 70, 77, 65, 73, 78, 89, 0, /* 0x 370 */ + 46,114,101,108, 97, 69, 76, 70, 77, 65, 73, 78, 90, 0, 0, 0, /* 0x 380 */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x 390 */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x 3a0 */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 1, /* 0x 3b0 */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 52, 0, 0, 0, 4, /* 0x 3c0 */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, /* 0x 3d0 */ + 0, 0, 0, 27, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x 3e0 */ + 0, 0, 6,112, 0, 0, 0, 12, 0, 0, 0, 13, 0, 0, 0, 1, /* 0x 3f0 */ + 0, 0, 0, 4, 0, 0, 0, 12, 0, 0, 0, 41, 0, 0, 0, 1, /* 0x 400 */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 56, 0, 0, 0, 0, /* 0x 410 */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, /* 0x 420 */ + 0, 0, 0, 57, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x 430 */ + 0, 0, 0, 56, 0, 0, 1, 64, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x 440 */ + 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 52, 0, 0, 0, 4, /* 0x 450 */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6,124, 0, 0, 0, 12, /* 0x 460 */ + 0, 0, 0, 13, 0, 0, 0, 4, 0, 0, 0, 4, 0, 0, 0, 12, /* 0x 470 */ + 0, 0, 0, 68, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x 480 */ + 0, 0, 1,120, 0, 0, 0,232, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x 490 */ + 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 63, 0, 0, 0, 4, /* 0x 4a0 */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6,136, 0, 0, 0, 12, /* 0x 4b0 */ + 0, 0, 0, 13, 0, 0, 0, 6, 0, 0, 0, 4, 0, 0, 0, 12, /* 0x 4c0 */ + 0, 0, 0, 79, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x 4d0 */ + 0, 0, 2, 96, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x 4e0 */ + 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 74, 0, 0, 0, 4, /* 0x 4f0 */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6,148, 0, 0, 0, 12, /* 0x 500 */ + 0, 0, 0, 13, 0, 0, 0, 8, 0, 0, 0, 4, 0, 0, 0, 12, /* 0x 510 */ + 0, 0, 0, 93, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x 520 */ + 0, 0, 2,164, 0, 0, 0,132, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x 530 */ + 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 88, 0, 0, 0, 4, /* 0x 540 */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6,160, 0, 0, 0, 12, /* 0x 550 */ + 0, 0, 0, 13, 0, 0, 0, 10, 0, 0, 0, 4, 0, 0, 0, 12, /* 0x 560 */ + 0, 0, 0, 17, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x 570 */ + 0, 0, 3, 40, 0, 0, 0,102, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x 580 */ + 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 2, /* 0x 590 */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5,232, 0, 0, 0,128, /* 0x 5a0 */ + 0, 0, 0, 14, 0, 0, 0, 7, 0, 0, 0, 4, 0, 0, 0, 16, /* 0x 5b0 */ + 0, 0, 0, 9, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x 5c0 */ + 0, 0, 6,104, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x 5d0 */ + 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x 5e0 */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x 5f0 */ + 0, 0, 0, 0, 3, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x 600 */ + 0, 0, 0, 0, 3, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x 610 */ + 0, 0, 0, 0, 3, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x 620 */ + 0, 0, 0, 0, 3, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x 630 */ + 0, 0, 0, 0, 3, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x 640 */ + 0, 0, 0, 0, 3, 0, 0, 6, 0, 0, 0, 1, 0, 0, 0, 0, /* 0x 650 */ + 0, 0, 0, 0, 16, 0, 0, 1, 0, 95,115,116, 97,114,116, 0, /* 0x 660 */ + 0, 0, 0, 0, 0, 0, 2, 10, 0, 0, 0,116, 0, 0, 0,172, /* 0x 670 */ + 0, 0, 1, 11, 0, 0, 0, 0, 0, 0, 0,136, 0, 0, 1, 11, /* 0x 680 */ + 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 2, 10, 0, 0, 0, 0, /* 0x 690 */ + 0, 0, 0, 80, 0, 0, 1, 11, 0, 0, 0, 32, 10,116,109,112, /* 0x 6a0 */ + 47,112,111,119,101,114,112, 99, 45,108,105,110,117,120, 46,101, /* 0x 6b0 */ +108,102, 45,101,110,116,114,121, 46, 98,105,110, 58, 32, 32, 32, /* 0x 6c0 */ + 32, 32,102,105,108,101, 32,102,111,114,109, 97,116, 32,101,108, /* 0x 6d0 */ +102, 51, 50, 45,112,111,119,101,114,112, 99, 10, 10, 83,101, 99, /* 0x 6e0 */ +116,105,111,110,115, 58, 10, 73,100,120, 32, 78, 97,109,101, 32, /* 0x 6f0 */ + 32, 32, 32, 32, 32, 32, 32, 32, 32, 83,105,122,101, 32, 32, 32, /* 0x 700 */ + 32, 32, 32, 86, 77, 65, 32, 32, 32, 32, 32, 32, 32, 76, 77, 65, /* 0x 710 */ + 32, 32, 32, 32, 32, 32, 32, 70,105,108,101, 32,111,102,102, 32, /* 0x 720 */ + 32, 65,108,103,110, 32, 32, 70,108, 97,103,115, 10, 32, 32, 48, /* 0x 730 */ + 32, 69, 76, 70, 77, 65, 73, 78, 88, 32, 32, 32, 32, 32, 32, 48, /* 0x 740 */ + 48, 48, 48, 48, 48, 48, 52, 32, 32, 48, 48, 48, 48, 48, 48, 48, /* 0x 750 */ + 48, 32, 32, 48, 48, 48, 48, 48, 48, 48, 48, 32, 32, 48, 48, 48, /* 0x 760 */ + 48, 48, 48, 51, 52, 32, 32, 50, 42, 42, 50, 32, 32, 67, 79, 78, /* 0x 770 */ + 84, 69, 78, 84, 83, 44, 32, 82, 69, 76, 79, 67, 44, 32, 82, 69, /* 0x 780 */ + 65, 68, 79, 78, 76, 89, 10, 32, 32, 49, 32, 78, 82, 86, 95, 67, /* 0x 790 */ + 79, 77, 77, 79, 78, 32, 32, 32, 32, 48, 48, 48, 48, 48, 48, 48, /* 0x 7a0 */ + 48, 32, 32, 48, 48, 48, 48, 48, 48, 48, 48, 32, 32, 48, 48, 48, /* 0x 7b0 */ + 48, 48, 48, 48, 48, 32, 32, 48, 48, 48, 48, 48, 48, 51, 56, 32, /* 0x 7c0 */ + 32, 50, 42, 42, 50, 32, 32, 67, 79, 78, 84, 69, 78, 84, 83, 44, /* 0x 7d0 */ + 32, 82, 69, 65, 68, 79, 78, 76, 89, 10, 32, 32, 50, 32, 78, 82, /* 0x 7e0 */ + 86, 50, 69, 32, 32, 32, 32, 32, 32, 32, 32, 32, 48, 48, 48, 48, /* 0x 7f0 */ + 48, 49, 52, 48, 32, 32, 48, 48, 48, 48, 48, 48, 48, 48, 32, 32, /* 0x 800 */ + 48, 48, 48, 48, 48, 48, 48, 48, 32, 32, 48, 48, 48, 48, 48, 48, /* 0x 810 */ + 51, 56, 32, 32, 50, 42, 42, 50, 32, 32, 67, 79, 78, 84, 69, 78, /* 0x 820 */ + 84, 83, 44, 32, 82, 69, 76, 79, 67, 44, 32, 82, 69, 65, 68, 79, /* 0x 830 */ + 78, 76, 89, 10, 32, 32, 51, 32, 78, 82, 86, 50, 66, 32, 32, 32, /* 0x 840 */ + 32, 32, 32, 32, 32, 32, 48, 48, 48, 48, 48, 48,101, 56, 32, 32, /* 0x 850 */ + 48, 48, 48, 48, 48, 48, 48, 48, 32, 32, 48, 48, 48, 48, 48, 48, /* 0x 860 */ + 48, 48, 32, 32, 48, 48, 48, 48, 48, 49, 55, 56, 32, 32, 50, 42, /* 0x 870 */ + 42, 50, 32, 32, 67, 79, 78, 84, 69, 78, 84, 83, 44, 32, 82, 69, /* 0x 880 */ + 76, 79, 67, 44, 32, 82, 69, 65, 68, 79, 78, 76, 89, 10, 32, 32, /* 0x 890 */ + 52, 32, 69, 76, 70, 77, 65, 73, 78, 89, 32, 32, 32, 32, 32, 32, /* 0x 8a0 */ + 48, 48, 48, 48, 48, 48, 52, 52, 32, 32, 48, 48, 48, 48, 48, 48, /* 0x 8b0 */ + 48, 48, 32, 32, 48, 48, 48, 48, 48, 48, 48, 48, 32, 32, 48, 48, /* 0x 8c0 */ + 48, 48, 48, 50, 54, 48, 32, 32, 50, 42, 42, 50, 32, 32, 67, 79, /* 0x 8d0 */ + 78, 84, 69, 78, 84, 83, 44, 32, 82, 69, 76, 79, 67, 44, 32, 82, /* 0x 8e0 */ + 69, 65, 68, 79, 78, 76, 89, 10, 32, 32, 53, 32, 69, 76, 70, 77, /* 0x 8f0 */ + 65, 73, 78, 90, 32, 32, 32, 32, 32, 32, 48, 48, 48, 48, 48, 48, /* 0x 900 */ + 56, 52, 32, 32, 48, 48, 48, 48, 48, 48, 48, 48, 32, 32, 48, 48, /* 0x 910 */ + 48, 48, 48, 48, 48, 48, 32, 32, 48, 48, 48, 48, 48, 50, 97, 52, /* 0x 920 */ + 32, 32, 50, 42, 42, 50, 32, 32, 67, 79, 78, 84, 69, 78, 84, 83, /* 0x 930 */ + 44, 32, 82, 69, 76, 79, 67, 44, 32, 82, 69, 65, 68, 79, 78, 76, /* 0x 940 */ + 89, 10, 83, 89, 77, 66, 79, 76, 32, 84, 65, 66, 76, 69, 58, 10, /* 0x 950 */ + 48, 48, 48, 48, 48, 48, 48, 48, 32,108, 32, 32, 32, 32,100, 32, /* 0x 960 */ + 32, 69, 76, 70, 77, 65, 73, 78, 89, 9, 48, 48, 48, 48, 48, 48, /* 0x 970 */ + 48, 48, 32, 69, 76, 70, 77, 65, 73, 78, 89, 10, 48, 48, 48, 48, /* 0x 980 */ + 48, 48, 48, 48, 32,108, 32, 32, 32, 32,100, 32, 32, 69, 76, 70, /* 0x 990 */ + 77, 65, 73, 78, 90, 9, 48, 48, 48, 48, 48, 48, 48, 48, 32, 69, /* 0x 9a0 */ + 76, 70, 77, 65, 73, 78, 90, 10, 48, 48, 48, 48, 48, 48, 48, 48, /* 0x 9b0 */ + 32,108, 32, 32, 32, 32,100, 32, 32, 69, 76, 70, 77, 65, 73, 78, /* 0x 9c0 */ + 88, 9, 48, 48, 48, 48, 48, 48, 48, 48, 32, 69, 76, 70, 77, 65, /* 0x 9d0 */ + 73, 78, 88, 10, 48, 48, 48, 48, 48, 48, 48, 48, 32,108, 32, 32, /* 0x 9e0 */ + 32, 32,100, 32, 32, 78, 82, 86, 95, 67, 79, 77, 77, 79, 78, 9, /* 0x 9f0 */ + 48, 48, 48, 48, 48, 48, 48, 48, 32, 78, 82, 86, 95, 67, 79, 77, /* 0x a00 */ + 77, 79, 78, 10, 48, 48, 48, 48, 48, 48, 48, 48, 32,108, 32, 32, /* 0x a10 */ + 32, 32,100, 32, 32, 78, 82, 86, 50, 69, 9, 48, 48, 48, 48, 48, /* 0x a20 */ + 48, 48, 48, 32, 78, 82, 86, 50, 69, 10, 48, 48, 48, 48, 48, 48, /* 0x a30 */ + 48, 48, 32,108, 32, 32, 32, 32,100, 32, 32, 78, 82, 86, 50, 66, /* 0x a40 */ + 9, 48, 48, 48, 48, 48, 48, 48, 48, 32, 78, 82, 86, 50, 66, 10, /* 0x a50 */ + 48, 48, 48, 48, 48, 48, 48, 48, 32,103, 32, 32, 32, 32, 32, 32, /* 0x a60 */ + 32, 69, 76, 70, 77, 65, 73, 78, 88, 9, 48, 48, 48, 48, 48, 48, /* 0x a70 */ + 48, 48, 32, 95,115,116, 97,114,116, 10, 10, 10, 82, 69, 76, 79, /* 0x a80 */ + 67, 65, 84, 73, 79, 78, 32, 82, 69, 67, 79, 82, 68, 83, 32, 70, /* 0x a90 */ + 79, 82, 32, 91, 69, 76, 70, 77, 65, 73, 78, 88, 93, 58, 10, 79, /* 0x aa0 */ + 70, 70, 83, 69, 84, 32, 32, 32, 84, 89, 80, 69, 32, 32, 32, 32, /* 0x ab0 */ + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 86, 65, 76, 85, 69, 32, /* 0x ac0 */ + 10, 48, 48, 48, 48, 48, 48, 48, 48, 32, 82, 95, 80, 80, 67, 95, /* 0x ad0 */ + 82, 69, 76, 50, 52, 32, 32, 32, 32, 32, 32, 32, 69, 76, 70, 77, /* 0x ae0 */ + 65, 73, 78, 90, 43, 48,120, 48, 48, 48, 48, 48, 48, 55, 52, 10, /* 0x af0 */ + 10, 10, 82, 69, 76, 79, 67, 65, 84, 73, 79, 78, 32, 82, 69, 67, /* 0x b00 */ + 79, 82, 68, 83, 32, 70, 79, 82, 32, 91, 78, 82, 86, 50, 69, 93, /* 0x b10 */ + 58, 10, 79, 70, 70, 83, 69, 84, 32, 32, 32, 84, 89, 80, 69, 32, /* 0x b20 */ + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 86, 65, 76, /* 0x b30 */ + 85, 69, 32, 10, 48, 48, 48, 48, 48, 48, 97, 99, 32, 82, 95, 80, /* 0x b40 */ + 80, 67, 95, 82, 69, 76, 49, 52, 32, 32, 32, 32, 32, 32, 32, 69, /* 0x b50 */ + 76, 70, 77, 65, 73, 78, 89, 10, 10, 10, 82, 69, 76, 79, 67, 65, /* 0x b60 */ + 84, 73, 79, 78, 32, 82, 69, 67, 79, 82, 68, 83, 32, 70, 79, 82, /* 0x b70 */ + 32, 91, 78, 82, 86, 50, 66, 93, 58, 10, 79, 70, 70, 83, 69, 84, /* 0x b80 */ + 32, 32, 32, 84, 89, 80, 69, 32, 32, 32, 32, 32, 32, 32, 32, 32, /* 0x b90 */ + 32, 32, 32, 32, 32, 86, 65, 76, 85, 69, 32, 10, 48, 48, 48, 48, /* 0x ba0 */ + 48, 48, 56, 56, 32, 82, 95, 80, 80, 67, 95, 82, 69, 76, 49, 52, /* 0x bb0 */ + 32, 32, 32, 32, 32, 32, 32, 69, 76, 70, 77, 65, 73, 78, 89, 10, /* 0x bc0 */ + 10, 10, 82, 69, 76, 79, 67, 65, 84, 73, 79, 78, 32, 82, 69, 67, /* 0x bd0 */ + 79, 82, 68, 83, 32, 70, 79, 82, 32, 91, 69, 76, 70, 77, 65, 73, /* 0x be0 */ + 78, 89, 93, 58, 10, 79, 70, 70, 83, 69, 84, 32, 32, 32, 84, 89, /* 0x bf0 */ + 80, 69, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, /* 0x c00 */ + 86, 65, 76, 85, 69, 32, 10, 48, 48, 48, 48, 48, 48, 50, 48, 32, /* 0x c10 */ + 82, 95, 80, 80, 67, 95, 82, 69, 76, 50, 52, 32, 32, 32, 32, 32, /* 0x c20 */ + 32, 32, 69, 76, 70, 77, 65, 73, 78, 90, 10, 10, 10, 82, 69, 76, /* 0x c30 */ + 79, 67, 65, 84, 73, 79, 78, 32, 82, 69, 67, 79, 82, 68, 83, 32, /* 0x c40 */ + 70, 79, 82, 32, 91, 69, 76, 70, 77, 65, 73, 78, 90, 93, 58, 10, /* 0x c50 */ + 79, 70, 70, 83, 69, 84, 32, 32, 32, 84, 89, 80, 69, 32, 32, 32, /* 0x c60 */ + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 86, 65, 76, 85, 69, /* 0x c70 */ + 32, 10, 48, 48, 48, 48, 48, 48, 53, 48, 32, 82, 95, 80, 80, 67, /* 0x c80 */ + 95, 82, 69, 76, 49, 52, 32, 32, 32, 32, 32, 32, 32, 69, 76, 70, /* 0x c90 */ + 77, 65, 73, 78, 89, 43, 48,120, 48, 48, 48, 48, 48, 48, 50, 48, /* 0x ca0 */ + 10, 10, 10 /* 0x cb0 */ }; diff --git a/src/stub/src/arch/powerpc/32/nrv2b_d.S b/src/stub/src/arch/powerpc/32/nrv2b_d.S index fdc3b795..4bf17907 100644 --- a/src/stub/src/arch/powerpc/32/nrv2b_d.S +++ b/src/stub/src/arch/powerpc/32/nrv2b_d.S @@ -29,41 +29,29 @@ */ -#include "ppc_regs.h" +#define M_NRV2B_LE32 2 + rlwinm r0,meth,8,25,31 // .b_method (hi byte of meth) + cmpli cr0,r0,M_NRV2B_LE32 + bne cr0,not_nrv2b -SZ_DLINE=128 # size of data cache line in Apple G5 + dcbtst 0,dst // prime dcache for store -/* Returns 0 on success; non-zero on failure. */ -decompress: # (uchar const *src, size_t lsrc, uchar *dst, size_t &ldst, uint method) + stw dst,0(ldst) // original dst + add lsrc,lsrc,src // input eof -/* PowerPC has no 'cmplis': compare logical [unsigned] immediate shifted [by 16] */ -#define hibit r0 /* holds 0x80000000 during decompress */ + lis hibit,0x8000 // 0x80000000 for detecting next bit + lis bits,0x8000 // prepare for first load + addi src,src,-1 // prepare for 'lbzu' + addi dst,dst,-1 // prepare for 'stbu' + li disp,-1 // initial displacement -#define src a0 -#define lsrc a1 -#define dst a2 -#define ldst a3 /* Out: actually a reference: &len_dst */ -#define meth a4 - -#define off a4 -#define len a5 -#define bits a6 -#define disp a7 - - dcbtst 0,dst # prime dcache for store - - stw dst,0(ldst) # original dst - add lsrc,lsrc,src # input eof - - lis hibit,0x8000 # 0x80000000 for detecting next bit - lis bits,0x8000 # prepare for first load - addi src,src,-1 # prepare for 'lbzu' - addi dst,dst,-1 # prepare for 'stbu' - li disp,-1 # initial displacement - - mflr t3 # return address + mflr t3 // return address b bot_n2b +#undef jnextb0y +#undef jnextb0n +#undef jnextb1y +#undef jnextb1n /* jump on next bit, with branch prediction: y==>likely; n==>unlikely cr0 is set by the cmpl ["compare logical"==>unsigned]: lt next bit is 0 @@ -75,66 +63,67 @@ decompress: # (uchar const *src, size_t lsrc, uchar *dst, size_t &ldst, uint me #define jnextb1y call get1; bgt+ cr0, #define jnextb1n call get1; bgt- cr0, +#undef getnextb /* rotate next bit into bottom bit of reg; set cr0 based on entire result reg */ #define getnextb(reg) call get1; adde. reg,reg,reg get1: - cmpl cr0,bits,hibit # cr0 for jnextb - addc bits,bits,bits # CArry for getnextb - bnelr+ cr0 # return if reload not needed; likely 31/32 + cmpl cr0,bits,hibit // cr0 for jnextb + addc bits,bits,bits // CArry for getnextb + bnelr+ cr0 // return if reload not needed; likely 31/32 /* CArry has been set from adding 0x80000000 to itself; preserve for 'adde' */ - # fetch 4 bytes unaligned and LITTLE ENDIAN + // fetch 4 bytes unaligned and LITTLE ENDIAN #if 0 /*{ clean; but 4 instr larger, and 3 cycles longer */ - lbz bits,1(src) # lo8 + lbz bits,1(src) // lo8 lbz t0,2(src); rlwimi bits,t0, 8,16,23 lbz t0,3(src); rlwimi bits,t0,16, 8,15 lbzu t0,4(src); rlwimi bits,t0,24, 0, 7 #else /*}{ pray for no unalignment trap or slowdown */ - li bits,1 # compensate for 'lbzu' - lwbrx bits,bits,src # bits= fetch_le32(bits+src) + li bits,1 // compensate for 'lbzu' + lwbrx bits,bits,src // bits= fetch_le32(bits+src) addi src,src,4 #endif /*}*/ - cmpl cr0,bits,hibit # cr0 for jnextb - adde bits,bits,bits # CArry for getnextb; set lo bit from CarryIn + cmpl cr0,bits,hibit // cr0 for jnextb + adde bits,bits,bits // CArry for getnextb; set lo bit from CarryIn ret lit_n2b: #define tmp len - lbzu tmp,1(src) # tmp= *++src; - stbu tmp,1(dst) # *++dst= tmp; + lbzu tmp,1(src) // tmp= *++src; + stbu tmp,1(dst) // *++dst= tmp; #undef tmp top_n2b: jnextb1y lit_n2b - li off,1 # "the msb" + li off,1 // "the msb" offmore_n2b: getnextb(off) jnextb0n offmore_n2b - addic. off,off,-3 # CArry set [and ignored], but no 'addi.' + addic. off,off,-3 // CArry set [and ignored], but no 'addi.' li len,0 blt- offprev_n2b lbzu t0,1(src) - rlwinm off,off,8,0,31-8 # off<<=8; - nor. disp,off,t0 # disp = -(1+ (off|t0)); - beq- eof_n2b + rlwinm off,off,8,0,31-8 // off<<=8; + nor. disp,off,t0 // disp = -(1+ (off|t0)); + beq- eof_nrv -offprev_n2b: # In: 0==len - getnextb(len); getnextb(len) # two bits; cr0 set on result - li off,1; bne- gotlen_n2b # raw 1,2,3 ==> 2,3,4 - li off,3 # raw 2.. ==> 5.. - li len,1 # "the msb" +offprev_n2b: // In: 0==len + getnextb(len); getnextb(len) // two bits; cr0 set on result + li off,1; bne- gotlen_n2b // raw 1,2,3 ==> 2,3,4 + li off,3 // raw 2.. ==> 5.. + li len,1 // "the msb" lenmore_n2b: getnextb(len) jnextb0n lenmore_n2b gotlen_n2b: - subfic t0,disp,(~0)+(-0xd00) # want CArry only - adde len,len,off # len += off + (disp < -0xd00); + subfic t0,disp,(~0)+(-0xd00) // want CArry only + adde len,len,off // len += off + (disp < -0xd00); copy: #define back off - add back,disp,dst # point back to match in dst + add back,disp,dst // point back to match in dst mtctr len short_n2b: #define tmp len @@ -151,21 +140,10 @@ short_n2b: */ bot_n2b: li back,2*SZ_DLINE - dcbtst back,dst # 2 lines ahead [-1 for stbu] - dcbt back,src # jump start auto prefetch at page boundary + dcbtst back,dst // 2 lines ahead [-1 for stbu] + dcbt back,src // jump start auto prefetch at page boundary /* Auto prefetch for Read quits at page boundary; needs 2 misses to restart. */ #undef back b top_n2b -eof_n2b: -#define tmp r0 /* hibit is dead */ - lwz tmp,0(ldst) # original dst - mtlr t3 # return address - addi dst,dst,1 # uncorrect for 'stbu' - addi src,src,1 # uncorrect for 'lbzu' - subf dst,tmp,dst # dst -= tmp; // dst length -#undef tmp - subf a0,lsrc,src # src -= eof; // return 0: good; else: bad - stw dst,0(ldst) - ret - +not_nrv2b: diff --git a/src/stub/src/arch/powerpc/32/nrv2e_d.S b/src/stub/src/arch/powerpc/32/nrv2e_d.S index 1790f538..fd63010a 100644 --- a/src/stub/src/arch/powerpc/32/nrv2e_d.S +++ b/src/stub/src/arch/powerpc/32/nrv2e_d.S @@ -29,26 +29,10 @@ */ -#include "regs.h" - -SZ_DLINE=128 # size of data cache line in Apple G5 - -/* Returns 0 on success; non-zero on failure. */ -decompress: # (uchar const *src, size_t lsrc, uchar *dst, size_t &ldst, uint method) - -/* PowerPC has no 'cmplis': compare logical [unsigned] immediate shifted [by 16] */ -#define hibit r0 /* holds 0x80000000 during decompress */ - -#define src a0 -#define lsrc a1 -#define dst a2 -#define ldst a3 /* Out: actually a reference: &len_dst */ -#define meth a4 - -#define off a4 -#define len a5 -#define bits a6 -#define disp a7 +#define M_NRV2E_LE32 8 + rlwinm r0,meth,8,25,31 // .b_method (hi byte of meth) + cmpli cr0,r0,M_NRV2E_LE32 + bne cr0,not_nrv2e dcbtst 0,dst # prime dcache for store @@ -64,6 +48,10 @@ decompress: # (uchar const *src, size_t lsrc, uchar *dst, size_t &ldst, uint me mflr t3 # return address b bot_n2e +#undef jnextb0y +#undef jnextb0n +#undef jnextb1y +#undef jnextb1n /* jump on next bit, with branch prediction: y==>likely; n==>unlikely cr0 is set by the cmpl ["compare logical"==>unsigned]: lt next bit is 0 @@ -77,31 +65,32 @@ decompress: # (uchar const *src, size_t lsrc, uchar *dst, size_t &ldst, uint me #define jnextb1y cmpl 0,bits,hibit; add bits,bits,bits; beql- get32; bgt+ #define jnextb1n cmpl 0,bits,hibit; add bits,bits,bits; beql- get32; bgt- +#undef getnextb /* rotate next bit into bottom bit of reg */ #define getnextb(reg) addc. bits,bits,bits; beql- get32; adde reg,reg,reg get32: - # fetch 4 bytes unaligned and LITTLE ENDIAN + // fetch 4 bytes unaligned and LITTLE ENDIAN #if 0 /*{ clean; but 4 instr larger, and 3 cycles longer */ - lbz bits,1(src) # lo8 + lbz bits,1(src) // lo8 lbz t0,2(src); rlwimi bits,t0, 8,16,23 lbz t0,3(src); rlwimi bits,t0,16, 8,15 lbzu t0,4(src); rlwimi bits,t0,24, 0, 7 #else /*}{ pray for no unalignment trap or slowdown */ - li bits,1 # compensate for 'lbzu' - lwbrx bits,bits,src # bits= fetch_le32(bits+src) + li bits,1 // compensate for 'lbzu' + lwbrx bits,bits,src // bits= fetch_le32(bits+src) addi src,src,4 #endif /*}*/ - cmpl 0,bits,hibit # cr0 for jnextb - addc bits,bits,bits # CArry for getnextb - ori bits,bits,1 # the flag bit + cmpl 0,bits,hibit // cr0 for jnextb + addc bits,bits,bits // CArry for getnextb + ori bits,bits,1 // the flag bit ret lit_n2e: #define tmp len - lbzu tmp,1(src) # tmp= *++src; - stbu tmp,1(dst) # *++dst= tmp; + lbzu tmp,1(src) // tmp= *++src; + stbu tmp,1(dst) // *++dst= tmp; #undef tmp top_n2e: jnextb1y lit_n2e @@ -116,21 +105,21 @@ getoff_n2e: jnextb0n off_n2e li len,0 - addic. off,off,-3 # CArry set [and ignored], but no 'addi.' - rlwinm off,off,8,0,31-8 # off<<=8; + addic. off,off,-3 // CArry set [and ignored], but no 'addi.' + rlwinm off,off,8,0,31-8 // off<<=8; blt- offprev_n2e lbzu t0,1(src) - nor. disp,off,t0 # disp = -(1+ (off|t0)); - srawi disp,disp,1 # shift off low bit (sets CArry; ignored) - beq- eof_n2e - andi. t0,t0,1 # complement of low bit of unshifted disp - beq+ lenlast_n2e # low bit was 1 - b lenmore_n2e # low bit was 0 + nor. disp,off,t0 // disp = -(1+ (off|t0)); + srawi disp,disp,1 // shift off low bit (sets CArry; ignored) + beq- eof_nrv + andi. t0,t0,1 // complement of low bit of unshifted disp + beq+ lenlast_n2e // low bit was 1 + b lenmore_n2e // low bit was 0 offprev_n2e: jnextb1y lenlast_n2e lenmore_n2e: - li len,1 # 1: "the msb" + li len,1 // 1: "the msb" jnextb1y lenlast_n2e len_n2e: getnextb(len) @@ -139,16 +128,16 @@ len_n2e: b gotlen_n2e lenlast_n2e: - getnextb(len) # 0,1,2,3 + getnextb(len) // 0,1,2,3 gotlen_n2e: #define tmp off - subfic tmp,disp,(~0)+(-0x500) # want CArry only + subfic tmp,disp,(~0)+(-0x500) // want CArry only #undef tmp addi len,len,2 - addze len,len # len += (disp < -0x500); + addze len,len // len += (disp < -0x500); #define back off - add back,disp,dst # point back to match in dst + add back,disp,dst // point back to match in dst mtctr len short_n2e: #define tmp len @@ -164,21 +153,10 @@ bot_n2e: pace the dcbtst optimally; but that takes 7 or 8 instructions of space. */ li back,2*SZ_DLINE - dcbtst back,dst # 2 lines ahead [-1 for stbu] - dcbt back,src # jump start auto prefetch at page boundary + dcbtst back,dst // 2 lines ahead [-1 for stbu] + dcbt back,src // jump start auto prefetch at page boundary /* Auto prefetch for Read quits at page boundary; needs 2 misses to restart. */ b top_n2e #undef back -eof_n2e: -#define tmp r0 /* hibit is dead */ - lwz tmp,0(ldst) # original dst - mtlr t3 # return address - addi dst,dst,1 # uncorrect for 'stbu' - addi src,src,1 # uncorrect for 'lbzu' - subf dst,tmp,dst # dst -= tmp; // dst length -#undef tmp - subf a0,lsrc,src # src -= eof; // return 0: good; else: bad - stw dst,0(ldst) - ret - +not_nrv2e: diff --git a/src/stub/src/powerpc-linux.elf-entry.S b/src/stub/src/powerpc-linux.elf-entry.S index 8c58158c..38b834af 100644 --- a/src/stub/src/powerpc-linux.elf-entry.S +++ b/src/stub/src/powerpc-linux.elf-entry.S @@ -29,12 +29,8 @@ * */ -#include "arch/powerpc/32/regs.h" - -/*__MACOS000__*/ -_start: .globl _start - call main # must be exactly 1 instruction; link_register= &decompress -#include "arch/powerpc/32/nrv2e_d.S" +#include "arch/powerpc/32/ppc_regs.h" +#define section .section sz_b_info= 12 sz_unc= 0 @@ -49,29 +45,77 @@ MAP_PRIVATE= 2 MAP_FIXED= 0x10 MAP_ANONYMOUS= 0x20 -__NR_mmap= 90 - PAGE_SHIFT= 12 PAGE_SIZE = -(~0<