diff --git a/Makefile b/Makefile index 30fe556eed04564ce892d67ca5566e8a576ff9ca..6c8092c395ce60ea16c806f71d2a1011ae067d4a 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 dd38e874d9c142289fa8f6abf7d23b1e0bd7a856..4cdbdbab559409d5dbaa28bdcccac2c97744bc40 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 8bf2457df8f5772794dc314b8f21138eef2c8418..a31814986fe65fef4e5959d3df595f0b66de2059 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 c9ec82b97fd3aa92ba96379c1453a6f9176d530e..ebb358ad759dae1c80a79473b498f8d399dd3f7e 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 99dcedb8b24303825cef4b723d6dd676bb6c0a3e..78f53e7e9a4a4f0829669e32865fac0c785dce07 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 766971c833df84e327f9f527bda691b8f0cac101..f764a3cdec62d725671f995cd3c884cd23aa6632 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 4b21a33ad73f366278888d20358a874482471b75..3a52c0f5e60509e2797cb3302aac1c865928d32c 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 0dcb4eb142806c8766835a343214650dd2e7e969..87e3d116a570552d13c6a87e6307af348e1459ad 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 126c7e41bd1fd72fa039ac1694130195749eb405..44813c73beae2269696c9db925a6493253fdff52 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 9d0f4ba1927b49442ee76347dbf0caa2930d9fd3..60206d9a9d8f7d7fd8a432de6f76ead83a6a7593 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 27653175ecefea0a1a3a936f0dc70eec66a82d97..09a7174b900d0864f171105a25d8a326c3bd9e09 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 0000000000000000000000000000000000000000..b98de8b1f16b6562b41a626088a772dd209a75ba --- /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 0000000000000000000000000000000000000000..4003fd8a87dcb9d41b001db8fba4ee33d8b16a8d --- /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 b993810f85b4d1cd867557f9cc4dbda4c16cb08b..0000000000000000000000000000000000000000 --- 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 56764344f49790935a47f8fd8494025d8cfe879b..0000000000000000000000000000000000000000 --- 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 33ce17376ac524b642233e6bd4a286df972c537e..0000000000000000000000000000000000000000 --- 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); -}