词条 | Rpath |
释义 |
In computing, {{lowercase}}rpath designates the run-time search path hard-coded in an executable file or library. Dynamic linking loaders use the rpath to find required libraries. Specifically it encodes a path to shared libraries into the header of an executable (or another shared library). This RPATH header value (so named in the Executable and Linkable Format header standards) may either override or supplement the system default dynamic linking search paths. The rpath of an executable or shared library is an optional entry in the Use of the DT_RPATH entry by the dynamic linkerThe different dynamic linkers for ELF implement the use of the GNU ld.soThe dynamic linker of the GNU C Library searches for shared libraries in the following locations:[1]
Notes:
The role of GNU ldThe GNU Linker (GNU ld) implements a feature which it calls "new-dtags", which can be used to insert an rpath that has lower precedence than the If the new-dtags feature is enabled in the linker ( The ld dynamic linker does not search DT_RUNPATH locations for transitive dependencies, unlike DT_RPATH. [3] Instead of specifying the Solaris ld.soThe dynamic linker of Solaris, specifically Example{{howto|date=August 2018}}In this example, GNU or Sun ld (ld.so) will REFUSE to load termcap for a program needing it unless the file termcap.so is in /lib/ and named termcap.so.4. {{mono|LD_LIBRARY_PATH}} is ignored. If /lib/termcap.so.4 is removed to remediate, the shell dies (one cannot load an alternate termcap.so and a rescue disk is needed, but also if a new termcap.so.4 has RPATH /lib, ld.so will refuse to use to load it unless it clobbered /lib/termcap.so.4). But there's another issue: it isn't safe to copy over some libs in /lib as they are "in use," further restricting the would-be lib tester. Furthermore, {{samp|SONAME termcap.so.4}} vs. {{samp|SONAME termcap.so}} means programs needing basic termcap.so are denied because the library above deleted the ABI access to basic support. Old Linux/Sun used the above, which allows a user to direct any program to use any termcap.so they specify in {{mono|LD_LIBRARY_PATH}}, or what is found in /usr/local/lib(n) using the search rules such as ld.so.conf. However, GNU ld always uses /lib or /usr/lib regardless before {{mono|LD_LIBRARY_PATH}}, so first /lib/termcap.so is moved to /usr/local/lib and that mentioned in ld.so.conf, which enables use of moving libs and ld.so.conf or use of {{mono|LD_LIBRARY_PATH}} to use. A preferred practice is to use "{{samp|SONAME termcap.so}}" and have programs check version (all libs do support that) to use features available, but that was often skipped in old releases due to slow computing speed and lack of time to code correctly. That being said, test this kind of thing thoroughly on a given platform before deciding to rely on it. Release administrators today are not guaranteed to respect past guidelines or documentation. Some UNIX varieties link and load in a completely different way. rpath is specific to ld shipped with a particular distribution. Lastly, as said, rpath is a security feature however "mandatory access control" (MAC) and other techniques can be as effective or more effective than rpath to control lib reading and writing. Control over rpath using today's compilers is often nearly impossible given lengthy and convoluted make(1) scripting. Worse, some build scripts ignore --disable-rpath even though they present it as an option. It would be time-consuming and frustrating, and probably unfeasible, to fix build scripting in every odd program to compile. A simple sh(1) "wrapper" can call the real ld, named ld.bin. The wrapper can filter in/out {{mono|-rpath}} option before invoking ld. However, note that some builds incorrectly use rpath instead of rpath-link or {{mono|LD_LIBRARY_PATH}} or {{mono|$(TOP)/dir/foo.so}} to locate intermediate products that stay in the build directory - thus backwardly demand rpath in the final product, which is a new issue concerning "what is rpath". References1. ^{{cite web |title=Linux / Unix Command: ld.so |url=http://man7.org/linux/man-pages/man8/ld.so.8.html |publisher=man7.org |accessdate=19 February 2018 }} 2. ^{{cite web|title=Shared Libraries: distribution and build-system issues|url=http://hackage.haskell.org/trac/ghc/wiki/SharedLibraries/Management#OnLinux|publisher=Official website of the Haskell Compiler|accessdate=12 October 2011}} 3. ^https://bugs.launchpad.net/ubuntu/+source/eglibc/+bug/1253638 External links
2 : Computer libraries|Operating system technology |
随便看 |
|
开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。