Once libroot's getenv() is available, that one will be used instead of the one built in.
This makes the runtime_loader able to adopt path changes properly. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17380 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
e77acd698a
commit
9a6bbd514e
@ -60,7 +60,7 @@ Objects
|
||||
elf.c
|
||||
export.c
|
||||
heap.c
|
||||
utility.c
|
||||
utility.cpp
|
||||
arch_relocate.c
|
||||
arch_call_init_term.c
|
||||
;
|
||||
|
@ -1199,6 +1199,14 @@ load_program(char const *path, void **_entry)
|
||||
remap_images();
|
||||
// ToDo: once setup_system_time() is fixed, move this one line higher!
|
||||
|
||||
// Since the images are initialized now, we no longer should use our
|
||||
// getenv(), but use the one from libroot.so
|
||||
{
|
||||
struct Elf32_Sym *symbol = find_symbol_in_loaded_images(&image, "getenv");
|
||||
if (symbol != NULL)
|
||||
gGetEnv = (void *)(symbol->st_value + image->regions[0].delta);
|
||||
}
|
||||
|
||||
if (sProgramImage->entry_point == NULL) {
|
||||
status = B_NOT_AN_EXECUTABLE;
|
||||
goto err;
|
||||
|
@ -13,6 +13,15 @@
|
||||
#include <runtime_loader.h>
|
||||
|
||||
|
||||
extern struct uspace_program_args *gProgramArgs;
|
||||
extern struct rld_export gRuntimeLoader;
|
||||
extern char *(*gGetEnv)(const char *name);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int runtime_loader(void *arg);
|
||||
int open_executable(char *name, image_type type, const char *rpath);
|
||||
status_t test_executable(const char *path, uid_t user, gid_t group, char *starter);
|
||||
@ -42,7 +51,8 @@ status_t arch_relocate_image(image_t *image);
|
||||
void arch_call_init(image_t *image);
|
||||
void arch_call_term(image_t *image);
|
||||
|
||||
extern struct uspace_program_args *gProgramArgs;
|
||||
extern struct rld_export gRuntimeLoader;
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* RUNTIME_LOADER_H */
|
||||
|
@ -9,17 +9,26 @@
|
||||
|
||||
#include "runtime_loader_private.h"
|
||||
|
||||
#include <syscalls.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <syscalls.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
char *
|
||||
char *(*gGetEnv)(const char *name) = NULL;
|
||||
|
||||
|
||||
extern "C" char *
|
||||
getenv(const char *name)
|
||||
{
|
||||
// ToDo: this should use the real environ pointer once available!
|
||||
// (or else, any updates to the search paths while the app is running are ignored)
|
||||
if (gGetEnv != NULL) {
|
||||
// Use libroot's getenv() as soon as it is available to us - the environment
|
||||
// in gProgramArgs is static.
|
||||
return gGetEnv(name);
|
||||
}
|
||||
|
||||
char **environ = gProgramArgs->envp;
|
||||
int32 length = strlen(name);
|
||||
int32 i;
|
||||
@ -33,18 +42,17 @@ getenv(const char *name)
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
printf(const char *fmt, ...)
|
||||
extern "C" int
|
||||
printf(const char *format, ...)
|
||||
{
|
||||
char buffer[1024];
|
||||
va_list args;
|
||||
char buf[1024];
|
||||
int i;
|
||||
|
||||
va_start(args, fmt);
|
||||
i = vsprintf(buf, fmt, args);
|
||||
va_start(args, format);
|
||||
int length = vsprintf(buffer, format, args);
|
||||
va_end(args);
|
||||
|
||||
_kern_write(2, 0, buf, strlen(buf));
|
||||
_kern_write(STDERR_FILENO, 0, buffer, length);
|
||||
|
||||
return i;
|
||||
return length;
|
||||
}
|
Loading…
Reference in New Issue
Block a user