powerpc64-darwin.macho (not powerpc64le-darwin.macho)

All Apple PowerPC are BigEndian only.
        https://github.com/upx/upx/issues/596
	modified:   p_mach.cpp
	modified:   p_mach.h
	modified:   packmast.cpp
This commit is contained in:
John Reiser
2022-09-03 12:39:50 -07:00
committed by Markus F.X.J. Oberhumer
parent eb68ab91cd
commit aeb04d97c8
3 changed files with 43 additions and 63 deletions
+19 -39
View File
@@ -478,26 +478,6 @@ __packed_struct(Mach_ppc_thread_state64)
Word vrsave; /* Vector Save Register */
__packed_struct_end()
template <class TMachITypes>
__packed_struct(Mach_ppcle_thread_state64)
typedef typename TMachITypes::Word Word;
typedef typename TMachITypes::Xword Xword;
Xword srr0; /* Instruction address register (PC; entry addr) */
Xword srr1; /* Machine state register (supervisor) */
Xword r0, r1, r2, r3, r4, r5, r6, r7;
Xword r8, r9,r10,r11,r12,r13,r14,r15;
Xword r16,r17,r18,r19,r20,r21,r22,r23;
Xword r24,r25,r26,r27,r28,r29,r30,r31;
Word cr; /* Condition register */ // FIXME: Xword?
Xword xer; /* User's integer exception register */
Xword lr; /* Link register */
Xword ctr; /* Count register */
Word vrsave; /* Vector Save Register */
__packed_struct_end()
template <class TMachITypes> __packed_struct(Mach_ARM64_thread_state)
typedef typename TMachITypes::Xword Xword;
typedef typename TMachITypes::Word Word;
@@ -593,7 +573,7 @@ struct MachClass_64
typedef N_Mach::Mach_source_version_command<MachITypes> Mach_source_version_command;
typedef N_Mach::Mach_main_command<MachITypes> Mach_main_command;
typedef N_Mach64::Mach_ppcle_thread_state64<MachITypes> Mach_ppcle_thread_state64;
typedef N_Mach64::Mach_ppc_thread_state64<MachITypes> Mach_ppc_thread_state64;
typedef N_Mach64::Mach_AMD64_thread_state<MachITypes> Mach_AMD64_thread_state;
typedef N_Mach64::Mach_ARM64_thread_state<MachITypes> Mach_ARM64_thread_state;
@@ -716,7 +696,7 @@ typedef MachClass_LE64::Mach_version_min_command MachLE64_version_min_command;
typedef MachClass_LE64::Mach_source_version_command MachLE64_source_version_command;
typedef MachClass_BE32::Mach_ppc_thread_state Mach_ppc_thread_state;
typedef MachClass_LE64::Mach_ppcle_thread_state64 Mach_ppcle_thread_state64;
typedef MachClass_BE64::Mach_ppc_thread_state64 Mach_ppc_thread_state64;
typedef MachClass_LE32::Mach_i386_thread_state Mach_i386_thread_state;
typedef MachClass_LE64::Mach_AMD64_thread_state Mach_AMD64_thread_state;
typedef MachClass_LE64::Mach_ARM64_thread_state Mach_ARM64_thread_state;
@@ -937,16 +917,16 @@ protected:
}
};
class PackMachPPC64LE : public PackMachBase<MachClass_LE64>
class PackMachPPC64 : public PackMachBase<MachClass_BE64>
{
typedef PackMachBase<MachClass_LE64> super;
typedef PackMachBase<MachClass_BE64> super;
public:
PackMachPPC64LE(InputFile *f);
PackMachPPC64(InputFile *f);
virtual int getFormat() const { return UPX_F_MACH_PPC64LE; }
virtual const char *getName() const { return "macho/ppc64le"; }
virtual const char *getFullName(const options_t *) const { return "powerpc64le-darwin.macho"; }
virtual int getFormat() const { return UPX_F_MACH_PPC64; }
virtual const char *getName() const { return "macho/ppc64"; }
virtual const char *getFullName(const options_t *) const { return "powerpc64-darwin.macho"; }
protected:
virtual const int *getFilters() const;
@@ -955,11 +935,11 @@ protected:
virtual Linker* newLinker() const;
__packed_struct(Mach_thread_command)
LE32 cmd; /* LC_THREAD or LC_UNIXTHREAD */
LE32 cmdsize; /* total size of this command */
LE32 flavor;
LE32 count; /* sizeof(following_thread_state)/4 */
Mach_ppcle_thread_state64 state64;
BE32 cmd; /* LC_THREAD or LC_UNIXTHREAD */
BE32 cmdsize; /* total size of this command */
BE32 flavor;
BE32 count; /* sizeof(following_thread_state)/4 */
Mach_ppc_thread_state64 state64;
#define WANT_MACH_THREAD_ENUM 1
#include "p_mach_enum.h"
__packed_struct_end()
@@ -1004,16 +984,16 @@ protected:
virtual void pack4(OutputFile *, Filter &); // append PackHeader
};
class PackDylibPPC64LE : public PackMachPPC64LE
class PackDylibPPC64 : public PackMachPPC64
{
typedef PackMachPPC64LE super;
typedef PackMachPPC64 super;
public:
PackDylibPPC64LE(InputFile *f);
PackDylibPPC64(InputFile *f);
virtual int getFormat() const { return UPX_F_DYLIB_PPC64LE; }
virtual const char *getName() const { return "dylib/ppc64le"; }
virtual const char *getFullName(const options_t *) const { return "powerpc64le-darwin.dylib"; }
virtual int getFormat() const { return UPX_F_DYLIB_PPC64; }
virtual const char *getName() const { return "dylib/ppc64"; }
virtual const char *getFullName(const options_t *) const { return "powerpc64-darwin.dylib"; }
protected:
virtual off_t pack3(OutputFile *, Filter &); // append loader
virtual void pack4(OutputFile *, Filter &); // append PackHeader