[lttng-dev] dlopen, gcc -l and LD_PRELOAD

Thibault, Daniel Daniel.Thibault at drdc-rddc.gc.ca
Fri Mar 15 12:41:49 EDT 2013


   In the lttng-ust man pages, there is a paragraph that reads:

Note about dlopen() usage: Due to locking side-effects caused by the way libc lazily resolves Thread-Local Storage (TLS) symbols when a library is dlopened, linking the tracepoint probe or liblttng-ust with dlopen() is discouraged.  They should be linked with the application using "-llibname" or loaded with LD_PRELOAD.

   I'm confused by the LD_PRELOAD bit: as far as I know, LD_PRELOAD serves only to substitute a dynamic library (the LD_PRELOAD argument) for another (the one the executable was linked against).  I don't see how one could compile an instrumented application and leave its tracepoint provider unlinked, which is what the stated -llibname <-> LD_PRELOAD opposition implies.

   (Also, shouldn't that paragraph drop 'lazily', assuming the locking problems also arise if dlopen is used with RTLD_NOW?  Because if RTLD_NOW fixed the locking problem, that's what would be recommended here, no?)

Daniel U. Thibault
R & D pour la défense Canada - Valcartier (RDDC Valcartier) / Defence R&D Canada - Valcartier (DRDC Valcartier)
Cyber sécurité pour les missions essentielles (CME) / Mission Critical Cyber Security (MCCS)
Protection des systèmes et contremesures (PSC) / Systems Protection & Countermeasures (SPC)
2459 route de la Bravoure
Québec, QC  G3J 1X5
CANADA
Vox : (418) 844-4000 x4245
Fax : (418) 844-4538
NAC : 918V QSDJ <http://www.travelgis.com/map.asp?addr=918V%20QSDJ>
Gouvernement du Canada / Government of Canada
<http://www.valcartier.drdc-rddc.gc.ca/>



More information about the lttng-dev mailing list