How to make $ORIGIN in RPATH not follow symlinks?
I have an executable app
, which depends on a library libbar.so
and loads it via RPATH
with $ORIGIN
like this:
$ readelf -d app
Dynamic section at offset 0xe08 contains 26 entries:
Tag Type Name/Value
0x0000000000000001 (NEEDED) Shared library: [libbar.so]
0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
0x000000000000000f (RPATH) Library rpath: [$ORIGIN/lib/]
It would be nice to run it in the appropriate directory structure, made with symlinks to the executable and the libbar.so
:
$ ls -R
.:
app@ lib/
./lib:
libbar.so@
-- but the linker follows symlinks to the original file of the executable, sets $ORIGIN
to the directory of the executable file and resolves the dependency paths from there. Is it possible to make it not do this? So that directory-path-wise, in the search for lib files, the symlinks are treated as real files of the filesystem ("end-points" of the search).
Also, some reasoning to this problem:
It is convenient to have binaries set up to search for dependencies in a couple relational directories, for instance in the
$ORIGIN/
of a binary itself and also in$ORIGIN/appname_dependencies/
(so that one can just copy the binary and its' dependencies into one directory and run it, but also has a fall-back for a more complicated set-up with multiple versions of the same binary in the system).Due to the requirement of several dependency search paths,
RPATH
is the search method to use: a "slashed" name of dependency (NEEDED Shared library: [./libbar.so]
) sets only 1 search path. Also, for simplicity the dependency resolution paths should be in the binary itself.
It's nice to be able to combine all binaries (the application and all its' dependencies) into the full dependency graph with links, instead of copying the files. And symbolic links are more resilient than hard links: they link across filesystems. In fact, I have this problem in one academic environment of a linux cluster, where a hard link to parent directory cannot be done:
$ ln ../afile
ln: creating hard link `./afile' => `../afile': Invalid cross-device link
symlink dynamic-linking elf
bumped to the homepage by Community♦ 3 hours ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I have an executable app
, which depends on a library libbar.so
and loads it via RPATH
with $ORIGIN
like this:
$ readelf -d app
Dynamic section at offset 0xe08 contains 26 entries:
Tag Type Name/Value
0x0000000000000001 (NEEDED) Shared library: [libbar.so]
0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
0x000000000000000f (RPATH) Library rpath: [$ORIGIN/lib/]
It would be nice to run it in the appropriate directory structure, made with symlinks to the executable and the libbar.so
:
$ ls -R
.:
app@ lib/
./lib:
libbar.so@
-- but the linker follows symlinks to the original file of the executable, sets $ORIGIN
to the directory of the executable file and resolves the dependency paths from there. Is it possible to make it not do this? So that directory-path-wise, in the search for lib files, the symlinks are treated as real files of the filesystem ("end-points" of the search).
Also, some reasoning to this problem:
It is convenient to have binaries set up to search for dependencies in a couple relational directories, for instance in the
$ORIGIN/
of a binary itself and also in$ORIGIN/appname_dependencies/
(so that one can just copy the binary and its' dependencies into one directory and run it, but also has a fall-back for a more complicated set-up with multiple versions of the same binary in the system).Due to the requirement of several dependency search paths,
RPATH
is the search method to use: a "slashed" name of dependency (NEEDED Shared library: [./libbar.so]
) sets only 1 search path. Also, for simplicity the dependency resolution paths should be in the binary itself.
It's nice to be able to combine all binaries (the application and all its' dependencies) into the full dependency graph with links, instead of copying the files. And symbolic links are more resilient than hard links: they link across filesystems. In fact, I have this problem in one academic environment of a linux cluster, where a hard link to parent directory cannot be done:
$ ln ../afile
ln: creating hard link `./afile' => `../afile': Invalid cross-device link
symlink dynamic-linking elf
bumped to the homepage by Community♦ 3 hours ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
Are hard links a possibility?
– Satya Mishra
Aug 10 '16 at 16:44
@SatyaMishra sadly no. Hard links work indeed splendidly -- they are just like regular files for the filesystem, but don't take more space -- and that's what I need. But it would be better to have symbolic links, since they can link to files across devices/filesystems.
– xealits
Aug 10 '16 at 17:00
add a comment |
I have an executable app
, which depends on a library libbar.so
and loads it via RPATH
with $ORIGIN
like this:
$ readelf -d app
Dynamic section at offset 0xe08 contains 26 entries:
Tag Type Name/Value
0x0000000000000001 (NEEDED) Shared library: [libbar.so]
0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
0x000000000000000f (RPATH) Library rpath: [$ORIGIN/lib/]
It would be nice to run it in the appropriate directory structure, made with symlinks to the executable and the libbar.so
:
$ ls -R
.:
app@ lib/
./lib:
libbar.so@
-- but the linker follows symlinks to the original file of the executable, sets $ORIGIN
to the directory of the executable file and resolves the dependency paths from there. Is it possible to make it not do this? So that directory-path-wise, in the search for lib files, the symlinks are treated as real files of the filesystem ("end-points" of the search).
Also, some reasoning to this problem:
It is convenient to have binaries set up to search for dependencies in a couple relational directories, for instance in the
$ORIGIN/
of a binary itself and also in$ORIGIN/appname_dependencies/
(so that one can just copy the binary and its' dependencies into one directory and run it, but also has a fall-back for a more complicated set-up with multiple versions of the same binary in the system).Due to the requirement of several dependency search paths,
RPATH
is the search method to use: a "slashed" name of dependency (NEEDED Shared library: [./libbar.so]
) sets only 1 search path. Also, for simplicity the dependency resolution paths should be in the binary itself.
It's nice to be able to combine all binaries (the application and all its' dependencies) into the full dependency graph with links, instead of copying the files. And symbolic links are more resilient than hard links: they link across filesystems. In fact, I have this problem in one academic environment of a linux cluster, where a hard link to parent directory cannot be done:
$ ln ../afile
ln: creating hard link `./afile' => `../afile': Invalid cross-device link
symlink dynamic-linking elf
I have an executable app
, which depends on a library libbar.so
and loads it via RPATH
with $ORIGIN
like this:
$ readelf -d app
Dynamic section at offset 0xe08 contains 26 entries:
Tag Type Name/Value
0x0000000000000001 (NEEDED) Shared library: [libbar.so]
0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
0x000000000000000f (RPATH) Library rpath: [$ORIGIN/lib/]
It would be nice to run it in the appropriate directory structure, made with symlinks to the executable and the libbar.so
:
$ ls -R
.:
app@ lib/
./lib:
libbar.so@
-- but the linker follows symlinks to the original file of the executable, sets $ORIGIN
to the directory of the executable file and resolves the dependency paths from there. Is it possible to make it not do this? So that directory-path-wise, in the search for lib files, the symlinks are treated as real files of the filesystem ("end-points" of the search).
Also, some reasoning to this problem:
It is convenient to have binaries set up to search for dependencies in a couple relational directories, for instance in the
$ORIGIN/
of a binary itself and also in$ORIGIN/appname_dependencies/
(so that one can just copy the binary and its' dependencies into one directory and run it, but also has a fall-back for a more complicated set-up with multiple versions of the same binary in the system).Due to the requirement of several dependency search paths,
RPATH
is the search method to use: a "slashed" name of dependency (NEEDED Shared library: [./libbar.so]
) sets only 1 search path. Also, for simplicity the dependency resolution paths should be in the binary itself.
It's nice to be able to combine all binaries (the application and all its' dependencies) into the full dependency graph with links, instead of copying the files. And symbolic links are more resilient than hard links: they link across filesystems. In fact, I have this problem in one academic environment of a linux cluster, where a hard link to parent directory cannot be done:
$ ln ../afile
ln: creating hard link `./afile' => `../afile': Invalid cross-device link
symlink dynamic-linking elf
symlink dynamic-linking elf
edited Aug 11 '16 at 15:18
xealits
asked Aug 10 '16 at 15:04
xealitsxealits
80811121
80811121
bumped to the homepage by Community♦ 3 hours ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ 3 hours ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
Are hard links a possibility?
– Satya Mishra
Aug 10 '16 at 16:44
@SatyaMishra sadly no. Hard links work indeed splendidly -- they are just like regular files for the filesystem, but don't take more space -- and that's what I need. But it would be better to have symbolic links, since they can link to files across devices/filesystems.
– xealits
Aug 10 '16 at 17:00
add a comment |
Are hard links a possibility?
– Satya Mishra
Aug 10 '16 at 16:44
@SatyaMishra sadly no. Hard links work indeed splendidly -- they are just like regular files for the filesystem, but don't take more space -- and that's what I need. But it would be better to have symbolic links, since they can link to files across devices/filesystems.
– xealits
Aug 10 '16 at 17:00
Are hard links a possibility?
– Satya Mishra
Aug 10 '16 at 16:44
Are hard links a possibility?
– Satya Mishra
Aug 10 '16 at 16:44
@SatyaMishra sadly no. Hard links work indeed splendidly -- they are just like regular files for the filesystem, but don't take more space -- and that's what I need. But it would be better to have symbolic links, since they can link to files across devices/filesystems.
– xealits
Aug 10 '16 at 17:00
@SatyaMishra sadly no. Hard links work indeed splendidly -- they are just like regular files for the filesystem, but don't take more space -- and that's what I need. But it would be better to have symbolic links, since they can link to files across devices/filesystems.
– xealits
Aug 10 '16 at 17:00
add a comment |
1 Answer
1
active
oldest
votes
If you really want to mix symbolic links like that, you could construct a configuration like this:
- move your executable to its own directory
- make a symbolic link from the "normal" location to the moved executable
- create symbolic links in the executable's directory to the shared libraries that you want to resolve
but that is exactly what I want to avoid: executable file sitting in a directory together with some particular dependency libraries, so that the dependency graph is already defined. I would like to have a directory with executables and libraries of any versions, with not colliding names (hash of the content of the binary file), and the whole dependency graph could be constructed with links to particular binaries.
– xealits
Aug 11 '16 at 23:06
The libraries don't have to be in that directory. That's what I pointed out in my answer. Alternatively, you could rewrite the dynamic loader.
– Thomas Dickey
Aug 11 '16 at 23:12
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f302589%2fhow-to-make-origin-in-rpath-not-follow-symlinks%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
If you really want to mix symbolic links like that, you could construct a configuration like this:
- move your executable to its own directory
- make a symbolic link from the "normal" location to the moved executable
- create symbolic links in the executable's directory to the shared libraries that you want to resolve
but that is exactly what I want to avoid: executable file sitting in a directory together with some particular dependency libraries, so that the dependency graph is already defined. I would like to have a directory with executables and libraries of any versions, with not colliding names (hash of the content of the binary file), and the whole dependency graph could be constructed with links to particular binaries.
– xealits
Aug 11 '16 at 23:06
The libraries don't have to be in that directory. That's what I pointed out in my answer. Alternatively, you could rewrite the dynamic loader.
– Thomas Dickey
Aug 11 '16 at 23:12
add a comment |
If you really want to mix symbolic links like that, you could construct a configuration like this:
- move your executable to its own directory
- make a symbolic link from the "normal" location to the moved executable
- create symbolic links in the executable's directory to the shared libraries that you want to resolve
but that is exactly what I want to avoid: executable file sitting in a directory together with some particular dependency libraries, so that the dependency graph is already defined. I would like to have a directory with executables and libraries of any versions, with not colliding names (hash of the content of the binary file), and the whole dependency graph could be constructed with links to particular binaries.
– xealits
Aug 11 '16 at 23:06
The libraries don't have to be in that directory. That's what I pointed out in my answer. Alternatively, you could rewrite the dynamic loader.
– Thomas Dickey
Aug 11 '16 at 23:12
add a comment |
If you really want to mix symbolic links like that, you could construct a configuration like this:
- move your executable to its own directory
- make a symbolic link from the "normal" location to the moved executable
- create symbolic links in the executable's directory to the shared libraries that you want to resolve
If you really want to mix symbolic links like that, you could construct a configuration like this:
- move your executable to its own directory
- make a symbolic link from the "normal" location to the moved executable
- create symbolic links in the executable's directory to the shared libraries that you want to resolve
answered Aug 11 '16 at 19:53
Thomas DickeyThomas Dickey
53.9k5103176
53.9k5103176
but that is exactly what I want to avoid: executable file sitting in a directory together with some particular dependency libraries, so that the dependency graph is already defined. I would like to have a directory with executables and libraries of any versions, with not colliding names (hash of the content of the binary file), and the whole dependency graph could be constructed with links to particular binaries.
– xealits
Aug 11 '16 at 23:06
The libraries don't have to be in that directory. That's what I pointed out in my answer. Alternatively, you could rewrite the dynamic loader.
– Thomas Dickey
Aug 11 '16 at 23:12
add a comment |
but that is exactly what I want to avoid: executable file sitting in a directory together with some particular dependency libraries, so that the dependency graph is already defined. I would like to have a directory with executables and libraries of any versions, with not colliding names (hash of the content of the binary file), and the whole dependency graph could be constructed with links to particular binaries.
– xealits
Aug 11 '16 at 23:06
The libraries don't have to be in that directory. That's what I pointed out in my answer. Alternatively, you could rewrite the dynamic loader.
– Thomas Dickey
Aug 11 '16 at 23:12
but that is exactly what I want to avoid: executable file sitting in a directory together with some particular dependency libraries, so that the dependency graph is already defined. I would like to have a directory with executables and libraries of any versions, with not colliding names (hash of the content of the binary file), and the whole dependency graph could be constructed with links to particular binaries.
– xealits
Aug 11 '16 at 23:06
but that is exactly what I want to avoid: executable file sitting in a directory together with some particular dependency libraries, so that the dependency graph is already defined. I would like to have a directory with executables and libraries of any versions, with not colliding names (hash of the content of the binary file), and the whole dependency graph could be constructed with links to particular binaries.
– xealits
Aug 11 '16 at 23:06
The libraries don't have to be in that directory. That's what I pointed out in my answer. Alternatively, you could rewrite the dynamic loader.
– Thomas Dickey
Aug 11 '16 at 23:12
The libraries don't have to be in that directory. That's what I pointed out in my answer. Alternatively, you could rewrite the dynamic loader.
– Thomas Dickey
Aug 11 '16 at 23:12
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f302589%2fhow-to-make-origin-in-rpath-not-follow-symlinks%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Are hard links a possibility?
– Satya Mishra
Aug 10 '16 at 16:44
@SatyaMishra sadly no. Hard links work indeed splendidly -- they are just like regular files for the filesystem, but don't take more space -- and that's what I need. But it would be better to have symbolic links, since they can link to files across devices/filesystems.
– xealits
Aug 10 '16 at 17:00