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:
@@ -60,7 +60,7 @@ Objects
|
|||||||
elf.c
|
elf.c
|
||||||
export.c
|
export.c
|
||||||
heap.c
|
heap.c
|
||||||
utility.c
|
utility.cpp
|
||||||
arch_relocate.c
|
arch_relocate.c
|
||||||
arch_call_init_term.c
|
arch_call_init_term.c
|
||||||
;
|
;
|
||||||
|
|||||||
@@ -1199,6 +1199,14 @@ load_program(char const *path, void **_entry)
|
|||||||
remap_images();
|
remap_images();
|
||||||
// ToDo: once setup_system_time() is fixed, move this one line higher!
|
// 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) {
|
if (sProgramImage->entry_point == NULL) {
|
||||||
status = B_NOT_AN_EXECUTABLE;
|
status = B_NOT_AN_EXECUTABLE;
|
||||||
goto err;
|
goto err;
|
||||||
|
|||||||
@@ -13,6 +13,15 @@
|
|||||||
#include <runtime_loader.h>
|
#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 runtime_loader(void *arg);
|
||||||
int open_executable(char *name, image_type type, const char *rpath);
|
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);
|
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_init(image_t *image);
|
||||||
void arch_call_term(image_t *image);
|
void arch_call_term(image_t *image);
|
||||||
|
|
||||||
extern struct uspace_program_args *gProgramArgs;
|
#ifdef __cplusplus
|
||||||
extern struct rld_export gRuntimeLoader;
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* RUNTIME_LOADER_H */
|
#endif /* RUNTIME_LOADER_H */
|
||||||
|
|||||||
@@ -9,17 +9,26 @@
|
|||||||
|
|
||||||
#include "runtime_loader_private.h"
|
#include "runtime_loader_private.h"
|
||||||
|
|
||||||
|
#include <syscalls.h>
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <syscalls.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
|
||||||
char *
|
char *(*gGetEnv)(const char *name) = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
extern "C" char *
|
||||||
getenv(const char *name)
|
getenv(const char *name)
|
||||||
{
|
{
|
||||||
// ToDo: this should use the real environ pointer once available!
|
if (gGetEnv != NULL) {
|
||||||
// (or else, any updates to the search paths while the app is running are ignored)
|
// 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;
|
char **environ = gProgramArgs->envp;
|
||||||
int32 length = strlen(name);
|
int32 length = strlen(name);
|
||||||
int32 i;
|
int32 i;
|
||||||
@@ -33,18 +42,17 @@ getenv(const char *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
extern "C" int
|
||||||
printf(const char *fmt, ...)
|
printf(const char *format, ...)
|
||||||
{
|
{
|
||||||
|
char buffer[1024];
|
||||||
va_list args;
|
va_list args;
|
||||||
char buf[1024];
|
|
||||||
int i;
|
|
||||||
|
|
||||||
va_start(args, fmt);
|
va_start(args, format);
|
||||||
i = vsprintf(buf, fmt, args);
|
int length = vsprintf(buffer, format, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
_kern_write(2, 0, buf, strlen(buf));
|
_kern_write(STDERR_FILENO, 0, buffer, length);
|
||||||
|
|
||||||
return i;
|
return length;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user