1
/*-------------------------------------------------------------------------
4
* Dynamic Loader for Postgres for Linux, generated from those for
7
* You need to install the dld library on your Linux system!
9
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
10
* Portions Copyright (c) 1994, Regents of the University of California
14
* src/backend/port/dynloader/bsdi.c
16
*-------------------------------------------------------------------------
21
extern char my_exec_path[];
24
pg_dlopen(char *filename)
26
static int dl_initialized = 0;
29
* initializes the dynamic loader with the executable's pathname. (only
30
* needs to do this the first time pg_dlopen is called.)
34
if (dld_init(dld_find_executable(my_exec_path)))
38
* if there are undefined symbols, we want dl to search from the
39
* following libraries also.
45
* link the file, then check for undefined symbols!
47
if (dld_link(filename))
51
* If undefined symbols: try to link with the C and math libraries! This
52
* could be smarter, if the dynamic linker was able to handle shared libs!
54
if (dld_undefined_sym_count > 0)
56
if (dld_link("/usr/lib/libc.a"))
58
elog(WARNING, "could not link C library");
61
if (dld_undefined_sym_count > 0)
63
if (dld_link("/usr/lib/libm.a"))
65
elog(WARNING, "could not link math library");
68
if (dld_undefined_sym_count > 0)
70
int count = dld_undefined_sym_count;
71
char **list = dld_list_undefined_sym();
73
/* list the undefined symbols, if any */
76
elog(WARNING, "\"%s\" is undefined", *list);
81
dld_unlink_by_file(filename, 1);
87
return (void *) strdup(filename);
93
return dld_strerror(dld_errno);
96
#endif /* not HAVE_DLOPEN */