Skip to content

Commit 554dec3

Browse files
committed
do not add new string entries when changing libraries to themself
1 parent 4967cdc commit 554dec3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/patchelf.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,7 +1504,7 @@ void ElfFile<ElfFileParamNames>::replaceNeeded(const std::map<std::string, std::
15041504
if (rdi(dyn->d_tag) == DT_NEEDED) {
15051505
char * name = strTab + rdi(dyn->d_un.d_val);
15061506
auto i = libs.find(name);
1507-
if (i != libs.end()) {
1507+
if (i != libs.end() && name != i->second) {
15081508
auto replacement = i->second;
15091509

15101510
debug("replacing DT_NEEDED entry '%s' with '%s'\n", name, replacement.c_str());
@@ -1556,7 +1556,7 @@ void ElfFile<ElfFileParamNames>::replaceNeeded(const std::map<std::string, std::
15561556
while (verNeedNum > 0) {
15571557
char * file = verStrTab + rdi(need->vn_file);
15581558
auto i = libs.find(file);
1559-
if (i != libs.end()) {
1559+
if (i != libs.end() && file != i->second) {
15601560
auto replacement = i->second;
15611561

15621562
debug("replacing .gnu.version_r entry '%s' with '%s'\n", file, replacement.c_str());

0 commit comments

Comments
 (0)