Skip to content

Commit 0611392

Browse files
authored
Update patchelf.cc
Untested. Coding from github while my VM is acting up.
1 parent 16f13b4 commit 0611392

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/patchelf.cc

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2549,18 +2549,24 @@ static int mainWrapped(int argc, char * * argv)
25492549
renameDynamicSymbols = true;
25502550
if (++i == argc) error("missing argument");
25512551

2552-
std::ifstream infile(argv[i]);
2553-
if (!infile) error(fmt("Cannot open map file ", argv[i]));
2552+
const char* fname = argv[i];
2553+
std::ifstream infile(fname);
2554+
if (!infile) error(fmt("Cannot open map file ", fname));
25542555

2555-
std::string from, to;
2556-
while (true)
2556+
std::string line, from, to;
2557+
size_t lineCount = 1;
2558+
while (std::getline(infile, line))
25572559
{
2558-
if (!(infile >> from))
2560+
std::istringstream iss(line);
2561+
if (!(iss >> from))
25592562
break;
2560-
if (!(infile >> to))
2561-
error("Odd number of symbols in map file");
2563+
if (!(iss >> to))
2564+
error(fmt(fname, ":", lineCount, ": Map file line is missing the second element"));
25622565
if (symbolsToRenameKeys.count(from))
2563-
error(fmt("Symbol appears twice in the map file: ", from.c_str()));
2566+
error(fmt(fname, ":", lineCount, ": Name ", from, " appears twice in the map file"));
2567+
if (from.find('@') != std::string_view::npos || to.find('@') != std::string_view::npos)
2568+
error(fmt(fname, ":", lineCount, ": Name pair contains version tag: ", from, " ", to));
2569+
lineCount++;
25642570
symbolsToRename[*symbolsToRenameKeys.insert(from).first] = to;
25652571
}
25662572
}

0 commit comments

Comments
 (0)