mirror of
https://github.com/corda/corda.git
synced 2025-01-08 14:03:06 +00:00
search libraries for symbols in the order they are loaded
This commit is contained in:
parent
618684de6e
commit
35ada0ea65
@ -537,12 +537,9 @@ Java_java_lang_Runtime_load(Thread* t, jclass, jstring name, jboolean mapName)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
System::Library* lib;
|
if (UNLIKELY(not t->m->system->success
|
||||||
if (LIKELY(t->m->system->success
|
(t->m->system->load(&(t->m->libraries), n, mapName))))
|
||||||
(t->m->system->load(&lib, n, mapName, t->m->libraries))))
|
|
||||||
{
|
{
|
||||||
t->m->libraries = lib;
|
|
||||||
} else {
|
|
||||||
object message = makeString(t, "library not found: %s", n);
|
object message = makeString(t, "library not found: %s", n);
|
||||||
t->exception = makeUnsatisfiedLinkError(t, message);
|
t->exception = makeUnsatisfiedLinkError(t, message);
|
||||||
}
|
}
|
||||||
|
@ -400,8 +400,8 @@ class BuiltinElement: public JarElement {
|
|||||||
|
|
||||||
virtual void init() {
|
virtual void init() {
|
||||||
if (index == 0) {
|
if (index == 0) {
|
||||||
System::Library* library;
|
System::Library* library = 0;
|
||||||
if (s->success(s->load(&library, 0, false, 0))) {
|
if (s->success(s->load(&library, 0, false))) {
|
||||||
void* p = library->resolve(name);
|
void* p = library->resolve(name);
|
||||||
if (p) {
|
if (p) {
|
||||||
uint8_t* (*function)(unsigned*);
|
uint8_t* (*function)(unsigned*);
|
||||||
|
@ -1812,7 +1812,7 @@ Machine::Machine(System* system, Heap* heap, Finder* finder,
|
|||||||
not system->success(system->make(&heapLock)) or
|
not system->success(system->make(&heapLock)) or
|
||||||
not system->success(system->make(&classLock)) or
|
not system->success(system->make(&classLock)) or
|
||||||
not system->success(system->make(&referenceLock)) or
|
not system->success(system->make(&referenceLock)) or
|
||||||
not system->success(system->load(&libraries, 0, false, 0)))
|
not system->success(system->load(&libraries, 0, false)))
|
||||||
{
|
{
|
||||||
system->abort();
|
system->abort();
|
||||||
}
|
}
|
||||||
|
@ -447,13 +447,13 @@ class MySystem: public System {
|
|||||||
class Library: public System::Library {
|
class Library: public System::Library {
|
||||||
public:
|
public:
|
||||||
Library(System* s, void* p, const char* name, unsigned nameLength,
|
Library(System* s, void* p, const char* name, unsigned nameLength,
|
||||||
bool mapName, System::Library* next):
|
bool mapName):
|
||||||
s(s),
|
s(s),
|
||||||
p(p),
|
p(p),
|
||||||
name_(name),
|
name_(name),
|
||||||
nameLength(nameLength),
|
nameLength(nameLength),
|
||||||
mapName_(mapName),
|
mapName_(mapName),
|
||||||
next_(next)
|
next_(0)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
virtual void* resolve(const char* function) {
|
virtual void* resolve(const char* function) {
|
||||||
@ -639,8 +639,7 @@ class MySystem: public System {
|
|||||||
|
|
||||||
virtual Status load(System::Library** lib,
|
virtual Status load(System::Library** lib,
|
||||||
const char* name,
|
const char* name,
|
||||||
bool mapName,
|
bool mapName)
|
||||||
System::Library* next)
|
|
||||||
{
|
{
|
||||||
void* p;
|
void* p;
|
||||||
unsigned nameLength = (name ? strlen(name) : 0);
|
unsigned nameLength = (name ? strlen(name) : 0);
|
||||||
@ -666,8 +665,14 @@ class MySystem: public System {
|
|||||||
n = 0;
|
n = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
*lib = new (allocate(this, sizeof(Library)))
|
Library* newLib = new (allocate(this, sizeof(Library)))
|
||||||
Library(this, p, n, nameLength, mapName, next);
|
Library(this, p, n, nameLength, mapName);
|
||||||
|
|
||||||
|
if (*lib) {
|
||||||
|
static_cast<Library*>(*lib)->next_ = newLib;
|
||||||
|
}
|
||||||
|
|
||||||
|
*lib = newLib;
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
// fprintf(stderr, "dlerror: %s\n", dlerror());
|
// fprintf(stderr, "dlerror: %s\n", dlerror());
|
||||||
|
@ -104,8 +104,7 @@ class System {
|
|||||||
unsigned returnType) = 0;
|
unsigned returnType) = 0;
|
||||||
virtual Status map(Region**, const char* name) = 0;
|
virtual Status map(Region**, const char* name) = 0;
|
||||||
virtual FileType identify(const char* name) = 0;
|
virtual FileType identify(const char* name) = 0;
|
||||||
virtual Status load(Library**, const char* name, bool mapName, Library* next)
|
virtual Status load(Library**, const char* name, bool mapName) = 0;
|
||||||
= 0;
|
|
||||||
virtual char pathSeparator() = 0;
|
virtual char pathSeparator() = 0;
|
||||||
virtual int64_t now() = 0;
|
virtual int64_t now() = 0;
|
||||||
virtual void exit(int code) = 0;
|
virtual void exit(int code) = 0;
|
||||||
|
@ -606,8 +606,7 @@ class MySystem: public System {
|
|||||||
|
|
||||||
virtual Status load(System::Library** lib,
|
virtual Status load(System::Library** lib,
|
||||||
const char* name,
|
const char* name,
|
||||||
bool mapName,
|
bool mapName)
|
||||||
System::Library* next)
|
|
||||||
{
|
{
|
||||||
HMODULE handle;
|
HMODULE handle;
|
||||||
unsigned nameLength = (name ? strlen(name) : 0);
|
unsigned nameLength = (name ? strlen(name) : 0);
|
||||||
@ -635,8 +634,14 @@ class MySystem: public System {
|
|||||||
n = 0;
|
n = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
*lib = new (allocate(this, sizeof(Library)))
|
Library* newLib = new (allocate(this, sizeof(Library)))
|
||||||
Library(this, handle, n, mapName, nameLength, next);
|
Library(this, p, n, nameLength, mapName);
|
||||||
|
|
||||||
|
if (*lib) {
|
||||||
|
static_cast<Library*>(*lib)->next = newLib;
|
||||||
|
}
|
||||||
|
|
||||||
|
*lib = newLib;
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
return 1;
|
return 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user