remove the assumption that game is ran from cwd at root
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
#include "twn_elf.h"
|
||||
#include "twn_game_object_c.h"
|
||||
#include "twn_engine_context_c.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
@ -9,6 +10,8 @@
|
||||
#define __USE_GNU
|
||||
#include <dlfcn.h>
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -33,7 +36,8 @@ bool infer_elf_section_bounds(const char *const restrict name,
|
||||
} else {
|
||||
/* dynamically linked */
|
||||
from_shared_object = true;
|
||||
memcpy(buf, "libgame.so", sizeof "libgame.so");
|
||||
if (SDL_snprintf(buf, sizeof buf, "%s%s", ctx.base_dir, "libgame.so") < 0)
|
||||
goto ERR_CANT_APPEND_BASE_PATH;
|
||||
}
|
||||
|
||||
int elf = open(buf, O_RDONLY);
|
||||
@ -84,6 +88,7 @@ ERR_NOT_ELF:
|
||||
close(elf);
|
||||
|
||||
ERR_CANT_OPEN_SELF:
|
||||
ERR_CANT_APPEND_BASE_PATH:
|
||||
ERR_CANT_READLINK:
|
||||
return result;
|
||||
}
|
||||
|
Reference in New Issue
Block a user