ElfLinkerPpc32

This commit is contained in:
John Reiser
2006-07-09 19:52:23 -07:00
parent 8266aa3343
commit b76118802a
4 changed files with 48 additions and 10 deletions
+30
View File
@@ -680,6 +680,11 @@ void ElfLinkerAMD64::align(unsigned len)
alignWithByte(len, 0x90); alignWithByte(len, 0x90);
} }
void ElfLinkerPpc32::align(unsigned len)
{
alignWithByte(len, 0);
}
void ElfLinkerX86::relocate1(Relocation *rel, upx_byte *location, void ElfLinkerX86::relocate1(Relocation *rel, upx_byte *location,
unsigned value, const char *type) unsigned value, const char *type)
{ {
@@ -726,6 +731,31 @@ void ElfLinkerAMD64::relocate1(Relocation *rel, upx_byte *location,
super::relocate1(rel, location, value, type); super::relocate1(rel, location, value, type);
} }
void ElfLinkerPpc32::relocate1(Relocation *rel, upx_byte *location,
unsigned value, const char *type)
{
if (strncmp(type, "R_PPC_", 6))
return super::relocate1(rel, location, value, type);
type += 6;
if (strncmp(type, "REL", 3) == 0)
{
value -= rel->section->offset + rel->offset;
type += 3;
}
// 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);
else
super::relocate1(rel, location, value, type);
}
void ElfLinkerArmLE::relocate1(Relocation *rel, upx_byte *location, void ElfLinkerArmLE::relocate1(Relocation *rel, upx_byte *location,
unsigned value, const char *type) unsigned value, const char *type)
{ {
+10
View File
@@ -268,6 +268,16 @@ protected:
unsigned value, const char *type); unsigned value, const char *type);
}; };
class ElfLinkerPpc32 : public ElfLinker
{
typedef ElfLinker super;
protected:
virtual void align(unsigned len);
virtual void relocate1(Relocation *, upx_byte *location,
unsigned value, const char *type);
};
class ElfLinkerArmLE : public ElfLinker class ElfLinkerArmLE : public ElfLinker
{ {
typedef ElfLinker super; typedef ElfLinker super;
+7 -9
View File
@@ -302,6 +302,11 @@ PackLinuxElf32ppc::~PackLinuxElf32ppc()
{ {
} }
Linker* PackLinuxElf32ppc::newLinker() const
{
return new ElfLinkerPpc32;
}
PackLinuxElf64amd::PackLinuxElf64amd(InputFile *f) PackLinuxElf64amd::PackLinuxElf64amd(InputFile *f)
: super(f) : super(f)
{ {
@@ -528,6 +533,7 @@ PackLinuxElf32::buildLinuxLoader(
addLoader("FOLDEXEC", NULL); addLoader("FOLDEXEC", NULL);
freezeLoader(); freezeLoader();
linker->relocate();
return getLoaderSize(); return getLoaderSize();
} }
@@ -583,18 +589,10 @@ PackLinuxElf64::buildLinuxLoader(
addLoader("FOLDEXEC", NULL); addLoader("FOLDEXEC", NULL);
freezeLoader(); freezeLoader();
linker->relocate();
return getLoaderSize(); return getLoaderSize();
} }
void
PackLinuxElf64amd::addStubEntrySections(
upx_byte const *const /*proto*/,
unsigned const /*szproto*/
)
{
// FIXME
}
static const static const
#include "stub/i386-linux.elf-entry.h" #include "stub/i386-linux.elf-entry.h"
static const static const
+1 -1
View File
@@ -288,7 +288,6 @@ protected:
virtual const int *getCompressionMethods(int method, int level) const; virtual const int *getCompressionMethods(int method, int level) const;
virtual int buildLoader(const Filter *); virtual int buildLoader(const Filter *);
virtual Linker* newLinker() const; virtual Linker* newLinker() const;
virtual void addStubEntrySections(upx_byte const *, unsigned);
}; };
/************************************************************************* /*************************************************************************
@@ -308,6 +307,7 @@ protected:
virtual void pack1(OutputFile *, Filter &); // generate executable header virtual void pack1(OutputFile *, Filter &); // generate executable header
virtual const int *getCompressionMethods(int method, int level) const; virtual const int *getCompressionMethods(int method, int level) const;
virtual int buildLoader(const Filter *); virtual int buildLoader(const Filter *);
virtual Linker* newLinker() const;
}; };
/************************************************************************* /*************************************************************************