MemPharos is a collection of custom user-space memory pagers for ELF binaries on Linux systems. This project implements different memory paging strategies for loading and executing ELF binaries, providing insights into memory management and paging mechanisms.
This project demonstrates several implementations of memory pagers:
- APager: Basic ELF loader that maps segments into memory
- DPager: Demand paging implementation with SIGSEGV handling for lazy loading
- HPager: Hybrid paging approach
Each pager implements different strategies for memory allocation, stack setup, and execution of ELF binaries, showcasing various aspects of user-space memory management.
The repository includes several test programs to demonstrate the pagers in action:
hello_world.c: Simple "Hello World" programadding_nums.c: Basic arithmetic operationsnull.c: NULL pointer handlingdata.c: Data manipulation examplecrazy_manipulation.c: More complex data manipulationslongstring_longmath.c: String and mathematical operationsextreme_page_faulting.c: Test case for page fault handling
Use the provided Makefile to build all pagers and test programs:
makeTo run a test program with a specific pager:
./apager hello_world
./dpager adding_nums
./hpager dataTo clean up compiled binaries:
make cleanThese pagers demonstrate various memory management techniques:
- ELF Binary Loading: Parsing and loading ELF headers and program segments
- Stack Management: Setting up the stack with proper alignment and layout for program execution
- Signal Handling: Intercepting page faults for demand paging
- Memory Mapping: Using mmap/munmap for segment allocation and deallocation
- Linux operating system
- GCC compiler