Skip to content

Other switches might set changed as true. Use extraStrings size. #416 #473

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/patchelf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2134,7 +2134,7 @@ void ElfFile<ElfFileParamNames>::renameDynamicSymbols(const std::unordered_map<s
}
}

if (changed)
if (!extraStrings.empty())
{
auto newStrTabSize = strTab.size() + extraStrings.size();
auto& newSec = replaceSection(".dynstr", newStrTabSize);
Expand Down
6 changes: 6 additions & 0 deletions tests/rename-dynamic-symbols.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,9 @@ ${PATCHELF} --rename-dynamic-symbols ../map *

echo "# Run the patched tool and libraries"
env LD_BIND_NOW=1 LD_LIBRARY_PATH=${PWD} ./many-syms-main

# Test that other switches still work when --rename-dynamic-symbols has no effect
echo "SYMBOL_THAT_DOESNT_EXIST ANOTHER_NAME" > map
${PATCHELF} --set-rpath changed_rpath --rename-dynamic-symbols map --output libnewrpath.so "$full_lib_name"
[ "$(${PATCHELF} --print-rpath libnewrpath.so)" = changed_rpath ] || exit 1