Skip to content

Commit fcb8fb7

Browse files
committed
Other switches might set changed as true. Use extraStrings size
1 parent 69a7ae5 commit fcb8fb7

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/patchelf.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2134,7 +2134,7 @@ void ElfFile<ElfFileParamNames>::renameDynamicSymbols(const std::unordered_map<s
21342134
}
21352135
}
21362136

2137-
if (changed)
2137+
if (!extraStrings.empty())
21382138
{
21392139
auto newStrTabSize = strTab.size() + extraStrings.size();
21402140
auto& newSec = replaceSection(".dynstr", newStrTabSize);

tests/rename-dynamic-symbols.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,9 @@ ${PATCHELF} --rename-dynamic-symbols ../map *
8282

8383
echo "# Run the patched tool and libraries"
8484
env LD_BIND_NOW=1 LD_LIBRARY_PATH=${PWD} ./many-syms-main
85+
86+
# Test that other switches still work when --rename-dynamic-symbols has no effect
87+
echo "SYMBOL_THAT_DOESNT_EXIST ANOTHER_NAME" > map
88+
${PATCHELF} --set-rpath changed_rpath --rename-dynamic-symbols map --output libnewrpath.so "$full_lib_name"
89+
[ "$(${PATCHELF} --print-rpath libnewrpath.so)" = changed_rpath ] || exit 1
90+

0 commit comments

Comments
 (0)