Skip to Content.
Sympa Menu

freetds - [freetds] Linker and -Bsymbolic option

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "ZIGLIO Frediano" <Frediano.Ziglio AT vodafone.com>
  • To: <freetds AT lists.ibiblio.org>
  • Subject: [freetds] Linker and -Bsymbolic option
  • Date: Fri, 8 Aug 2003 15:26:13 +0200

Yesterday I learn a strange thing of UNIX so.

Assuming you build a so from a C file like this:

#include <stdio.h>
#include <stdlib.h>

int foo()
{
printf("foo inside so1\n");
}

int test1()
{
foo();
}

another like this

#include <stdio.h>
#include <stdlib.h>

int foo()
{
printf("foo inside so2\n");
}

int test2()
{
foo();
}

And an executable

#include <stdio.h>
#include <stdlib.h>

int main()
{
test1();
test2();
return 0;
}

You will expect a result like:

foo inside so1
foo inside so2

but depending on so loading you can get

foo inside so1
foo inside so1

or

foo inside so2
foo inside so2

This because linker resolve functions at execution time even for
function in the same module !!! (the only exception is static
functions...)
I don't like this behavior so I searched an option to disable this. I
found -Bsymbolic linker option so I added a -Wl,-Bsymbolic to LDFLAGS
however I don't know if this option if portable or not...

Is -Bsymbolic a portable option or work only on GNU linker ?

freddy77



  • [freetds] Linker and -Bsymbolic option, ZIGLIO Frediano, 08/08/2003

Archive powered by MHonArc 2.6.24.

Top of Page