Comment 1 for bug 159181

Revision history for this message
Abdulaziz Ghuloum (aghuloum) wrote : Re: [Bug 159181] Build fails on FreeBSD and NetBSD

There is a flag that must be passed to gcc in order to make functions
in the executable visible to dlsym. On linux, it's "-rdynamic", and
on Mac OS, you don't need to do anything. I don't know what it is
for the bsds. If you know how to get gcc to compile the following
program such that the two printed lines show the same address, then
you'd have solved the problem. Otherwise, I'd have to look around
for a bsd machine to try to figure it out. Keep me posted.

Aziz,,,

#include <stdio.h>
#include <dlfcn.h>

int foo(int x){
   return x*x;
}

int main(int args, char** argv){
   printf("foo=0x%08x\n", (int)foo);
   printf("foo=0x%08x\n", (int)dlsym(RTLD_DEFAULT, "foo"));
   return 0;
}