emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: emacs25 dynamic module dlopen flags


From: Davis Herring
Subject: Re: emacs25 dynamic module dlopen flags
Date: Mon, 6 Mar 2017 14:24:15 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0

my emacs module linked with libperl.so,
when perl interpreter in the module execute some scripts, it may load other
.so files depending on which perl package is going to be loaded,
for example, DBD::mysql will load DBD/mysql/mysql.so, Socket will
load Socket.so,
without that flag, loading Socket.so will fail, the error message is like
Socket.so can't find some symbols from libperl.so .
it may look like the problem is in libperl.so,
but if I add RTLD_GLOBAL in emacs/src/dynlib.c, Socket.so will be loaded
successful,

I've had the same issues with Python (playing the role of Emacs here): it uses RTLD_LOCAL, which is fine for the "top level" .so but bad for the (DT_NEEDED) dependencies because they should be made available to other things which might have them as dependencies. (Otherwise you can get duplicate symbols loaded, which breaks things that have vague linkage (from C++) or which have static duration variables.)

Unfortunately, the fixed names that Philipp mentioned prevent this from working: you can't load two such things with RTLD_GLOBAL because the names will collide. Python doesn't have that problem because it looks for a symbol initfoo in a module named foo. If modules are careful to make all their other symbols have internal linkage (or have hidden ELF visibility), it should be an improvement (although Ulrich Drepper's piece on the subject calls RTLD_GLOBAL "usually a very bad idea").

Davis

--
This product is sold by volume, not by mass. If it appears too dense or too sparse, it is because mass-energy conversion has occurred during shipping.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]