반응형

Using static and shared libraries across platforms

I produced hereafter some information about shared libraries on different systems. However, this information is probably very sparse on details and may even not be up-to-date. Actually, keeping track of changes is nearly impossible.
The definitive information usually comes from the operating system docs. (e.g. HP's "HP-UX Linker and Libraries User's Guide", Sun's "Linker and Libraries Guide", SGI's "MIPSpro Compiling and Performance Tuning Guide", IBM's "AIX Linking and Loading Mechanisms", etc.), where there is often advice on the best options for performance.
GNU libtool offers an abstraction layer to shared library management.


Feedback is welcome.


Adapted from:
Cross platform development, Using Shared Libraries across Platforms, Shah, Amal ; Xiao, Hong, C/C++ Users JournalMay 1998, Volume 16 Number 5

Shared and static libraries information
LinuxSolarisHP-UXCompaq (Digital) Tru64AIXSGIWin32MacOS XVMSOS/390
Version[kernel 2.x, GCC 2.95.x and later][2.8][11][4.x][4.3 and later][Irix 6.5][NT 4][10.x][unmaintained][unmaintained]
1compiler flag (position independent code)-fPIC-KPIC, -Kpic+z/+Zxxxxxxxx-KPIC (default)xxxx-fno-commonxxxx-DLL
2ashared library creation flag-shared-G-b-shared-bM:SRE-sharedlink /DLLcc -bundle, -dynamiclib
libtool -dynamic
/SHARExxxx
2bshared library creation (C++)g++ -fPIC -shared -oCC -G -oaCC -b -ocxx -shared -oxlC -G (or -qmkshrobj)
obsolete:/usr/vacpp/bin/makeC++SharedLib -G -o
(was in /usr/ibmcxx/bin or/usr/lpp/xlC/bin/)
CC -shared -oCL -LD -Fexxx.DLL??
libtool -dynamic
????
2cstatic archiver (C++)arCC -xar -oarararCC -ar -oLIB (avoid link /lib that creates __impl symbols)??
libtool -static
????
3alibrary name(ld option) -soname name-h name(ld option) +h name(ld option) -soname namexxxx(ld option) -soname name/OUT:name-compatibility_version, -current_version/SHARE=xxxx
3bfile extension.so.so.sl.so.so (or .a).so.DLL.dylib.EXE??
4executable link options-Bdynamic
-Lpath -lname
-Bdynamic
-Lpath -lname
-a,shared
-Lpath -name
-no_archive
-Lpath -lname
-brtl
-bdynamic
-Lpath -lname
-Bdynamic,
-Lpath -lname
Controlled by .lib files??xxxxfilename/SHAREABLE
5aruntime path specification-rpath <path>-R <pathlist>-Wl,+b <pathlist> -Wl,+s-rpath <path>-blibpath:<path>
(by default, it is set to the arguments of -L)
-rpath <path>/LIBPATH:-install_name <path>xxxxxxxx
5bDoes not build the path for shared libraries into the executabledefault-norunpathchatr +b disable <file>default-blibpath:/usr/lib:/libdefault????????
6controlling symbolsusing a script file (see "info ld")-z defs/ nodefs/ muldefs+v[no] shlibunsats-expect [error] _unresolvedxxxx-ignore[no] _unresolved/FORCE: MULTIPLE [UNRESOLVED]??xxxxxxxx
LinuxSolarisHP-UXCompaq (Digital) Tru64AIXSGIWin32MacOS XVMSOS/390
7exports file/link option
(see notes)
using a script file (see "info ld")using a script file (see "man ld")+e,symname-exported_symbol.exp-exported_symbol
-exports_file filename
.def/__declspec(dllexport)-exported_symbols_list/SYMBOL_TABLE=(...).x file/
#pragma export()
8hiding symbolsusing a script file: VERSION command (see "Version Script" section in "info ld")using a script file (see "man ld") (see this article)-h symname-hidden_symbol, -hiddenxxxx-hidden_symbol,
-hiddens_file filename
using a .def file-unexported_symbols_listxxxxxxxx
9runtime library pathLD_LIBRARY_PATHLD_LIBRARY_PATH
LD_LIBRARY_PATH_64
SHLIB_PATH
LD_LIBRARY_PATH (64 bits)
LD_LIBRARY_PATHLIBPATHLD_LIBRARY_PATH
LD_LIBRARYN32_PATH
LD_LIBRARY64_PATH
. and then PATHDYLD_LIBRARY_PATH
DYLD_FALLBACK_LIBRARY_PATH
SYS$SHARELIBPATH
10symbol binding-Bsymbolic-Bsymbolic-Bsymbolic /immediate /deferredxxxxxxxx-Bsymbolicxxxx??xxxxxxxx
11runtime debugging(c.f. man ld.so)
LD_BIND_NOW
LD_TRACE_LOADED_OBJECTS
LD_DEBUG=help
ltrace
(c.f. man ld.so.1)
LD_BIND_NOW
LD_DEBUG
ld -D help
(c.f. man dld.sl)
_HP_DLDOPTS
(c.f. man loader)
LD_BIND_NOW
_RLD_ARGS
LDR_CNTRL(c.f. man rld)
LD_BIND_NOW
_RLD_PATH, _RLD_ARGS
xxxxDYLD_BIND_AT_LAUNCH
DYLD_PRINT_LIBRARIES
DYLD_PREBIND_DEBUG
xxxxxxxx
12runtime preloadLD_PRELOADLD_PRELOADLD_PRELOAD (probably HP-UX >= 11)_RLD_LIST "xxx.so:DEFAULT"xxxx_RLD_LIST "xxx.so:DEFAULT"??DYLD_INSERT_LIBRARIES????
13loaderld.sold.sodld.slloaderxxxxrldxxxxdyldxxxxxxxx
14runtime performancexxxxxxxxfastbind tool-quickstart_infoxxxx-quickstart_info/DELAYLOADxxxxxxxxxxxx
LinuxSolarisHP-UXCompaq (Digital) Tru64AIXSGIWin32MacOS XVMSOS/390
15versioningusing a script file: VERSION command (see "info ld")using a script file (see "man ld")
-M mapfile
xxxxxxxxxxxx-set_version/-exact_version/
-ignore_version
/VERSION:major.minor??/GSMATCH=xxxx
16entry pointsxxxxxxxxxxxxxxxxxxxxxxxxDllMainxxxxxxxxxxxx
17dynamic loading /
dynamic symbol access
dlopen / dlsymdlopen / dlsymshl_load / shl_findsym
(64 bits) dlopen / dlsym
dlopen / dlsymloadquery/loadbind
(AIX 4.2) dlopen / dlsym
dlopen / dlsymLoadLibrary / GetProcAddress"man 3 dyld"lib$find_image_symboldllload / dllqueryfn/ dllqueryvar
18utilitiesldd, ldconfig, objdump, ltrace, readelfldd, elfdump, pvs, dumpstabs (compilers V.6), crle (Solaris>=8)chatr
odump
ldd, elfdump (HP-UX >= 11)
odump -Dldump -H
ldd (in AIX tools)
elfdump -Dl
pldd
ldd (IRIX >= 6.5)
DUMPBIN, depends, EXEHDR, link -dumpotoolANALYSE/IMAGExxxx
19documentationman: ld, ld.so, ldd
info: ld, gcc, binutil
HOWTO: ELF-HOWTO, GCC-HOWTO
man: ld, ld.so.1, ldd, pvsman: ld, dld.sl, chatrman: ld, loader, odumpman: ld, dumpman: dso, ld, rld, elfdump, lddMSDNman: ld, libtool, dyld, otool????
LinuxSolarisHP-UXCompaq (Digital) Tru64AIXSGIWin32MacOS XVMSOS/390

Notes:


Acknowledgments

Juan Altmayer Pizzorno, Wolfgang Haefelinger, Per Losenborg, Anil E. Sahukar, Andrew Stalewski, Pirasenna Velandai Thiyagarajan, Nathan Stratton Treadway, Stephan Weber, Bo Xie

반응형

+ Recent posts