From f93b60e21000184304ffe6075c39a606ebbcc31a Mon Sep 17 00:00:00 2001
From: Terraneo Federico <fede.tft@hotmail.it>
Date: Tue, 20 Mar 2012 16:50:37 +0100
Subject: [PATCH] Fixed relocations with pie, elf loader now part of the kernel

---
 Makefile                                      |  2 +-
 app_template/Makefile                         |  7 +--
 app_template/prog3.h                          | 43 ++++++++--------
 main.cpp                                      |  2 +-
 miosix/Makefile                               |  2 +
 miosix/config/miosix_settings.h               |  8 +++
 .../kernel/elf_program.cpp                    | 11 +++--
 elf_program.h => miosix/kernel/elf_program.h  | 13 ++++-
 elf_types.h => miosix/kernel/elf_types.h      | 13 ++++-
 miosix/kernel/kernel.cpp                      |  2 +-
 miosix/kernel/kernel.h                        |  2 +-
 miosix/kernel/process.cpp                     | 37 ++++++++++++++
 miosix/kernel/process.h                       | 49 +++++++++++++++++++
 prog1.h                                       | 36 --------------
 prog2.h                                       | 29 -----------
 test_driver.cpp                               | 26 ----------
 16 files changed, 153 insertions(+), 129 deletions(-)
 rename elf_program.cpp => miosix/kernel/elf_program.cpp (98%)
 rename elf_program.h => miosix/kernel/elf_program.h (97%)
 rename elf_types.h => miosix/kernel/elf_types.h (98%)
 create mode 100644 miosix/kernel/process.cpp
 create mode 100644 miosix/kernel/process.h
 delete mode 100644 prog1.h
 delete mode 100644 prog2.h
 delete mode 100644 test_driver.cpp

diff --git a/Makefile b/Makefile
index 30fe556e..6c8092c3 100644
--- a/Makefile
+++ b/Makefile
@@ -14,7 +14,7 @@ SUBDIRS := miosix
 ## List here your source files (both .s, .c and .cpp)
 ##
 SRC :=                                  \
-main.cpp elf_program.cpp
+main.cpp
 
 ##
 ## List here additional static libraries with relative path
diff --git a/app_template/Makefile b/app_template/Makefile
index dd38e874..4cdbdbab 100644
--- a/app_template/Makefile
+++ b/app_template/Makefile
@@ -15,10 +15,10 @@ CXX := arm-miosix-eabi-g++
 SZ  := arm-miosix-eabi-size
 
 AFLAGS   := -mcpu=cortex-m3 -mthumb
-CFLAGS   := -mcpu=cortex-m3 -mthumb -mfix-cortex-m3-ldrd -fpic -msingle-pic-base \
+CFLAGS   := -mcpu=cortex-m3 -mthumb -mfix-cortex-m3-ldrd -fpie -msingle-pic-base \
             -ffunction-sections -O2 -Wall -c
 CXXFLAGS := $(CFLAGS)
-LFLAGS   := -mcpu=cortex-m3 -mthumb -mfix-cortex-m3-ldrd -fpic -msingle-pic-base \
+LFLAGS   := -mcpu=cortex-m3 -mthumb -mfix-cortex-m3-ldrd -fpie -msingle-pic-base \
             -Wl,--gc-sections,-Map,main.map,-T./miosix.ld,-n,-pie -O2 -nostdlib
 
 LINK_LIBS := -Wl,--start-group -lstdc++ -lc -lm -lgcc -Wl,--end-group
@@ -26,11 +26,12 @@ LINK_LIBS := -Wl,--start-group -lstdc++ -lc -lm -lgcc -Wl,--end-group
 all: $(OBJ) crt0.o
 	$(CXX) $(LFLAGS) -o main.elf $(OBJ) crt0.o $(LINK_LIBS)
 	$(SZ)  main.elf
+	@arm-miosix-eabi-objdump -Dslx main.elf > main.txt
 	@perl finalstage.pl main.elf --strip-sectheader
 	@xxd -i main.elf | sed 's/unsigned char/const unsigned char __attribute__((aligned(8)))/' > prog3.h
 
 clean:
-	-rm $(OBJ) crt0.o main.elf main.map
+	-rm $(OBJ) crt0.o main.elf main.map main.txt
 
 %.o: %.s
 	$(AS) $(AFLAGS) $< -o $@
diff --git a/app_template/prog3.h b/app_template/prog3.h
index 8bf2457d..a3181498 100644
--- a/app_template/prog3.h
+++ b/app_template/prog3.h
@@ -4,33 +4,30 @@ const unsigned char __attribute__((aligned(8))) main_elf[] = {
   0x99, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x02, 0x00, 0x00, 0x05, 0x34, 0x00, 0x20, 0x00, 0x03, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x98, 0x00, 0x00, 0x00,
-  0x98, 0x00, 0x00, 0x00, 0x98, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00,
-  0x78, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
-  0x01, 0x00, 0x00, 0x00, 0x10, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
-  0x00, 0x00, 0x00, 0x10, 0x7c, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00,
+  0x98, 0x00, 0x00, 0x00, 0x98, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00,
+  0x54, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
+  0x01, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
+  0x00, 0x00, 0x00, 0x10, 0x74, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00,
   0x06, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
-  0x24, 0x01, 0x00, 0x00, 0x14, 0x00, 0x00, 0x10, 0x14, 0x00, 0x00, 0x10,
+  0xfc, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x10, 0x0c, 0x00, 0x00, 0x10,
   0x50, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
-  0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x0c, 0xf8,
-  0x00, 0xf0, 0x26, 0xf8, 0x03, 0x78, 0x23, 0xb1, 0x00, 0x23, 0x01, 0x33,
-  0xc2, 0x5c, 0x00, 0x2a, 0xfb, 0xd1, 0x18, 0x46, 0x70, 0x47, 0x00, 0xbf,
-  0x10, 0xb5, 0x0a, 0x4c, 0x4c, 0x44, 0x20, 0x46, 0xff, 0xf7, 0xf0, 0xff,
-  0x21, 0x46, 0x02, 0x46, 0x01, 0x20, 0x00, 0xf0, 0x13, 0xf8, 0x06, 0x4b,
-  0x06, 0x4a, 0x59, 0xf8, 0x03, 0x30, 0x59, 0xf8, 0x02, 0x20, 0x1b, 0x68,
-  0x10, 0x60, 0x18, 0x68, 0x10, 0xbd, 0x00, 0xbf, 0x68, 0x00, 0x00, 0x00,
-  0x0c, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x23, 0x00, 0xdf,
-  0x02, 0x23, 0x00, 0xdf, 0x70, 0x47, 0x00, 0x00, 0x78, 0x00, 0x00, 0x10,
-  0x02, 0x04, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x10, 0x17, 0x00, 0x00, 0x00,
-  0x10, 0x00, 0x00, 0x10, 0x17, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x10,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x10,
-  0x80, 0x00, 0x00, 0x10, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x11, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00,
-  0x18, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
+  0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x02, 0xf8,
+  0x00, 0xf0, 0x1c, 0xf8, 0x0a, 0x49, 0x08, 0xb5, 0x00, 0x22, 0x09, 0xeb,
+  0x01, 0x03, 0x13, 0xf8, 0x01, 0x0f, 0x01, 0x32, 0x00, 0x28, 0xfa, 0xd1,
+  0x49, 0x44, 0x01, 0x20, 0x00, 0xf0, 0x10, 0xf8, 0x04, 0x4b, 0x05, 0x4a,
+  0x59, 0xf8, 0x03, 0x30, 0x49, 0xf8, 0x02, 0x00, 0x18, 0x68, 0x08, 0xbd,
+  0x60, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00,
+  0x01, 0x23, 0x00, 0xdf, 0x02, 0x23, 0x00, 0xdf, 0x70, 0x47, 0x00, 0x00,
+  0x70, 0x00, 0x00, 0x10, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+  0x0c, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+  0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00,
+  0xe4, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
+  0x13, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x77, 0x6f,
-  0x72, 0x6c, 0x64, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+  0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x0a,
+  0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x10
 };
-unsigned int main_elf_len = 396;
+unsigned int main_elf_len = 356;
diff --git a/main.cpp b/main.cpp
index c9ec82b9..ebb358ad 100644
--- a/main.cpp
+++ b/main.cpp
@@ -2,7 +2,7 @@
 #include <cstdio>
 #include <cassert>
 #include "miosix.h"
-#include "elf_program.h"
+#include "kernel/elf_program.h"
 #include "app_template/prog3.h"
 
 using namespace std;
diff --git a/miosix/Makefile b/miosix/Makefile
index 99dcedb8..78f53e7e 100644
--- a/miosix/Makefile
+++ b/miosix/Makefile
@@ -17,6 +17,8 @@ kernel/pthread.cpp                                                         \
 kernel/unistd.cpp                                                          \
 kernel/stage_2_boot.cpp                                                    \
 kernel/syscalls.cpp                                                        \
+kernel/elf_program.cpp                                                     \
+kernel/process.cpp                                                         \
 kernel/scheduler/priority/priority_scheduler.cpp                           \
 kernel/scheduler/control/control_scheduler.cpp                             \
 kernel/scheduler/edf/edf_scheduler.cpp                                     \
diff --git a/miosix/config/miosix_settings.h b/miosix/config/miosix_settings.h
index 766971c8..f764a3cd 100644
--- a/miosix/config/miosix_settings.h
+++ b/miosix/config/miosix_settings.h
@@ -69,6 +69,14 @@ namespace miosix {
 /// isolation of processes
 #define WITH_PROCESSES
 
+/// Maximum size of the RAM image of a process. If a program requires more
+/// the kernel will not run it
+const int MAX_PROCESS_IMAGE_SIZE=20*1024;
+
+/// Minimum size of the stack for a process. If a program specifies a lower
+/// size the kernel will not run it
+const int MIN_PROCESS_STACK_SIZE=2*1024;
+
 //
 // Filesystem options
 //
diff --git a/elf_program.cpp b/miosix/kernel/elf_program.cpp
similarity index 98%
rename from elf_program.cpp
rename to miosix/kernel/elf_program.cpp
index 4b21a33a..3a52c0f5 100644
--- a/elf_program.cpp
+++ b/miosix/kernel/elf_program.cpp
@@ -32,11 +32,11 @@
 
 using namespace std;
 
-//FIXME: move in miosix_config.h
-static const int MAX_PROCESS_IMAGE_SIZE=20*1024;
-static const int MIN_PROCESS_STACK_SIZE=2*1024;
+#ifdef WITH_PROCESSES
 
-///\internal Enable/disable debugging
+namespace miosix {
+
+///\internal Enable/disable debugging of program loading
 #define DBG iprintf
 //#define DBG(x,...) ;
 
@@ -294,3 +294,6 @@ ProcessImage::~ProcessImage()
     if(image) delete[] image;
 }
 
+} //namespace miosix
+
+#endif //WITH_PROCESSES
diff --git a/elf_program.h b/miosix/kernel/elf_program.h
similarity index 97%
rename from elf_program.h
rename to miosix/kernel/elf_program.h
index 0dcb4eb1..87e3d116 100644
--- a/elf_program.h
+++ b/miosix/kernel/elf_program.h
@@ -25,11 +25,16 @@
  *   along with this program; if not, see <http://www.gnu.org/licenses/>   *
  ***************************************************************************/
 
+#ifndef ELF_PROGRAM_H
+#define	ELF_PROGRAM_H
+
 #include <utility>
 #include "elf_types.h"
+#include "config/miosix_settings.h"
 
-#ifndef ELF_PROGRAM_H
-#define	ELF_PROGRAM_H
+#ifdef WITH_PROCESSES
+
+namespace miosix {
 
 /**
  * This class represents an elf file.
@@ -157,4 +162,8 @@ private:
     unsigned int size;   //Size of the process image
 };
 
+} //namespace miosix
+
+#endif //WITH_PROCESSES
+
 #endif //ELF_PROGRAM_H
diff --git a/elf_types.h b/miosix/kernel/elf_types.h
similarity index 98%
rename from elf_types.h
rename to miosix/kernel/elf_types.h
index 126c7e41..44813c73 100644
--- a/elf_types.h
+++ b/miosix/kernel/elf_types.h
@@ -25,11 +25,16 @@
  *   along with this program; if not, see <http://www.gnu.org/licenses/>   *
  ***************************************************************************/
 
-#include <inttypes.h>
-
 #ifndef ELF_TYPES_H
 #define	ELF_TYPES_H
 
+#include <inttypes.h>
+#include "config/miosix_settings.h"
+
+#ifdef WITH_PROCESSES
+
+namespace miosix {
+
 // elf-specific types
 typedef uint32_t Elf32_Word;
 typedef int32_t  Elf32_Sword;
@@ -163,4 +168,8 @@ static const unsigned char R_ARM_NONE     = 0;
 static const unsigned char R_ARM_ABS32    = 2;
 static const unsigned char R_ARM_RELATIVE = 23;
 
+} //namespace miosix
+
+#endif //WITH_PROCESSES
+
 #endif //ELF_TYPES_H
diff --git a/miosix/kernel/kernel.cpp b/miosix/kernel/kernel.cpp
index 9d0f4ba1..60206d9a 100644
--- a/miosix/kernel/kernel.cpp
+++ b/miosix/kernel/kernel.cpp
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2008, 2009, 2010, 2011 by Terraneo Federico             *
+ *   Copyright (C) 2008, 2009, 2010, 2011, 2012 by Terraneo Federico       *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
diff --git a/miosix/kernel/kernel.h b/miosix/kernel/kernel.h
index 27653175..09a7174b 100644
--- a/miosix/kernel/kernel.h
+++ b/miosix/kernel/kernel.h
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2008, 2009, 2010, 2011 by Terraneo Federico             *
+ *   Copyright (C) 2008, 2009, 2010, 2011, 2012 by Terraneo Federico       *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
diff --git a/miosix/kernel/process.cpp b/miosix/kernel/process.cpp
new file mode 100644
index 00000000..b98de8b1
--- /dev/null
+++ b/miosix/kernel/process.cpp
@@ -0,0 +1,37 @@
+/***************************************************************************
+ *   Copyright (C) 2012 by Terraneo Federico                               *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   As a special exception, if other files instantiate templates or use   *
+ *   macros or inline functions from this file, or you compile this file   *
+ *   and link it with other works to produce a work based on this file,    *
+ *   this file does not by itself cause the resulting work to be covered   *
+ *   by the GNU General Public License. However the source code for this   *
+ *   file must still be made available in accordance with the GNU General  *
+ *   Public License. This exception does not invalidate any other reasons  *
+ *   why a work based on this file might be covered by the GNU General     *
+ *   Public License.                                                       *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, see <http://www.gnu.org/licenses/>   *
+ ***************************************************************************/
+
+#include "process.h"
+
+#ifdef WITH_PROCESSES
+
+namespace miosix {
+    
+    
+} //namespace miosix
+
+#endif //WITH_PROCESSES
diff --git a/miosix/kernel/process.h b/miosix/kernel/process.h
new file mode 100644
index 00000000..4003fd8a
--- /dev/null
+++ b/miosix/kernel/process.h
@@ -0,0 +1,49 @@
+/***************************************************************************
+ *   Copyright (C) 2012 by Terraneo Federico                               *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   As a special exception, if other files instantiate templates or use   *
+ *   macros or inline functions from this file, or you compile this file   *
+ *   and link it with other works to produce a work based on this file,    *
+ *   this file does not by itself cause the resulting work to be covered   *
+ *   by the GNU General Public License. However the source code for this   *
+ *   file must still be made available in accordance with the GNU General  *
+ *   Public License. This exception does not invalidate any other reasons  *
+ *   why a work based on this file might be covered by the GNU General     *
+ *   Public License.                                                       *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, see <http://www.gnu.org/licenses/>   *
+ ***************************************************************************/ 
+
+#ifndef PROCESS_H
+#define	PROCESS_H
+
+#include "config/miosix_settings.h"
+
+#ifdef WITH_PROCESSES
+
+namespace miosix {
+
+class Process
+{
+public:
+    
+private:
+
+};
+
+} //namespace miosix
+
+#endif WITH_PROCESSES
+
+#endif //PROCESS_H
diff --git a/prog1.h b/prog1.h
deleted file mode 100644
index b993810f..00000000
--- a/prog1.h
+++ /dev/null
@@ -1,36 +0,0 @@
-const unsigned char __attribute__((aligned(8))) main_elf[] = {
-  0x7f, 0x45, 0x4c, 0x46, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x28, 0x00, 0x01, 0x00, 0x00, 0x00,
-  0x99, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x02, 0x00, 0x00, 0x05, 0x34, 0x00, 0x20, 0x00, 0x03, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x98, 0x00, 0x00, 0x00,
-  0x98, 0x00, 0x00, 0x00, 0x98, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00,
-  0x78, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
-  0x01, 0x00, 0x00, 0x00, 0x10, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
-  0x00, 0x00, 0x00, 0x10, 0x7c, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00,
-  0x06, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
-  0x24, 0x01, 0x00, 0x00, 0x14, 0x00, 0x00, 0x10, 0x14, 0x00, 0x00, 0x10,
-  0x50, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
-  0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x0c, 0xf8,
-  0x00, 0xf0, 0x26, 0xf8, 0x03, 0x78, 0x23, 0xb1, 0x00, 0x23, 0x01, 0x33,
-  0xc2, 0x5c, 0x00, 0x2a, 0xfb, 0xd1, 0x18, 0x46, 0x70, 0x47, 0x00, 0xbf,
-  0x10, 0xb5, 0x0a, 0x4c, 0x4c, 0x44, 0x20, 0x46, 0xff, 0xf7, 0xf0, 0xff,
-  0x21, 0x46, 0x02, 0x46, 0x01, 0x20, 0x00, 0xf0, 0x13, 0xf8, 0x06, 0x4b,
-  0x06, 0x4a, 0x59, 0xf8, 0x03, 0x30, 0x59, 0xf8, 0x02, 0x20, 0x1b, 0x68,
-  0x10, 0x60, 0x18, 0x68, 0x10, 0xbd, 0x00, 0xbf, 0x68, 0x00, 0x00, 0x00,
-  0x10, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x23, 0x00, 0xdf,
-  0x02, 0x23, 0x00, 0xdf, 0x70, 0x47, 0x00, 0x00, 0x78, 0x00, 0x00, 0x10,
-  0x02, 0x03, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x10, 0x17, 0x00, 0x00, 0x00,
-  0x10, 0x00, 0x00, 0x10, 0x17, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x10,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x10,
-  0x78, 0x00, 0x00, 0x10, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x11, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00,
-  0x18, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x77, 0x6f,
-  0x72, 0x6c, 0x64, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
-};
-unsigned int main_elf_len = 396;
diff --git a/prog2.h b/prog2.h
deleted file mode 100644
index 56764344..00000000
--- a/prog2.h
+++ /dev/null
@@ -1,29 +0,0 @@
-const unsigned char __attribute__((aligned(8))) main_elf[] = {
-  0x7f, 0x45, 0x4c, 0x46, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x28, 0x00, 0x01, 0x00, 0x00, 0x00,
-  0x99, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x02, 0x00, 0x00, 0x05, 0x34, 0x00, 0x20, 0x00, 0x03, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x98, 0x00, 0x00, 0x00,
-  0x98, 0x00, 0x00, 0x00, 0x98, 0x00, 0x00, 0x00, 0x46, 0x00, 0x00, 0x00,
-  0x46, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
-  0x01, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
-  0x00, 0x00, 0x00, 0x10, 0x58, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00,
-  0x06, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
-  0xec, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x10, 0x0c, 0x00, 0x00, 0x10,
-  0x38, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
-  0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x0c, 0xf8,
-  0x00, 0xf0, 0x1a, 0xf8, 0x03, 0x78, 0x23, 0xb1, 0x00, 0x23, 0x01, 0x33,
-  0xc2, 0x5c, 0x00, 0x2a, 0xfb, 0xd1, 0x18, 0x46, 0x70, 0x47, 0x00, 0xbf,
-  0x10, 0xb5, 0x06, 0x4c, 0x4c, 0x44, 0x20, 0x46, 0xff, 0xf7, 0xf0, 0xff,
-  0x21, 0x46, 0x02, 0x46, 0x01, 0x20, 0x00, 0xf0, 0x07, 0xf8, 0x00, 0x20,
-  0x10, 0xbd, 0x00, 0xbf, 0x48, 0x00, 0x00, 0x00, 0x01, 0x23, 0x00, 0xdf,
-  0x02, 0x23, 0x00, 0xdf, 0x70, 0x47, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x10,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x65, 0x6c, 0x6c,
-  0x6f, 0x20, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x0a, 0x00, 0x00, 0x00, 0x00
-};
-unsigned int main_elf_len = 312;
diff --git a/test_driver.cpp b/test_driver.cpp
deleted file mode 100644
index 33ce1737..00000000
--- a/test_driver.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-
-#include <iostream>
-#include <fstream>
-#include "elf_program.h"
-
-using namespace std;
-
-int main()
-{
-    ifstream in("example.elf",ios::binary);
-    if(!in.good()) return 1;
-    in.seekg(0,ios::end);
-    const int size=in.tellg();
-    in.seekg(0,ios::beg);
-    const int alignedSize=(size+3) & ~3;
-    unsigned int *elfFileData=new unsigned int[alignedSize/4];
-    in.read(reinterpret_cast<char*>(elfFileData),size);
-
-    ElfProgram program(elfFileData,size);
-    cout<<"Elf info:"<<endl
-        <<"base address = "<<elfFileData<<endl
-        <<"entry (file relative) = "<<program.getElfHeader()->e_entry<<endl
-        <<"entry (relocated) = "<<program.getEntryPoint()<<endl;
-    ProcessImage pi;
-    pi.load(program);
-}
-- 
GitLab