![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to export | jisha | BSD | 4 | 01-21-2008 07:06 AM |
| export??? | Justinkase | Shell Programming and Scripting | 1 | 12-03-2007 06:32 PM |
| nfs export permissions | psimoes79 | HP-UX | 1 | 10-13-2007 05:12 AM |
| confusion with export | kdipankar | Shell Programming and Scripting | 1 | 05-11-2006 06:07 AM |
| export variables | srishan | Shell Programming and Scripting | 4 | 07-06-2004 01:53 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
If I understand your question: dynamic loading means you know the symbol names and the libraries names ahead of time - for the all the entrypoints you are going to map dynamically by calling dlopen yourself... Right? Code:
nm myexcutablefile will list all of the external symbols your program uses. There will be a lot of them that are part of __start and the general C support runtime. Your special symbols need to be mapped by a call to dlopen. Am I on track so far? |
|
|||||
|
This is not what I meant
Suppose I have 2 files: main.c, lib.c Function func1() is defined in main.c, and lib.so is loaded from main.c: dlopen("lib.so", RTLD_LAZY) Then func1() is called from lib.c. Becouse of this I need to put all symbols to the dynamic symbol table: gcc -g -Wl,--export-dynamic,-rpath,. -o main main.o -ldl How can put only func1() to the dynamic symbol table (omitting other symbols)? |
|
||||
|
Sorry. I did not understand. Since you are in a GNU development environment do you know about libltdl? This allows you to handle what you are doing. See: http://www.gnu.org/software/libtool/...#Using-libltdl If you don't like that - what you have to do in code: do not directly reference the module you want by name, this is how you "hide" it from ld. Example: Code:
#include <stdlib.h>
#include <stdio.h>
#include <dlfcn.h>
int main(int argc, char **argv) {
void *libhandle=NULL;
double (*myfunc)(double);
char *errormsg=NULL;
libhandle = dlopen ("/lib/libwhatever.so.1", RTLD_LAZY);
if (!libhandle) {
fputs (dlerror(), stderr);
exit(EXIT_FAILURE);
}
myfunc = dlsym(libhandle, "myfunction");
if ((errormsg = dlerror()) != NULL) {
fputs(errormsg, stderr);
exit(EXIT_FAILURE);
}
printf ("%f\n", (*myfunc)(1.0));
dlclose(libhandle);
return 0;
}
You cannot hide fully qualified symbols from ld - it will try to link against each one, or generate an error. Again, this is what I think you are saying: you have not "hidden" all the symbols. Correct me if I'm wrong. You can't play mix-n-match, some hidden, some not. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|