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

Updated some ELF constants.

committer: mfx <mfx> 1109674932 +0000
This commit is contained in:
Markus F.X.J. Oberhumer 2005-03-01 11:02:12 +00:00
parent a0b26b6c06
commit 044d6b2ce2
2 changed files with 21 additions and 31 deletions

View File

@ -57,15 +57,19 @@ struct TT_Elf32_Ehdr
EI_CLASS = 4,
EI_DATA = 5,
EI_VERSION = 6,
EI_OSABI = 7
EI_OSABI = 7,
EI_ABIVERSION = 8
};
enum { // EI_CLASS
ELFCLASS32 = 1, /* 32-bit objects */
ELFCLASS32 = 1, /* 32-bit objects */
ELFCLASS64 = 2 /* 64-bit objects */
};
enum { // EI_DATA
ELFDATA2LSB = 1, /* 2's complement, little endian */
ELFDATA2MSB = 2 /* 2's complement, big endian */
ELFDATA2LSB = 1, /* 2's complement, little endian */
ELFDATA2MSB = 2 /* 2's complement, big endian */
};
enum { // EI_OSABI
ELFOSABI_LINUX = 3
};
enum { // e_type
ET_NONE = 0, /* No file type */
@ -74,12 +78,13 @@ struct TT_Elf32_Ehdr
ET_DYN = 3, /* Shared object file */
ET_CORE = 4 /* Core file */
};
enum { // e_machine
EM_386 = 3,
EM_PPC = 20
};
enum { // e_version
EV_CURRENT = 1
};
enum { // e_machine
EM_PPC = 20
};
}
__attribute_packed;

View File

@ -83,33 +83,17 @@ void PackLinuxI386interp::pack1(OutputFile *fo, Filter &)
fi->seek(ehdri.e_phoff, SEEK_SET);
fi->readx(phdri, sz_phdrs);
#define EI_ABIVERSION 8 /* ABI version */
#define EI_OSABI 7 /* OS ABI identification */
#define ELFOSABI_LINUX 3 /* Linux. */
#define EI_VERSION 6 /* File version byte index */
#define EV_CURRENT 1 /* Current version */
#define EI_DATA 5 /* Data encoding byte index */
#define ELFDATA2LSB 1 /* 2's complement, little endian */
#define EI_CLASS 4 /* File class byte index */
#define ELFCLASS32 1 /* 32-bit objects */
#define ET_EXEC 2
#define EM_386 3
#define E Elf32_Ehdr
cprElfHdr3 h3;
memset(&h3, 0, sizeof(h3));
memcpy(h3.ehdr.e_ident, "\177ELF", 4);
h3.ehdr.e_ident[EI_CLASS] = ELFCLASS32;
h3.ehdr.e_ident[EI_DATA] = ELFDATA2LSB;
h3.ehdr.e_ident[EI_VERSION] = EV_CURRENT;
h3.ehdr.e_ident[EI_OSABI] = ELFOSABI_LINUX;
h3.ehdr.e_ident[EI_ABIVERSION] = EV_CURRENT;
h3.ehdr.e_type = ET_EXEC;
h3.ehdr.e_machine = EM_386;
h3.ehdr.e_ident[E::EI_CLASS] = E::ELFCLASS32;
h3.ehdr.e_ident[E::EI_DATA] = E::ELFDATA2LSB;
h3.ehdr.e_ident[E::EI_VERSION] = E::EV_CURRENT;
h3.ehdr.e_ident[E::EI_OSABI] = E::ELFOSABI_LINUX;
h3.ehdr.e_ident[E::EI_ABIVERSION] = E::EV_CURRENT;
h3.ehdr.e_type = E::ET_EXEC;
h3.ehdr.e_machine = E::EM_386;
h3.ehdr.e_version = 1;
h3.ehdr.e_phoff = sizeof(Elf32_Ehdr);
h3.ehdr.e_ehsize = sizeof(Elf32_Ehdr);
@ -134,6 +118,7 @@ void PackLinuxI386interp::pack1(OutputFile *fo, Filter &)
else { // usual case
generateElfHdr(fo, &h3, getbrk(phdri, ehdri.e_phnum));
}
#undef E
}
void PackLinuxI386interp::pack2(OutputFile *fo, Filter &ft)