| 1 |
/* { dg-options "-DCE_EXTRACT_FUNCTIONS=___dlsym -DCE_NO_EXTERNALIZATION" }*/ |
| 2 |
|
| 3 |
extern void *_dl_sym(void *handle, const char *name, void *who) __attribute__((visibility("hidden"))); |
| 4 |
extern int _dlerror_run(void (*operate)(void *), void *args) __attribute__((visibility("hidden"))); |
| 5 |
|
| 6 |
struct dlsym_args |
| 7 |
{ |
| 8 |
/* The arguments to dlsym_doit. */ |
| 9 |
void *handle; |
| 10 |
const char *name; |
| 11 |
void *who; |
| 12 |
|
| 13 |
/* The return value of dlsym_doit. */ |
| 14 |
void *sym; |
| 15 |
}; |
| 16 |
|
| 17 |
static void |
| 18 |
dlsym_doit (void *a) |
| 19 |
{ |
| 20 |
struct dlsym_args *args = (struct dlsym_args *) a; |
| 21 |
|
| 22 |
args->sym = _dl_sym (args->handle, args->name, args->who); |
| 23 |
} |
| 24 |
|
| 25 |
static void *dlsym_implementation(void *handle, const char *name, void *dl_caller) { |
| 26 |
struct dlsym_args args; |
| 27 |
args.who = dl_caller; |
| 28 |
args.handle = handle; |
| 29 |
args.name = name; |
| 30 |
//__pthread_mutex_lock(&(_dl_load_lock).mutex); |
| 31 |
void *result = (_dlerror_run(dlsym_doit, &args) ? ((void *)0) : args.sym); |
| 32 |
//__pthread_mutex_unlock(&(_dl_load_lock).mutex); |
| 33 |
return result; |
| 34 |
} |
| 35 |
|
| 36 |
void *__dlsym(void *handle, const char *name, void *dl_caller) { |
| 37 |
return dlsym_implementation(handle, name, dl_caller); |
| 38 |
} |
| 39 |
|
| 40 |
void *___dlsym(void *handle, const char *name) { |
| 41 |
return __dlsym(handle, name, __builtin_extract_return_addr(__builtin_return_address(0))); |
| 42 |
} |
| 43 |
|
| 44 |
/* { dg-final { scan-tree-dump "extern void \*_dl_sym" } } */ |