On 11/25/2009 06:24 PM, yunfeng zhang wrote:
It seems that original limitation isn't clear or sufficient

For a sample:

// f.c
int g;
void foo(void)
{
        g = 1;
}

compile with `gcc -shared -fPIC -Wl,-soname,f.so,-Map,f.map -o f.so f.c'...

With -fPIC, the variable G may be overridden by another variable of the same name from another shared object earlier in the search path. That is, the offset is *not* fixed because the final address of G may reside in a different .so file.

Change your program to

  static int g;

or

  extern int g __attribute__((visibility("hidden")));
  int g;

and compare the results. In either case G is known to resolve to the instance present in f.so. In either case we'll use a constant offset.

You really need to understand how ELF actually works before suggesting that it's broken.


r~

Reply via email to