home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
vp21beta.zip
/
LRTLSRC.RAR
/
PE2ELF
/
ELFDEF.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
2000-08-15
|
7KB
|
226 lines
(*$Use32+*)
unit elfdef;
// 1999.07.28 Veit Kannegieser
interface
type
Elf32_Ehdr_type=
packed record
magic0123 :array[0..3] of char;
file_class :byte;
data_encoding :byte;
file_version :byte;
padding :array[$07..$0f] of byte;
e_type :smallword;
e_machine :smallword;
e_version :word;
e_entry :word; // entrypoint
e_phoff :word; // program header offset
e_shoff :word; // sections header offset
e_flags :word;
e_ehsize :smallword; // elf header size in bytes
e_phentsize :smallword; // size of an entry in the program header array
e_phnum :smallword; // 0..e_phnum-1 of entrys
e_shentsize :smallword; // size of an entry in sections header array
e_shnum :smallword; // 0..e_shnum-1 of entrys
e_shstrndx :smallword; // index of string section header
end;
const
magic0123_elf =#$7f'ELF';
file_class__32bit =1;
ELFDATA2LSB =1;
e_type__exec =2; // executable file
e_machine__intel386 =3;
e_version__current =1;
type
section_header_type= // Seite 26
packed record
sh_name :word;
sh_type :word;
sh_flags :word;
sh_addr :word;
sh_offset :word;
sh_size :word;
sh_link :word;
sh_info :word;
sh_addralign :word;
sh_entsize :word;
end;
const
// sh_type
SHT_NULL = 0;
SHT_PROGBITS = 1;
SHT_SYMTAB = 2;
SHT_STRTAB = 3;
SHT_RELA = 4;
SHT_HASH = 5;
SHT_DYNAMIC = 6;
SHT_NOTE = 7;
SHT_NOBITS = 8;
SHT_REL = 9;
SHT_SHLIB = 10;
SHT_DYNSYM = 11;
SHT_LOPROC = $70000000;
SHT_HIPROC = $7fffffff;
SHT_LOUSER = $80000000;
SHT_HIUSER = $ffffffff;
// sh_flags
SHF_WRITE = $00000001;
SHF_ALLOC = $00000002;
SHF_EXECINSTR = $00000004;
SHF_MASKPROC = $f0000000;
// Seite 23, Verweise in .dynsym
SHN_UNDEF = $0000;
SHN_LORESERVE = $ff00;
SHN_LOPROC = $ff00;
SHN_HIPROC = $ff1f;
SHN_ABS = $fff1;
SHN_COMMON = $fff2;
SHN_HIRESERVE = $ffff;
type
Elf32_Rel_type=
packed record
r_offset :word;
r_info :word;
end;
Elf32_Rela_type=
packed record
r_offset :word;
r_info :word;
r_addend :integer;
end;
const
// Seite 58
R_386_NONE = 0;
R_386_32 = 1;
R_386_PC32 = 2;
// Seite 93
R_386_GOT32 = 3;
R_386_PLT32 = 4;
R_386_COPY = 5;
R_386_GLOB_DAT = 6;
R_386_JMP_SLOT = 7;
R_386_RELATIVE = 8;
R_386_GOTOFF = 9;
R_386_GOTPC = 10;
type
program_header_type=
packed record
p_type :word;
p_offset :word;
p_vaddr :word;
p_paddr :word;
p_filesz :word;
p_memsz :word;
p_flags :word;
p_align :word;
end;
const
// p_type
PT_NULL = 0;
PT_LOAD = 1;
PT_DYNAMIC = 2;
PT_INTERP = 3;
PT_NOTE = 4;
PT_SHLIB = 5;
PT_PHDR = 6;
PT_LOPROC = $70000000;
PT_HIPROC = $7fffffff;
// p_flags
PF_X = $00000001; // Execute
PF_W = $00000002; // Write
PF_R = $00000004; // Read
PF_MASKPROC = $f0000000; // Unspecified
type // Seite 32
Elf32_Sym_type=
packed record
st_name :word;
st_value :word;
st_size :word;
st_info :byte;
st_other :byte;
st_shndx :smallword;
end;
const
// Seite 33 (st_info shr 4)
STB_LOCAL = 0;
STB_GLOBAL = 1;
STB_WEAK = 2;
STB_LOPROC = 13;
STB_HIPROC = 15;
// Seite 34 (st_info and $f)
STT_NOTYPE = 0;
STT_OBJECT = 1;
STT_FUNC = 2;
STT_SECTION = 3;
STT_FILE = 4;
STT_LOPROC = 13;
STT_HIPROC = 15;
type
Elf32_Dyn_type=
packed record
d_tag :word;
case integer of
0:(d_val :word);
1:(d_ptr :word);
end;
const
// Seite 80
// d_tag Name Value d_un Executable Shared Object
DT_NULL = 0; // ignored mandatory mandatory
DT_NEEDED = 1; // d_val optional optional
DT_PLTRELSZ = 2; // d_val optional optional
DT_PLTGOT = 3; // d_ptr optional optional
DT_HASH = 4; // d_ptr mandatory mandatory
DT_STRTAB = 5; // d_ptr mandatory mandatory
DT_SYMTAB = 6; // d_ptr mandatory mandatory
DT_RELA = 7; // d_ptr mandatory optional
DT_RELASZ = 8; // d_val mandatory optional
DT_RELAENT = 9; // d_val mandatory optional
DT_STRSZ = 10; // d_val mandatory mandatory
DT_SYMENT = 11; // d_val mandatory mandatory
DT_INIT = 12; // d_ptr optional optional
DT_FINI = 13; // d_ptr optional optional
DT_SONAME = 14; // d_val ignored optional
DT_RPATH = 15; // d_val optional ignored
DT_SYMBOLIC = 16; // ignored ignored optional
DT_REL = 17; // d_ptr mandatory optional
DT_RELSZ = 18; // d_val mandatory optional
DT_RELENT = 19; // d_val mandatory optional
DT_PLTREL = 20; // d_val optional optional
DT_DEBUG = 21; // d_ptr optional ignored
DT_TEXTREL = 22; // ignored optional optional
DT_JMPREL = 23; // d_ptr optional optional
DT_BIND_NOW = 24; // ignored optional optional
DT_LOPROC =$70000000; // unspecified unspecified unspecified
DT_HIPROC =$7fffffff; // unspecified unspecified unspecified
implementation
end.