[comp.sys.sun] converting dynamically linked executables to static

jdh@bu-it.bu.edu (10/02/89)

Can a dynamically linked SunOS 4 executable be made static without
recompiling it from source (let's say we're talking C) ?

It seems like a trick with dump/undump would do this, no?  Does anyone
have something better ?

Jason Heirtzler           (617) 353-2780       jdh@bu-it.bu.edu
Information Technology    Boston University    ..!harvard!bu-cs!bu-it!jdh  

dan@bbn.com (10/13/89)

I gather that you want to capture the libraries it was built with so you
can take it to another machine?

If you core-dump and undump, be careful.  That doesn't restore the values
of data associated with the shared library.  So if shared-library data
changed as the command ran before the dump was created, you can get
inconsistent results.  For example, when sbrk() is called to expand the
address space, its internal pointer to the current end of memory gets
updated.  A core dump won't have this changed value, and undump won't put
it in the new executable, but the address space *will* be larger; sbrk
calls in the new executable produced by undump will return pointers into
already-used address space.  Malloc has similar problems.

So if you go that route, you'll have to find some way to get the core dump
from the executable before it's done *anything*.  Probably adb could be
used to set a breakpoint just after main() is entered.

Our application uses undump to capture its context; after a lot of trying,
we finally just loaded it statically initially in order for undump to
work.

	Dan Franklin