more *BSD arrangements
This commit is contained in:
@@ -30,6 +30,7 @@
|
|||||||
#include "mygetopt.h"
|
#include "mygetopt.h"
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
#include "packer.h"
|
#include "packer.h"
|
||||||
|
#include "p_elf.h"
|
||||||
|
|
||||||
|
|
||||||
#if 1 && defined(__DJGPP__)
|
#if 1 && defined(__DJGPP__)
|
||||||
@@ -737,6 +738,18 @@ static int do_option(int optc, const char *arg)
|
|||||||
case 665:
|
case 665:
|
||||||
opt->o_unix.make_ptinterp = true;
|
opt->o_unix.make_ptinterp = true;
|
||||||
break;
|
break;
|
||||||
|
case 666: // Linux
|
||||||
|
opt->o_unix.osabi0 = 0; // Elf32_Ehdr::ELFOSABI_LINUX
|
||||||
|
break;
|
||||||
|
case 667: // FreeBSD
|
||||||
|
opt->o_unix.osabi0 = Elf32_Ehdr::ELFOSABI_FREEBSD;
|
||||||
|
break;
|
||||||
|
case 668: // NetBSD
|
||||||
|
opt->o_unix.osabi0 = Elf32_Ehdr::ELFOSABI_NETBSD;
|
||||||
|
break;
|
||||||
|
case 669: // OpenBSD
|
||||||
|
opt->o_unix.osabi0 = Elf32_Ehdr::ELFOSABI_OPENBSD;
|
||||||
|
break;
|
||||||
case 670:
|
case 670:
|
||||||
opt->ps1_exe.boot_only = true;
|
opt->ps1_exe.boot_only = true;
|
||||||
break;
|
break;
|
||||||
@@ -864,6 +877,10 @@ static const struct mfx_option longopts[] =
|
|||||||
{"is_ptinterp", 0, 0, 663}, // linux/elf386 PT_INTERP program
|
{"is_ptinterp", 0, 0, 663}, // linux/elf386 PT_INTERP program
|
||||||
{"use_ptinterp", 0, 0, 664}, // linux/elf386 PT_INTERP program
|
{"use_ptinterp", 0, 0, 664}, // linux/elf386 PT_INTERP program
|
||||||
{"make_ptinterp", 0, 0, 665}, // linux/elf386 PT_INTERP program
|
{"make_ptinterp", 0, 0, 665}, // linux/elf386 PT_INTERP program
|
||||||
|
{"Linux", 0, 0, 666},
|
||||||
|
{"FreeBSD", 0, 0, 667},
|
||||||
|
{"NetBSD", 0, 0, 668},
|
||||||
|
{"OpenBSD", 0, 0, 669},
|
||||||
// watcom/le
|
// watcom/le
|
||||||
{"le", 0, 0, 620}, // produce LE output
|
{"le", 0, 0, 620}, // produce LE output
|
||||||
// win32/pe
|
// win32/pe
|
||||||
|
|||||||
@@ -146,6 +146,7 @@ struct options_t {
|
|||||||
bool is_ptinterp; // is PT_INTERP, so don't adjust auxv_t
|
bool is_ptinterp; // is PT_INTERP, so don't adjust auxv_t
|
||||||
bool use_ptinterp; // use PT_INTERP /opt/upx/run
|
bool use_ptinterp; // use PT_INTERP /opt/upx/run
|
||||||
bool make_ptinterp; // make PT_INTERP [ignore current file!]
|
bool make_ptinterp; // make PT_INTERP [ignore current file!]
|
||||||
|
unsigned char osabi0; // replacement if 0==.e_ident[EI_OSABI]
|
||||||
enum { SCRIPT_MAX = 32 };
|
enum { SCRIPT_MAX = 32 };
|
||||||
const char *script_name;
|
const char *script_name;
|
||||||
} o_unix;
|
} o_unix;
|
||||||
|
|||||||
@@ -72,8 +72,10 @@ struct Ehdr
|
|||||||
};
|
};
|
||||||
enum { // e_ident[EI_OSABI]
|
enum { // e_ident[EI_OSABI]
|
||||||
ELFOSABI_NONE = 0,
|
ELFOSABI_NONE = 0,
|
||||||
|
ELFOSABI_NETBSD = 2,
|
||||||
ELFOSABI_LINUX = 3,
|
ELFOSABI_LINUX = 3,
|
||||||
ELFOSABI_FREEBSD = 9,
|
ELFOSABI_FREEBSD = 9,
|
||||||
|
ELFOSABI_OPENBSD = 12,
|
||||||
ELFOSABI_ARM = 97
|
ELFOSABI_ARM = 97
|
||||||
};
|
};
|
||||||
enum { // e_type
|
enum { // e_type
|
||||||
|
|||||||
+32
-2
@@ -50,11 +50,15 @@ int
|
|||||||
PackLinuxElf32::checkEhdr(Elf32_Ehdr const *ehdr) const
|
PackLinuxElf32::checkEhdr(Elf32_Ehdr const *ehdr) const
|
||||||
{
|
{
|
||||||
const unsigned char * const buf = ehdr->e_ident;
|
const unsigned char * const buf = ehdr->e_ident;
|
||||||
|
unsigned osabi0 = buf[Elf32_Ehdr::EI_OSABI];
|
||||||
|
if (0==osabi0) {
|
||||||
|
osabi0 = opt->o_unix.osabi0;
|
||||||
|
}
|
||||||
|
|
||||||
if (0!=memcmp(buf, "\x7f\x45\x4c\x46", 4) // "\177ELF"
|
if (0!=memcmp(buf, "\x7f\x45\x4c\x46", 4) // "\177ELF"
|
||||||
|| buf[Elf32_Ehdr::EI_CLASS]!=ei_class
|
|| buf[Elf32_Ehdr::EI_CLASS]!=ei_class
|
||||||
|| buf[Elf32_Ehdr::EI_DATA] !=ei_data
|
|| buf[Elf32_Ehdr::EI_DATA] !=ei_data
|
||||||
|| buf[Elf32_Ehdr::EI_OSABI] !=ei_osabi
|
|| osabi0!=ei_osabi
|
||||||
) {
|
) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -1874,13 +1878,39 @@ PackBSDElf32x86::PackBSDElf32x86(InputFile *f) : super(f)
|
|||||||
e_machine = Elf32_Ehdr::EM_386;
|
e_machine = Elf32_Ehdr::EM_386;
|
||||||
ei_class = Elf32_Ehdr::ELFCLASS32;
|
ei_class = Elf32_Ehdr::ELFCLASS32;
|
||||||
ei_data = Elf32_Ehdr::ELFDATA2LSB;
|
ei_data = Elf32_Ehdr::ELFDATA2LSB;
|
||||||
ei_osabi = Elf32_Ehdr::ELFOSABI_FREEBSD;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PackBSDElf32x86::~PackBSDElf32x86()
|
PackBSDElf32x86::~PackBSDElf32x86()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PackFreeBSDElf32x86::PackFreeBSDElf32x86(InputFile *f) : super(f)
|
||||||
|
{
|
||||||
|
ei_osabi = Elf32_Ehdr::ELFOSABI_FREEBSD;
|
||||||
|
}
|
||||||
|
|
||||||
|
PackFreeBSDElf32x86::~PackFreeBSDElf32x86()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
PackNetBSDElf32x86::PackNetBSDElf32x86(InputFile *f) : super(f)
|
||||||
|
{
|
||||||
|
ei_osabi = Elf32_Ehdr::ELFOSABI_NETBSD;
|
||||||
|
}
|
||||||
|
|
||||||
|
PackNetBSDElf32x86::~PackNetBSDElf32x86()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
PackOpenBSDElf32x86::PackOpenBSDElf32x86(InputFile *f) : super(f)
|
||||||
|
{
|
||||||
|
ei_osabi = Elf32_Ehdr::ELFOSABI_OPENBSD;
|
||||||
|
}
|
||||||
|
|
||||||
|
PackOpenBSDElf32x86::~PackOpenBSDElf32x86()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
int const *
|
int const *
|
||||||
PackLinuxElf32x86::getFilters() const
|
PackLinuxElf32x86::getFilters() const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -342,6 +342,30 @@ protected:
|
|||||||
virtual int buildLoader(const Filter *);
|
virtual int buildLoader(const Filter *);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class PackFreeBSDElf32x86 : public PackBSDElf32x86
|
||||||
|
{
|
||||||
|
typedef PackBSDElf32x86 super;
|
||||||
|
public:
|
||||||
|
PackFreeBSDElf32x86(InputFile *f);
|
||||||
|
virtual ~PackFreeBSDElf32x86();
|
||||||
|
};
|
||||||
|
|
||||||
|
class PackNetBSDElf32x86 : public PackBSDElf32x86
|
||||||
|
{
|
||||||
|
typedef PackBSDElf32x86 super;
|
||||||
|
public:
|
||||||
|
PackNetBSDElf32x86(InputFile *f);
|
||||||
|
virtual ~PackNetBSDElf32x86();
|
||||||
|
};
|
||||||
|
|
||||||
|
class PackOpenBSDElf32x86 : public PackBSDElf32x86
|
||||||
|
{
|
||||||
|
typedef PackBSDElf32x86 super;
|
||||||
|
public:
|
||||||
|
PackOpenBSDElf32x86(InputFile *f);
|
||||||
|
virtual ~PackOpenBSDElf32x86();
|
||||||
|
};
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
// linux/elfarm
|
// linux/elfarm
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|||||||
+5
-1
@@ -213,7 +213,11 @@ static Packer* try_packers(InputFile *f, try_function func)
|
|||||||
if ((p = func(new PackLinuxElf32x86interp(f),f)) != NULL)
|
if ((p = func(new PackLinuxElf32x86interp(f),f)) != NULL)
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
if ((p = func(new PackBSDElf32x86(f),f)) != NULL)
|
if ((p = func(new PackFreeBSDElf32x86(f),f)) != NULL)
|
||||||
|
return p;
|
||||||
|
if ((p = func(new PackNetBSDElf32x86(f),f)) != NULL)
|
||||||
|
return p;
|
||||||
|
if ((p = func(new PackOpenBSDElf32x86(f),f)) != NULL)
|
||||||
return p;
|
return p;
|
||||||
if ((p = func(new PackLinuxElf32x86(f),f)) != NULL)
|
if ((p = func(new PackLinuxElf32x86(f),f)) != NULL)
|
||||||
return p;
|
return p;
|
||||||
|
|||||||
Reference in New Issue
Block a user