about summary refs log tree commit diff stats
path: root/cpp/.traces
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-04-28 22:42:54 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-04-28 22:42:54 -0700
commite3fa6cc7af792a6c0d83d9004859d6e9452c5fdb (patch)
tree411b8592ed143ed3f2ddf60ea6e05e03213bcf86 /cpp/.traces
parent0012c7037f63bf9a0195ba493448bc16f01655cd (diff)
downloadmu-e3fa6cc7af792a6c0d83d9004859d6e9452c5fdb.tar.gz
1216
Diffstat (limited to 'cpp/.traces')
-rw-r--r--cpp/.traces/string_literal9
-rw-r--r--cpp/.traces/string_literal_nested2
-rw-r--r--cpp/.traces/string_literal_with_colons2
3 files changed, 10 insertions, 3 deletions
diff --git a/cpp/.traces/string_literal b/cpp/.traces/string_literal
index 82986a95..333fb20d 100644
--- a/cpp/.traces/string_literal
+++ b/cpp/.traces/string_literal
@@ -1,3 +1,10 @@
-parse/0: instruction: 38
+parse/0: instruction: 1
 parse/0:   ingredient: {name: "abc def", value: 0, type: 0, properties: ["abc def": "literal-string"]}
+parse/0:   ingredient: {name: "#", value: 0, type: , properties: ["#": ]}
+parse/0:   ingredient: {name: "copy", value: 0, type: , properties: ["copy": ]}
+parse/0:   ingredient: {name: "can't", value: 0, type: , properties: ["can't": ]}
+parse/0:   ingredient: {name: "really", value: 0, type: , properties: ["really": ]}
+parse/0:   ingredient: {name: "take", value: 0, type: , properties: ["take": ]}
+parse/0:   ingredient: {name: "a", value: 0, type: , properties: ["a": ]}
+parse/0:   ingredient: {name: "string", value: 0, type: , properties: ["string": ]}
 parse/0:   product: {name: "1", value: 0, type: 2-5-4, properties: ["1": "address":"array":"character"]}
diff --git a/cpp/.traces/string_literal_nested b/cpp/.traces/string_literal_nested
index 219b31db..937d78f7 100644
--- a/cpp/.traces/string_literal_nested
+++ b/cpp/.traces/string_literal_nested
@@ -1,3 +1,3 @@
-parse/0: instruction: 38
+parse/0: instruction: 1
 parse/0:   ingredient: {name: "abc [def]", value: 0, type: 0, properties: ["abc [def]": "literal-string"]}
 parse/0:   product: {name: "1", value: 0, type: 2-5-4, properties: ["1": "address":"array":"character"]}
diff --git a/cpp/.traces/string_literal_with_colons b/cpp/.traces/string_literal_with_colons
index 5f181a42..698f0358 100644
--- a/cpp/.traces/string_literal_with_colons
+++ b/cpp/.traces/string_literal_with_colons
@@ -1,3 +1,3 @@
-parse/0: instruction: 38
+parse/0: instruction: 1
 parse/0:   ingredient: {name: "abc:def/ghi", value: 0, type: 0, properties: ["abc:def/ghi": "literal-string"]}
 parse/0:   product: {name: "1", value: 0, type: 2-5-4, properties: ["1": "address":"array":"character"]}
-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
#ifndef ELF_H
#define ELF_H

#include "common.h"

/*
 * ELF HEADER
 */
typedef struct {
    unsigned char e_ident[16];	/* ELF identification */
    uint16 e_type;		/* 2 (exec file) */
    uint16 e_machine;		/* 3 (intel architecture) */
    uint32 e_version;		/* 1 */
    uint32 e_entry;		/* starting point */
    uint32 e_phoff;		/* program header table offset */
    uint32 e_shoff;		/* section header table offset */
    uint32 e_flags;		/* various flags */
    uint16 e_ehsize;		/* ELF header (this) size */

    uint16 e_phentsize;	/* program header table entry size */
    uint16 e_phnum;		/* number of entries */

    uint16 e_shentsize;	/* section header table entry size */
    uint16 e_shnum;		/* number of entries */

    uint16 e_shstrndx;		/* index of the section name string table */
} Elf32_Ehdr;

/*
 * ELF identification
 */
#define	EI_MAG0		0
#define	EI_MAG1		1
#define	EI_MAG2		2
#define	EI_MAG3		3
#define	EI_CLASS	4
#define	EI_DATA		5
#define	EI_VERSION	6
#define EI_PAD		7

/* EI_MAG */
#define	ELFMAG0		0x7f
#define	ELFMAG1		'E'
#define	ELFMAG2		'L'
#define	ELFMAG3		'F'

/* EI_CLASS */
#define	ELFCLASSNONE	0	/* invalid class */
#define	ELFCLASS32	1	/* 32-bit objects */
#define	ELFCLASS64	2	/* 64-bit objects */

/* EI_DATA */
#define	ELFDATANONE	0	/* invalide data encoding */
#define	ELFDATA2LSB	1	/* least significant byte first (0x01020304 is 0x04 0x03 0x02 0x01) */
#define	ELFDATA2MSB	2	/* most significant byte first (0x01020304 is 0x01 0x02 0x03 0x04) */

/* EI_VERSION */
#define	EV_CURRENT	1
#define	ELFVERSION	EV_CURRENT

/*
 * PROGRAM HEADER
 */
typedef struct {
    uint32 p_type;		/* type of segment */
    uint32 p_offset;
    uint32 p_vaddr;
    uint32 p_paddr;
    uint32 p_filesz;
    uint32 p_memsz;
    uint32 p_flags;
    uint32 p_align;
} Elf32_Phdr;

/* p_type */
#define	PT_NULL             0
#define	PT_LOAD             1
#define	PT_DYNAMIC          2
#define	PT_INTERP           3
#define	PT_NOTE             4
#define	PT_SHLIB            5
#define	PT_PHDR             6
#define	PT_LOPROC  0x70000000
#define	PT_HIPROC  0x7fffffff

/* p_flags */
#define PF_X	0x1
#define PF_W	0x2
#define PF_R	0x4



enum eElfSectionTypes {
    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,	//A
    SHT_DYNSYM,	//B
    SHT_LAST,	//C
    SHT_LOPROC = 0x70000000,
    SHT_HIPROC = 0x7fffffff,
    SHT_LOUSER = 0x80000000,
    SHT_HIUSER = 0xffffffff
};


typedef struct {
    uint32		name;
    uint32	type;
    uint32	flags;
    uint32	address;
    uint32	offset;
    uint32	size;
    uint32	link;
    uint32	info;
    uint32	addralign;
    uint32	entsize;
} Elf32_Scdr;





enum {
    R_386_NONE=0,	// none
    R_386_32,	// S+A
    R_386_PC32,	// S+A-P
    R_386_GOT32,	// G+A-P
    R_386_PLT32,	// L+A-P
    R_386_COPY,	// none
    R_386_GLOB_DAT,	// S
    R_386_JMP_SLOT,	// S
    R_386_RELATIVE,	// B+A
    R_386_GOTOFF,	// S+A-GOT
    R_386_GOTPC,	// GOT+A-P
    R_386_LAST	// none
};

typedef struct {
    uint16	d_tag;
    uint32	d_val;	//Also d_ptr
} Elf32_dyn;


enum {
    DT_NULL,	//!< Marks End of list
    DT_NEEDED,	//!< Offset in strtab to needed library
    DT_PLTRELSZ,	//!< Size in bytes of PLT
    DT_PLTGOT,	//!< Address of PLT/GOT
    DT_HASH,	//!< Address of symbol hash table
    DT_STRTAB,	//!< String Table address
    DT_SYMTAB,	//!< Symbol Table address
    DT_RELA,	//!< Relocation table address
    DT_RELASZ,	//!< Size of relocation table
    DT_RELAENT,	//!< Size of entry in relocation table
    DT_STRSZ,	//!< Size of string table
    DT_SYMENT,	//!< Size of symbol table entry
    DT_INIT,	//!< Address of initialisation function
    DT_FINI,	//!< Address of termination function
    DT_SONAME,	//!< String table offset of so name
    DT_RPATH,	//!< String table offset of library path
    DT_SYMBOLIC,//!< Reverse order of symbol searching for library, search libs first then executable
    DT_REL,		//!< Relocation Entries (Elf32_Rel instead of Elf32_Rela)
    DT_RELSZ,	//!< Size of above table (bytes)
    DT_RELENT,	//!< Size of entry in above table
    DT_PLTREL,	//!< Relocation entry of PLT
    DT_DEBUG,	//!< Debugging Entry - Unknown contents
    DT_TEXTREL,	//!< Indicates that modifcations to a non-writeable segment may occur
    DT_JMPREL,	//!< Address of PLT only relocation entries
    DT_LOPROC = 0x70000000,	//!< Low Definable
    DT_HIPROC = 0x7FFFFFFF	//!< High Definable
};

BOOL isElf(char *elfData);
uint32 loadElf(char *elfData);

#endif // ELF_H