The idea I got is about removing .got section in ELF format totally.
Before we go, let's see the limitation on the idea
1) It must be deployed on aligned segment model, such as Linux, which cs.start
= ds.start.
2) Currently, I only know how to do on x86 ELF.
Here is a typical sample in PIC model
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',
according to f.map, offsetof(g - foo) in library is 0x1550 - 0x3cc = 0x1184,
however let's load the
typedef int (*gso)(int, int);
gso f;
*(void**) (&f) = dlsym(handle, "foo");
f(1, 2);
return 0;
}
gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-44).
2009/11/26 Richard Henderson :
> On 11/25/2009 06:24 PM, yunfeng zhang wrote
review my code, so which can bring an optimization is offsetof(C - A) is
const. Further, everything in data/bss section has a fixed offset to text
section.
2009/11/26 Alexandre Oliva :
> On Nov 26, 2009, yunfeng zhang wrote:
>
>> The result is the same
>
> But the code isn
You can run a.out several times
24>>a5e0<<, 249>>41c<<
11>>15e0<<, 110>>41c<<
c7>>85e0<<, c77>>41c<<
8c>>35e0<<, 8c2>>41c<<
...
Now open f.map
g = 0x15e0, foo = 0x41c
is it 5 + 3 = 4 + 4?
2009/
Sorry! I've made a mistake! But using LD_PRELOAD to force to reposition a
variable/function from a module is violating software engineer. And the more
important is, as the result, all user *all* pay the bill for this even they
make sure they don't need the feature, such as, glibc itself.
Thank you! I've known to how to create a *compat* PIC library, firstly using
`-fvisibility=hidden' in compile command line to hidden all symbols, then
using `objcopy -R' to remove .got section totally! However, assemble result is
just like this
call__i686.get_pc_thunk.bx
addl
on gcc 4.6.3 only.
Attachment is from
https://gccsymdb.googlecode.com/svn/trunk@43 or
https://gccsymdb.googlecode.com/svn/tags/v4
Thanks for trying:)
Yunfeng Zhang
symdb.gcc.tgz
Description: GNU Zip compressed data