From 044d6b2ce2a269c08bc9f658014fd6b71fa53345 Mon Sep 17 00:00:00 2001 From: "Markus F.X.J. Oberhumer" Date: Tue, 1 Mar 2005 11:02:12 +0000 Subject: [PATCH] Updated some ELF constants. committer: mfx 1109674932 +0000 --- src/p_elf.h | 19 ++++++++++++------- src/p_lx_interp.cpp | 33 +++++++++------------------------ 2 files changed, 21 insertions(+), 31 deletions(-) diff --git a/src/p_elf.h b/src/p_elf.h index 08255def..3b04f91b 100644 --- a/src/p_elf.h +++ b/src/p_elf.h @@ -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; diff --git a/src/p_lx_interp.cpp b/src/p_lx_interp.cpp index f3a18bdb..1a79dcb2 100644 --- a/src/p_lx_interp.cpp +++ b/src/p_lx_interp.cpp @@ -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)