2013-07-11 40 views

回答

1
# create linker script 

$ export BASE_ADDRESS=0x00800000 
$ gcc -shared -Wl,--verbose 2>&1 | sed -e '/^======/,/^======/!d' -e '/^======/d;s/0\(.*\)\(+ SIZEOF_HEADERS\)/'$BASE_ADDRESS'\1\2/' >foo.lds 

# build and link with linker-script 

$ gcc -shared foo.c -o foo.o 
$ gcc -Wl,-T,foo.lds -shared -fPIC foo.o -o foo.so 
$ objdump --syms foo.so 

foo.so:  file format elf32-i386 

SYMBOL TABLE: 

00800114 l d .note.gnu.build-id 00000000    .note.gnu.build-id 
00800138 l d .gnu.hash 00000000    .gnu.hash 
0080016c l d .dynsym 00000000    .dynsym 
008001fc l d .dynstr 00000000    .dynstr 
... 
+0

这很酷。我认为它会起作用。让我试试我的情况。 – limi