Re: export symbols

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Aug 17, 2009 at 11:52 AM, Andrew Haley<aph@xxxxxxxxxx> wrote:
> Alberich de megres wrote:
>> On Fri, Aug 14, 2009 at 12:53 PM, Andrew Haley<aph@xxxxxxxxxx> wrote:
>>> Please don't top-post.
>>>
>>> Alberich de megres wrote:
>>>> Ian Lance Taylor<iant@xxxxxxxxxx> wrote:
>>>>> "Diego ." <eljedi@xxxxxxxxx> writes:
>>>>>
>>>>>> Reading this thread, i got one doubt: when using version scripts,
>>>>>> is there some way to automate the build of a map file?
>>>>> I don't understand the question.
>>>>>
>>>>> Certainly one can automate the building of a version script file in
>>>>> various ways, e.g., based on the output of nm on the .o files.
>>>>>
>>>> Any web or tutorial where explains the basics for that? i really
>>>> have a mess with all of this, sorry.
>>>>
>>>> I tried version scripts.. but nothing. Modules could not access to
>>>> some calls on core part of my app :((
>>> Examples are better than any other way to understand this.
>>>
>>> I have appended the version script that we use when building libjava.
>>> It causes symbols beginning with "Jv", "_Jv_", and "_Z" to be
>>> exported, along with "__gcj_personality_v0" and
>>> "__gcj_personality_sj0".
>>>
>>> Does this explain what you need to know?
>>> # Anonymous GNU ld version script to hide boehm-gc, libffi and fdlibm
>>> # symbols in libgcj.so.
>>>
>>> {
>>>  global: Jv*; _Jv_*; __gcj_personality_v0; __gcj_personality_sj0; _Z*;
>>>  local: *;
>>> };
>>>
>>>
>>
>> How you compile your library?
>
> It's complicated, but all the information is in gcc/libjava.
>
>> I still have the same problem: on my module file everything goes fine,
>> but on my core app file no API function are added to .dynsym table
>> (the ones to be used by modules). Using you script i cannot get
>> modules to access some funtions on core side, they only are added to
>> .symtab table.
>>
>> thanks once again!!!
>
> We have got beyond the point where any progress can be made by talking
> about this in the abstract.  You need to produce a detailed test case that
> someone eles can run which shows the problem.  The smaller and simpler the
> test case, the more likely people will help you.
>
> Andrew.
>

Hi again!!


I got  2 files:

main.c: defines main and f1() and load module on b.c file ( compiled )
b.c : defines f2() which uses f1() after been loaded.

Here you have the steps to reproduce the error:

to compile b.c file i use:
gcc -shared -fPIC b.c -o b.so

And to compile main.c:
gcc main.c -o main -g -fPIC -O2 -ldl -Wl,--version-script=vs.txt

When i execute main i get this error:
./main: symbol lookup error: ./b.so: undefined symbol: f1

If we do now:
readelf -s main

I noticed tha f1 symbol is not on .dymsyn table. But if i use
-rdynamic when compiling main.c i got f1 on this tables (dynsym), and
the execution doesn't fail.


And the source code for the files:

----  MAIN.C  ---------------------------------------------------------------
#include <stdio.h>
#include <dlfcn.h>

int main(int argc, char **argv)
{
       int *handler;
       double (*cosine)(double);

       handler=(int*)dlopen("dym.mo", RTLD_LAZY);
       if (!handler) {
               printf( "!!! %s\n", dlerror() );
               return;
       }
       cosine = dlsym(handler, "cos");


       printf("coseno 1 =>%f",cosine(1));

       return 0;

       dlclose(handler);

}

int f1()
{
  return 42;
} __attribute__((visibility ("default")))

-----  B.C  ------------------------------------------------------



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



double cos(double d)
{

       printf("f1 returns->%e\n",f1());

       return d;
}

-----  vs.txt  ------------------------------------------------------

{
    global: f1;
    local: *;
};


Thanks!!!


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux