mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 15:22:43 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			24 lines
		
	
	
	
		
			481 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			24 lines
		
	
	
	
		
			481 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| #include "ExecSpace.h"
 | |
| #include <cstdio>
 | |
| 
 | |
| typedef int (*MainFunctionPtr)(void);
 | |
| 
 | |
| int main(int, char**)
 | |
| {
 | |
|     MappedFile f("_test.o");
 | |
|     if (!f.isValid()) {
 | |
|         fprintf(stderr, "Failed to map file :(\n");
 | |
|         return 1;
 | |
|     }
 | |
| 
 | |
|     ExecSpace space;
 | |
|     space.loadELF(std::move(f));
 | |
| 
 | |
|     auto func = reinterpret_cast<MainFunctionPtr>(space.symbolPtr("EntryPoint"));
 | |
|     printf("func: %p\n", func);
 | |
| 
 | |
|     int z = func();
 | |
|     printf("func() returned %d\n", z);
 | |
| 
 | |
|     return 0;
 | |
| }
 | 
