Made our glue code compatible to BeOS again. IOW executables compiled for Haiku will
now run under BeOS as well (as long as they don't use any functions that are not available under R5). The solution is a bit messy, but we have to live with it :-) The runtime loader now patches the __gRuntimeLoader symbol in libroot.so to point to its exported structure instead of passing it to the init functions as an argument. (Hax0red by axeld and bonefish on stippi's assimilated machine -- resistence is futile) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15848 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2005, Axel Dörfler, [email protected].
|
||||
* Copyright 2003-2006, Axel Dörfler, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
@@ -7,11 +7,16 @@
|
||||
#include <libroot_private.h>
|
||||
#include <user_runtime.h>
|
||||
#include <fork.h>
|
||||
#include <image.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
void initialize_before(image_id imageID, struct uspace_program_args const *args);
|
||||
void initialize_before(image_id imageID);
|
||||
|
||||
struct rld_export *__gRuntimeLoader = NULL;
|
||||
// This little bugger is set to something meaningful by the runtime loader
|
||||
// Ugly, eh?
|
||||
|
||||
char *__progname = NULL;
|
||||
int __libc_argc;
|
||||
@@ -30,9 +35,9 @@ int _data_offset_main_;
|
||||
|
||||
|
||||
void
|
||||
initialize_before(image_id imageID, struct uspace_program_args const *args)
|
||||
initialize_before(image_id imageID)
|
||||
{
|
||||
char *programPath = args->argv[0];
|
||||
char *programPath = __gRuntimeLoader->program_args->argv[0];
|
||||
if (programPath) {
|
||||
if ((__progname = strrchr(programPath, '/')) == NULL)
|
||||
__progname = programPath;
|
||||
@@ -40,15 +45,13 @@ initialize_before(image_id imageID, struct uspace_program_args const *args)
|
||||
__progname++;
|
||||
}
|
||||
|
||||
__libc_argc = args->argc;
|
||||
__libc_argv = args->argv;
|
||||
__libc_argc = __gRuntimeLoader->program_args->argc;
|
||||
__libc_argv = __gRuntimeLoader->program_args->argv;
|
||||
|
||||
__init_time();
|
||||
__init_image(args);
|
||||
__init_dlfcn(args);
|
||||
__init_fork();
|
||||
__init_heap();
|
||||
__init_env(args);
|
||||
__init_env(__gRuntimeLoader->program_args);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2005, Axel Dörfler, [email protected]. All rights reserved.
|
||||
* Copyright 2003-2006, Axel Dörfler, [email protected]. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
@@ -14,9 +14,6 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
static struct rld_export const *sRuntimeLinker;
|
||||
|
||||
|
||||
thread_id
|
||||
load_image(int32 argCount, const char **args, const char **environ)
|
||||
{
|
||||
@@ -57,21 +54,21 @@ load_image(int32 argCount, const char **args, const char **environ)
|
||||
image_id
|
||||
load_add_on(char const *name)
|
||||
{
|
||||
return sRuntimeLinker->load_add_on(name, 0);
|
||||
return __gRuntimeLoader->load_add_on(name, 0);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
unload_add_on(image_id id)
|
||||
{
|
||||
return sRuntimeLinker->unload_add_on(id);
|
||||
return __gRuntimeLoader->unload_add_on(id);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
get_image_symbol(image_id id, char const *symbolName, int32 symbolType, void **_location)
|
||||
{
|
||||
return sRuntimeLinker->get_image_symbol(id, symbolName, symbolType, _location);
|
||||
return __gRuntimeLoader->get_image_symbol(id, symbolName, symbolType, _location);
|
||||
}
|
||||
|
||||
|
||||
@@ -79,7 +76,7 @@ status_t
|
||||
get_nth_image_symbol(image_id id, int32 num, char *nameBuffer, int32 *_nameLength,
|
||||
int32 *_symbolType, void **_location)
|
||||
{
|
||||
return sRuntimeLinker->get_nth_image_symbol(id, num, nameBuffer, _nameLength, _symbolType, _location);
|
||||
return __gRuntimeLoader->get_nth_image_symbol(id, num, nameBuffer, _nameLength, _symbolType, _location);
|
||||
}
|
||||
|
||||
|
||||
@@ -188,14 +185,7 @@ __parse_invoke_line(char *invoker, char ***_newArgs,
|
||||
status_t
|
||||
__test_executable(const char *path, char *invoker)
|
||||
{
|
||||
return sRuntimeLinker->test_executable(path, geteuid(), getegid(), invoker);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
__init_image(const struct uspace_program_args *args)
|
||||
{
|
||||
sRuntimeLinker = args->rld_export;
|
||||
return __gRuntimeLoader->test_executable(path, geteuid(), getegid(), invoker);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
/*
|
||||
** Copyright 2003-2004, Axel Dörfler, [email protected]. All rights reserved.
|
||||
** Distributed under the terms of the Haiku License.
|
||||
**
|
||||
** Copyright 2002, Manuel J. Petit. All rights reserved.
|
||||
** Distributed under the terms of the NewOS License.
|
||||
*/
|
||||
/*
|
||||
* Copyright 2003-2006, Axel Dörfler, [email protected]. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Copyright 2002, Manuel J. Petit. All rights reserved.
|
||||
* Distributed under the terms of the NewOS License.
|
||||
*/
|
||||
|
||||
|
||||
#include <libroot_private.h>
|
||||
@@ -14,7 +14,6 @@
|
||||
#include <string.h>
|
||||
|
||||
|
||||
static struct rld_export const *sRuntimeLinker;
|
||||
static status_t sStatus;
|
||||
// Note, this is not thread-safe
|
||||
|
||||
@@ -27,7 +26,7 @@ dlopen(char const *name, int mode)
|
||||
if (name == NULL)
|
||||
name = MAGIC_APP_NAME;
|
||||
|
||||
status = sRuntimeLinker->load_add_on(name, mode);
|
||||
status = __gRuntimeLoader->load_add_on(name, mode);
|
||||
sStatus = status;
|
||||
|
||||
if (status < B_OK)
|
||||
@@ -43,7 +42,7 @@ dlsym(void *handle, char const *name)
|
||||
status_t status;
|
||||
void *location;
|
||||
|
||||
status = sRuntimeLinker->get_image_symbol((image_id)handle, name, B_SYMBOL_TYPE_ANY, &location);
|
||||
status = get_image_symbol((image_id)handle, name, B_SYMBOL_TYPE_ANY, &location);
|
||||
sStatus = status;
|
||||
|
||||
if (status < B_OK)
|
||||
@@ -56,7 +55,7 @@ dlsym(void *handle, char const *name)
|
||||
int
|
||||
dlclose(void *handle)
|
||||
{
|
||||
return sRuntimeLinker->unload_add_on((image_id)handle);
|
||||
return unload_add_on((image_id)handle);
|
||||
}
|
||||
|
||||
|
||||
@@ -69,9 +68,3 @@ dlerror(void)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
__init_dlfcn(const struct uspace_program_args *args)
|
||||
{
|
||||
sRuntimeLinker = args->rld_export;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user