Skip to content

Commit

Permalink
Merge #473
Browse files Browse the repository at this point in the history
473: Other switches might set changed as true. Use extraStrings size. #416 r=Mic92 a=brenoguim



Co-authored-by: Breno Rodrigues Guimaraes <brenorg@gmail.com>
  • Loading branch information
bors[bot] and brenoguim committed Mar 7, 2023
2 parents 12c1fe7 + fcb8fb7 commit ea2fca7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/patchelf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2163,7 +2163,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

0 comments on commit ea2fca7

Please sign in to comment.