BUG: Do not mangle symbols when editing RPATHs
In ELF binaries the .dynstr string table is used both for the RPATH string and for program symbols. If a symbol name happens to match the end of the build-tree RPATH string the linker is allowed to merge the symbols. We must not allow this when the RPATH string will be replaced during installation because it will mangle the symbol. Therefore we always pad the end of the build-tree RPATH with ':' if it will be replaced. Tools tend not to use ':' at the end of symbol names, so it is unlikely to conflict. See issue #9130.
This commit is contained in:
parent
42c4a1d71f
commit
d6dd3e91a4
|
@ -1705,10 +1705,15 @@ std::string cmComputeLinkInformation::GetRPathString(bool for_install)
|
|||
rpath += *ri;
|
||||
}
|
||||
|
||||
// If the rpath will be replaced at install time make sure it is
|
||||
// long enough now.
|
||||
// If the rpath will be replaced at install time, prepare space.
|
||||
if(!for_install && this->RuntimeUseChrpath)
|
||||
{
|
||||
// Always add one trailing separator so the linker does not re-use
|
||||
// the rpath .dynstr entry for a symbol name that happens to match
|
||||
// the end of the rpath string.
|
||||
rpath += this->GetRuntimeSep();
|
||||
|
||||
// Make sure it is long enough to hold the replacement value.
|
||||
std::string::size_type minLength = this->GetChrpathString().length();
|
||||
while(rpath.length() < minLength)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue