aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Bucur <stefanb@zytor.com>2008-06-06 20:34:53 +0300
committerStefan Bucur <stefanb@zytor.com>2008-06-06 20:34:53 +0300
commit98b8be55d69b18ad6bfc76ee6a432e29314c7b9c (patch)
treef738d5c6457edde8ab70b1e75fc9220e645341ea
parent7a6eedf7c031dd8abb33130af71441de5b914716 (diff)
downloadsyslinux-elf-98b8be55d69b18ad6bfc76ee6a432e29314c7b9c.tar.gz
syslinux-elf-98b8be55d69b18ad6bfc76ee6a432e29314c7b9c.tar.xz
syslinux-elf-98b8be55d69b18ad6bfc76ee6a432e29314c7b9c.zip
Implemented section and symbol table headers.
-rw-r--r--.cproject176
-rw-r--r--.project77
-rw-r--r--elf/elf.h128
-rwxr-xr-xelf/elftestbin0 -> 8431 bytes
-rw-r--r--elf/elftest.c2
5 files changed, 378 insertions, 5 deletions
diff --git a/.cproject b/.cproject
new file mode 100644
index 00000000..9b0bb333
--- /dev/null
+++ b/.cproject
@@ -0,0 +1,176 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?fileVersion 4.0.0?>
+
+<cproject>
+<storageModule moduleId="org.eclipse.cdt.core.settings">
+<cconfiguration id="cdt.managedbuild.toolchain.gnu.base.1373856746">
+<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.toolchain.gnu.base.1373856746" moduleId="org.eclipse.cdt.core.settings" name="Linux GCC">
+<externalSettings/>
+<extensions>
+<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
+<extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+</extensions>
+</storageModule>
+<storageModule moduleId="cdtBuildSystem" version="4.0.0">
+<configuration artifactName="SyslinuxELF" buildProperties="" id="cdt.managedbuild.toolchain.gnu.base.1373856746" name="Linux GCC" parent="org.eclipse.cdt.build.core.emptycfg">
+<folderInfo id="cdt.managedbuild.toolchain.gnu.base.1373856746.1892202794" name="/" resourcePath="">
+<toolChain id="cdt.managedbuild.toolchain.gnu.base.991391865" name="cdt.managedbuild.toolchain.gnu.base" superClass="cdt.managedbuild.toolchain.gnu.base">
+<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.target.gnu.platform.base.551529690" name="Debug Platform" osList="linux,hpux,aix,qnx" superClass="cdt.managedbuild.target.gnu.platform.base"/>
+<builder id="cdt.managedbuild.target.gnu.builder.base.1493849787" managedBuildOn="false" name="Gnu Make Builder.Linux GCC" superClass="cdt.managedbuild.target.gnu.builder.base"/>
+<tool id="cdt.managedbuild.tool.gnu.archiver.base.771541123" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
+<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.base.934691204" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.base"/>
+<tool id="cdt.managedbuild.tool.gnu.c.compiler.base.1193832074" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.base">
+<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.356314568" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
+</tool>
+<tool id="cdt.managedbuild.tool.gnu.c.linker.base.2090485270" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.base">
+<inputType id="cdt.managedbuild.tool.gnu.c.linker.input.1066697913" superClass="cdt.managedbuild.tool.gnu.c.linker.input">
+<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
+<additionalInput kind="additionalinput" paths="$(LIBS)"/>
+</inputType>
+</tool>
+<tool id="cdt.managedbuild.tool.gnu.cpp.linker.base.1016773070" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.base"/>
+<tool id="cdt.managedbuild.tool.gnu.assembler.base.1181854962" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.base">
+<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1827973049" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
+</tool>
+</toolChain>
+</folderInfo>
+</configuration>
+</storageModule>
+<storageModule moduleId="scannerConfiguration">
+<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"/>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="specsFile">
+<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
+<buildOutputProvider>
+<openAction enabled="true" filePath=""/>
+<parser enabled="true"/>
+</buildOutputProvider>
+<scannerInfoProvider id="makefileGenerator">
+<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/>
+<parser enabled="true"/>
+</scannerInfoProvider>
+</profile>
+</storageModule>
+<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+<storageModule moduleId="org.eclipse.cdt.core.language.mapping"/>
+<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets">
+<buildTargets>
+<target name="All" path="elf" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
+<buildCommand>make</buildCommand>
+<buildArguments/>
+<buildTarget>all</buildTarget>
+<stopOnError>true</stopOnError>
+<useDefaultCommand>true</useDefaultCommand>
+<runAllBuilders>true</runAllBuilders>
+</target>
+<target name="Clean" path="elf" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
+<buildCommand>make</buildCommand>
+<buildArguments/>
+<buildTarget>clean</buildTarget>
+<stopOnError>true</stopOnError>
+<useDefaultCommand>true</useDefaultCommand>
+<runAllBuilders>true</runAllBuilders>
+</target>
+<target name="Test" path="elf" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
+<buildCommand>make</buildCommand>
+<buildArguments/>
+<buildTarget>test</buildTarget>
+<stopOnError>true</stopOnError>
+<useDefaultCommand>true</useDefaultCommand>
+<runAllBuilders>true</runAllBuilders>
+</target>
+<target name="Clean" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
+<buildCommand>make</buildCommand>
+<buildArguments/>
+<buildTarget>clean</buildTarget>
+<stopOnError>true</stopOnError>
+<useDefaultCommand>true</useDefaultCommand>
+<runAllBuilders>true</runAllBuilders>
+</target>
+<target name="Build" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
+<buildCommand>make</buildCommand>
+<buildArguments/>
+<buildTarget/>
+<stopOnError>true</stopOnError>
+<useDefaultCommand>true</useDefaultCommand>
+<runAllBuilders>true</runAllBuilders>
+</target>
+</buildTargets>
+</storageModule>
+</cconfiguration>
+</storageModule>
+<storageModule moduleId="cdtBuildSystem" version="4.0.0">
+<project id="SyslinuxELF.null.1852742557" name="SyslinuxELF"/>
+</storageModule>
+</cproject>
diff --git a/.project b/.project
new file mode 100644
index 00000000..ce7d5bdc
--- /dev/null
+++ b/.project
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>SyslinuxELF</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
+ <triggers>clean,full,incremental,</triggers>
+ <arguments>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.cleanBuildTarget</key>
+ <value>clean</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.enableCleanBuild</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>?name?</key>
+ <value></value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.append_environment</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.stopOnError</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.buildCommand</key>
+ <value>make</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.contents</key>
+ <value>org.eclipse.cdt.make.core.activeConfigSettings</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.enableAutoBuild</key>
+ <value>false</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.enableFullBuild</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.buildArguments</key>
+ <value></value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.fullBuildTarget</key>
+ <value>all</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.autoBuildTarget</key>
+ <value>all</value>
+ </dictionary>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
+ <nature>org.eclipse.cdt.core.cnature</nature>
+ </natures>
+</projectDescription>
diff --git a/elf/elf.h b/elf/elf.h
index eaa0f0c8..36186f74 100644
--- a/elf/elf.h
+++ b/elf/elf.h
@@ -3,6 +3,10 @@
#ifndef ELF_H_
#define ELF_H_
+
+////////////////////////////////////////////////////////////////////////////////
+// GENERAL ELF FORMAT DECLARATIONS
+
// ELF data types
typedef unsigned long Elf32_Addr;
typedef unsigned short Elf32_Half;
@@ -10,8 +14,37 @@ typedef unsigned long Elf32_Off;
typedef long Elf32_Sword;
typedef unsigned long Elf32_Word;
-// Size of the magic section
-#define EI_NIDENT 16
+
+////////////////////////////////////////////////////////////////////////////////
+// ELF HEADER DECLARATIONS
+
+// Relevant indices in the identification section
+enum e_ident_indices_enum {
+ // Magic indices
+ EI_MAG0 = 0,
+ EI_MAG1 = 1,
+ EI_MAG2 = 2,
+ EI_MAG3 = 3,
+
+ EI_CLASS = 4,
+ EI_DATA = 5,
+ EI_VERSION = 6,
+ EI_PAD = 7,
+ EI_NIDENT = 16 // Total size of the identification information
+};
+
+enum ei_class_enum {
+ ELFCLASSNONE = 0,
+ ELFCLASS32 = 1,
+ ELFCLASS64 = 2
+};
+
+enum ei_data_enum {
+ ELFDATANONE = 0,
+ ELFDATA2LSB = 1,
+ ELFDATA2MSB = 2
+};
+
// Object file types
enum e_type_enum {
@@ -43,7 +76,7 @@ enum e_version_enum {
// The ELF header
typedef struct {
- unsigned char e_ident[EI_NIDENT]; // Magic
+ unsigned char e_ident[EI_NIDENT]; // Identification
Elf32_Half e_type; // Object file type
Elf32_Half e_machine; // Machine type
Elf32_Word e_version; // Object file version
@@ -56,9 +89,96 @@ typedef struct {
Elf32_Half e_phnum; // Number of entries in PHT
Elf32_Half e_shentsize; // Size of an header in SHT
Elf32_Half e_shnum; // Number of entries in SHT
- Elf32_Half shstrndx; // Section name string table index
+ Elf32_Half e_shstrndx; // Section name string table index
} Elf32_Ehdr;
+////////////////////////////////////////////////////////////////////////////////
+// ELF SECTION DECLARATIONS
+
+// Special section indices
+enum sh_special_enum {
+ SHN_UNDEF = 0, // Undefined
+ SHN_LORESERVE = 0xFF00, // Lower index of reserved range
+ SHN_LOPROC = 0xFF00, // Processor specific semantics interval
+ SHN_HIPROC = 0xFF1F, // *
+ SHN_ABS = 0xFFF1, // Absolute values for the reference
+ SHN_COMMON = 0xFFF2, // Common symbols
+ SHN_HIRESERVE = 0xFFFF // Upper index of reserved range
+};
+
+// Section type
+enum sh_type_enum {
+ SHT_NULL = 0, // Inactive
+ SHT_PROGBITS = 1, // Program specific information
+ SHT_SYMTAB = 2, // Symbol table
+ SHT_STRTAB = 3, // String table
+ SHT_RELA = 4, // Relocation entries with explicit addends
+ SHT_HASH = 5, // Symbol hash table
+ SHT_DYNAMIC = 6, // Dynamic linking information
+ SHT_NOTE = 7, // Marking information
+ SHT_NOBITS = 8, // No space occupied
+ SHT_REL = 9, // Relocation entries w/o explicit addends
+ SHT_SHLIB = 10, // Reserved
+ SHT_DYNSYM = 11, // Symbol table
+ SHT_LOPROC = 0x70000000, // Processor specific semantics
+ SHT_HIPROC = 0x7FFFFFFF, // *
+ SHT_LOUSER = 0x80000000, // Application programs
+ SHT_HIUSER = 0xFFFFFFFF // *
+};
+
+// Section flags
+enum sh_flags_enum {
+ SHF_WRITE = 0x1, // Writable data
+ SHF_ALLOC = 0x2, // Section occupies memory during execution
+ SHF_EXECINSTR = 0x4, // Executable code
+ SHF_MASKPROC = 0xF0000000 // Processor specific semantics
+};
+
+// The section header
+typedef struct {
+ Elf32_Word sh_name; // Index into section header string table
+ Elf32_Word sh_type; // Section type and semantic
+ Elf32_Word sh_flags; // Section flags
+ Elf32_Addr sh_addr; // Address of the memory mapping (or 0)
+ Elf32_Off sh_offset; // Section location in the file
+ Elf32_Word sh_size; // Section size in the file
+ Elf32_Word sh_link; // Section header table index link
+ Elf32_Word sh_info; // Extra information
+ Elf32_Word sh_addralign; // Alignment constraint
+ Elf32_Word sh_entsize; // Entry size for table-like sections
+} Elf32_Shdr;
+
+
+////////////////////////////////////////////////////////////////////////////////
+// SYMBOL TABLE DECLARATIONS
+
+// Special symbol indices
+enum st_special_enum {
+ STN_UNDEF = 0 // Undefined symbol index
+};
+
+// Macros for manipulating a symbol table entry information field
+#define ELF32_ST_BIND(i) ((i) >> 4)
+#define ELF32_ST_TYPE(i) ((i) & 0xF)
+#define ELF32_ST_INFO(b,t) ((b) << 4) + ((t) & 0xF))
+
+enum st_bind_enum {
+ STB_LOCAL = 0,
+ STB_GLOBAL = 1,
+ STB_WEAK = 2,
+ STB_LOPROC = 13,
+ STB_HIPROC = 15
+};
+
+// Symbol table entry
+typedef struct {
+ Elf32_Word st_name; // Index in the name table
+ Elf32_Addr st_value; // Value associated with the symbol
+ Elf32_Word st_size; // Symbol data size
+ unsigned char st_info; // Type and binding attrs.
+ unsigned char st_other; // Reserved (zero)
+ Elf32_Half st_shndx; // Relevant section header table index
+} Elf32_Sym;
#endif /*ELF_H_*/
diff --git a/elf/elftest b/elf/elftest
new file mode 100755
index 00000000..7f8fcf18
--- /dev/null
+++ b/elf/elftest
Binary files differ
diff --git a/elf/elftest.c b/elf/elftest.c
index 154708d6..047537ed 100644
--- a/elf/elftest.c
+++ b/elf/elftest.c
@@ -40,7 +40,7 @@ void print_elf_info(const char *file_name) {
elf_header = (Elf32_Ehdr*)elf_addr;
- printf("Magic:\t\t");
+ printf("Identification:\t");
for (i=0; i < EI_NIDENT; i++) {
printf("%d ", elf_header->e_ident[i]);
}