This is the mail archive of the
mailing list for the binutils project.
Using linker script assignments in shared object
- From: Max Dmitrichenko <dmitrmax at gmail dot com>
- To: binutils at sourceware dot org
- Date: Wed, 28 May 2014 17:29:26 +0400
- Subject: Using linker script assignments in shared object
- Authentication-results: sourceware.org; auth=none
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;
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,