mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 13:07:46 +00:00
Implement loading of linked ELF executables.
This took me a couple hours. :^) The ELF loading code now allocates a single region for the entire file and creates virtual memory mappings for the sections as needed. Very nice!
This commit is contained in:
parent
99ee6acd69
commit
9a71c7759a
16 changed files with 258 additions and 57 deletions
|
@ -1,21 +1,24 @@
|
|||
#include <LibC/stdio.h>
|
||||
#include <LibC/unistd.h>
|
||||
#include <LibC/dirent.h>
|
||||
#include <LibC/errno.h>
|
||||
#include <LibC/string.h>
|
||||
|
||||
int main(int c, char** v)
|
||||
{
|
||||
DIR* dirp = opendir(".");
|
||||
if (!dirp) {
|
||||
printf("opendir failed :(\n");
|
||||
perror("opendir failed");
|
||||
return 1;
|
||||
}
|
||||
char pathbuf[256];
|
||||
while (auto* de = readdir(dirp)) {
|
||||
sprintf(pathbuf, "%s", de->d_name);
|
||||
|
||||
stat st;
|
||||
int rc = lstat(pathbuf, &st);
|
||||
if (rc == -1) {
|
||||
printf("Failed to stat '%s'\n", pathbuf);
|
||||
printf("lstat(%s) failed: %s\n", pathbuf, strerror(errno));
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue