This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Using linker script assignments in shared object


Hi!

I'm trying to define a value in linker script to be used in the shared object.

Suppose the following linker script:

PROVIDE_HIDDEN(test_ls_value = 5);


I have a test program with the following function:

extern int test_ls_value;

void show_test_value()
{
    printf("test value %p\n", &test_ls_value);
}

When this function is defined in the program object everything is OK.
The output is "test value 5".

But when I paste this code into shared object then I got some address
in the middle of memory address space. Though readelf outputs
following for this symbol:

552: 0000000000000005     0 NOTYPE  LOCAL  HIDDEN  ABS test_ls_value

I guess this is somehow connected with -fPIC but I'm not sure. Also I
don't understand if it possible to overcome this behavior. Any ideas?

With best regards,
  Max Dmitrichenko


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]