Hi Kewen, Thanks for your detailed instructions, Following your idea, but with a minor difference, instead of -T scriptfile, I am using -Wl,-Ttext-segment=0xXXXXXXXX(e.g. 0x70000000), ldd libtestScript.so linux-vdso.so.1 (0x0000007fa6f04000) libcpss.so => ./libcpss.so (0x0000000010000000) libhelper.so => ./libhelper.so (0x0000000014600000) libpthread.so.0 => /lib/aarch64-linux-gnu/libpthread.so.0 (0x0000007fa6ece000) librt.so.1 => /lib/aarch64-linux-gnu/librt.so.1 (0x0000007fa6eb7000) libdl.so.2 => /lib/aarch64-linux-gnu/libdl.so.2 (0x0000007fa6ea2000) libm.so.6 => /lib/aarch64-linux-gnu/libm.so.6 (0x0000007fa6de6000) libc.so.6 => /lib/aarch64-linux-gnu/libc.so.6 (0x0000007fa6c8d000) /lib/ld-linux-aarch64.so.1 (0x0000005565c4c000) readelf -h libtestScript.so ELF Header: Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 Class: ELF64 Data: 2's complement, little endian Version: 1 (current) OS/ABI: UNIX - System V ABI Version: 0 Type: DYN (Shared object file) Machine: AArch64 Version: 0x1 Entry point address: 0x70000840 Start of program headers: 64 (bytes into file) Start of section headers: 7248 (bytes into file) Flags: 0x0 Size of this header: 64 (bytes) Size of program headers: 56 (bytes) Number of program headers: 6 Size of section headers: 64 (bytes) Number of section headers: 28 Section header string table index: 25 Cheers, Kewen, appreciate so much for your kind help !!! Xinghao Chen (陈行浩) -----Original Message----- From: Kewen.Lin <linkw@xxxxxxxxxxxxx> Sent: 2019年12月17日 10:42 To: Xing-Hao Chen <ericxh@xxxxxxxxxxx>; gcc-help@xxxxxxxxxxx Subject: Re: [EXT] Re: help! why a 'so' can't load its dependent 'so' to the pre-defined address on 2019/12/16 下午4:13, Xing-Hao Chen wrote: > Hi Kewen, > Appreciate very much for your reply, > > "I found that if you force the virtual address for the libtestScript.so generation as well, you can see the expected result you wanted." > > But how to force the VA for libtestScript.so? > I tried "-Wl,-Ttext=0xXXXX", but will suffer some link problems. > How can I assign the 0xXXXX, while fixing the load VA of libcpss.so/libhelper.so(to be 0x10000000 / 0x14600000) which libtestScript.so relies on? > Hi, I think you can still use linker script scheme for libtestScript.so generation like what you have for libcpss.so/libhelper.so. I used linker script for libt1.so libt3.so generation and see the ldd dump as below. Here libt3 is like libtestScript.so, libt1 is like libcpss.so/libhelper.so and libt2 is as normal. $ LD_LIBRARY_PATH=. ldd ./libt3.so linux-vdso64.so.1 => (0x00003fffadb40000) libt1.so => ./libt1.so (0x0000020000000000) libt2.so => ./libt2.so (0x00003fffadb10000) libc.so.6 => /lib/powerpc64le-linux-gnu/libc.so.6 (0x00003fffad910000) /lib64/ld64.so.2 (0x00003fffadb60000) ** simple ld scripts ** ld01.txt: SECTIONS { . = 0x20000000000; .text : { *(.text) } } ld03.txt: SECTIONS { . = 0x40000000000; .text : { *(.text) } } PS: above scripts are really simple, just for proof of concepts. ** commands ** gcc -shared -fPIC t1.c -o libt1.so -Tld01.txt gcc -shared -fPIC t2.c -o libt2.so gcc -shared -fPIC t3.c -o libt3.so -Tld03.txt -L. -lt1 -lt2 -Wl,-R. gcc main.c -L. -lt3 Note that you need to avoid that the module libtestScript.so conflicts with libcpss.so/libhelper.so, for example using ld01.txt for libt3.so generation, it gets the dumping as below. $ LD_LIBRARY_PATH=. ldd ./libt3.so linux-vdso64.so.1 => (0x00003fffb0550000) libt1.so => ./libt1.so (0x00003fffa0540000) libt2.so => ./libt2.so (0x00003fffa0510000) libc.so.6 => /lib/powerpc64le-linux-gnu/libc.so.6 (0x00003fffa0310000) /lib64/ld64.so.2 (0x00003fffb0570000) ** simple src ** t1.c: int t1(int a, int b) { return a + b; } t2.c: int t2(int a, int b) { return a - b; } t3.c: extern int t1(int a, int b); extern int t2(int a, int b); int t3(int a, int b){ return t1(a, b) + t2(b, a); } main.c: extern int t3(int a, int b); int main() { int a = 1; int b = 2; int c = t3(a+b, b-a); return c; } I tested it on powerpc64le-linux-gnu, with gcc 5.4.0 and GNU ld 2.26.1, FYI in case it matters. BR, Kewen > In summary of my requirement - > When loading libtestScript.so, the loader should load its dependent > two so(libcpss.so/libhelper.so) into the pre-defined VA(to be > 0x10000000 / 0x14600000) > > How can I do? Any suggestion is appreciated. >