Skip to content

Commit e9029e1

Browse files
committed
[CLI] ensure error on not finding symbol
This sanity check was attempted in #38994, but dlsym is often also okay with finding the trampoline, so we want to also check that it does not use that to resolve the trampoline ad infinitum.
1 parent 6726ae8 commit e9029e1

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

cli/jl_exports.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,19 @@
1010
JL_EXPORTED_DATA_POINTERS(XX)
1111
#undef XX
1212

13-
// Define symbol data as `$type) $(name);`
13+
// Define symbol data as `$(type) $(name);`
1414
#define XX(name, type) JL_DLLEXPORT type name;
1515
JL_EXPORTED_DATA_SYMBOLS(XX)
1616
#undef XX
1717

18-
// Define holder locations for function addresses as `const void * $(name)_addr`
19-
#define XX(name) JL_HIDDEN const void * name##_addr;
18+
// Declare list of exported functions (sans type)
19+
#define XX(name) JL_DLLEXPORT void name(void);
20+
typedef void (anonfunc)(void);
21+
JL_EXPORTED_FUNCS(XX)
22+
#undef XX
23+
24+
// Define holder locations for function addresses as `const void * $(name)_addr = & $(name);`
25+
#define XX(name) JL_HIDDEN anonfunc * name##_addr = (anonfunc*)&name;
2026
JL_EXPORTED_FUNCS(XX)
2127
#undef XX
2228

@@ -29,7 +35,7 @@ static const char *const jl_exported_func_names[] = {
2935
#undef XX
3036

3137
#define XX(name) &name##_addr,
32-
static const void ** jl_exported_func_addrs[] = {
38+
static anonfunc **const jl_exported_func_addrs[] = {
3339
JL_EXPORTED_FUNCS(XX)
3440
NULL
3541
};

cli/loader_lib.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ __attribute__((constructor)) void jl_load_libjulia_internal(void) {
161161
// Once we have libjulia-internal loaded, re-export its symbols:
162162
for (unsigned int symbol_idx=0; jl_exported_func_names[symbol_idx] != NULL; ++symbol_idx) {
163163
void *addr = lookup_symbol(libjulia_internal, jl_exported_func_names[symbol_idx]);
164-
if (addr == NULL) {
164+
if (addr == NULL || addr == *jl_exported_func_addrs[symbol_idx]) {
165165
jl_loader_print_stderr3("ERROR: Unable to load ", jl_exported_func_names[symbol_idx], " from libjulia-internal");
166166
exit(1);
167167
}

0 commit comments

Comments
 (0)