Ali Bahrami wrote:
> C. Bergstr?m wrote:
>>
>>
> Can you explain what you're trying to achieve with that?
>
> LD_PRELOAD is something that is implemented by ld.so.1, so
> ld.so.1 is already in memory and running at the point when
> your LD_PRELOAD is being seen and acted upon.I'm not sure what
> happens at that point, but I don't think it would be anything good.
>
> If you're trying to substitute a different ld.so.1, then you
> can run your example this way:
>     
>     ./ld.so.1 /usr/bin/amd64/ld --help
This is exactly what I was looking for.. I don't know much about ld.so.1 
and executing a shared lib like this is non-obvious to me..
>
> Or you can elfedit your binary to point at a different interpreter.
> Or even better since you're using a zone, here's how I use zones to
> do linker testing:
>
>     
> http://blogs.sun.com/ali/entry/testing_critical_system_components_without
Nice post.. At the bottom or somewhere you should add this example from 
above..  Knowing that you can test ld.so.1 like this is very good..

I'll try to be as concise as possible in the changes I've made...

1) When libc builds it creates.. libc_pic.a Since I'm not building the 
entire gate all at once.. I'm packaging this and moving it out of the 
way so I can reference it later.. (I put them 
/usr/lib/libc/libc-pic/i386/libc_pic.a and 
/usr/lib/libc/libc-pic/amd64/libc_pic.a )

2) To adjust for this change I had to modify rtld/Makefile.com

In the end the command below is how ld.so.1 is being built... (paths 
shortened for readability)

/osunix-gate/usr/src/cmd/sgs/proto/i386/ld -o ld.so.1 -dy -G 
-h/lib/amd64/ld.so.1 -ztext -zdefs -Bdirect  -M../common/mapfile-vers 
-M../common/mapfile-order-devpro -Mmapfile-amd64-vers 
-M../common/mapfile-64-vers 
-M/osunix-gate/usr/src/common/mapfiles/i386/map.pagealign  -zignore -i 
-e _rt_boot -ulink_ver_string -znodlopen  -zinterpose 
-zdtrace=dtrace_data -R/lib/amd64 pics/crti.o pics/msg.o  pics/avl.o  
pics/dtrace_data.o  pics/alist.o pics/strhash.o  pics/boot.o             
pics/boot_elf.o pics/caller.o   pics/debugdata.o  pics/analyze.o        
pics/elf.o              pics/external.o pics/globals.o  pics/malloc.o   
pics/paths.o            pics/setup.o            pics/util.o  
pics/dlfcns.o      pics/config_elf.o       pics/locale.o   pics/tsort.o  
pics/remove.o     pics/move.o             pics/tls.o              
pics/cap.o   pics/amd64_elf.o   pics/_setup.o   
pics/dlamd64getunwind.o   pics/doreloc.o      pics/debug.o              
pics/audit.o            pics/object.o -L/lib/amd64 -L/usr/lib/amd64 
-L/osunix-gate/usr/src/cmd/sgs/libconv/amd64 -lconv 
-L/usr/lib/libc/libc-pic/amd64/ -lc_pic  
-L/osunix-gate/usr/src/cmd/sgs/liblddbg/amd64 -llddbg  -L 
../../librtld/amd64 -lrtld  -L ../../libld/amd64 -lld  pics/crtn.o


3) Here's a quick truss..

truss ./ld.so.1 /usr/bin/amd64/ld --help
execve("ld.so.1", 0xFFFFFD7FFFDFF718, 0xFFFFFD7FFFDFF738)  argc = 3
mmap(0x00000000, 4096, PROT_READ|PROT_WRITE|PROT_EXEC, 
MAP_PRIVATE|MAP_ANON, 4294967295, 0) = 0xFFFFFD7FFF3F0000
mmap(0x00000000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, 
4294967295, 0) = 0xFFFFFD7FFF390000
mmap(0x00000000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, 
4294967295, 0) = 0xFFFFFD7FFF380000
memcntl(0xFFFFFD7FFF3A1000, 101536, MC_ADVISE, MADV_WILLNEED, 0, 0) = 0
open("/usr/bin/amd64/ld", O_RDONLY)             = 3
fstat(3, 0xFFFFFD7FFFDFF430)                    = 0
mmapobj()                                       Err#89 ENOSYS
    Received signal #12, SIGSYS [default]
      siginfo: SIG#0

Anyone see anything glaring wrong from the build command above.. ?

To answers Jame's question..  LD_PRELOAD was a chicken/egg attempt to 
try to reproduce the problem.  All of this worked fine for onnv_107, but 
not sure what changed in 115 to cause this.  Unless someone has any 
other tips it looks like I must build with debugging and dbx it..

Thanks a lot Ali!

./C

Reply via email to