@@ -45,7 +45,7 @@ static bool debugMode = false;
4545
4646static bool forceRPath = false ;
4747
48- static std::string fileName ;
48+ static std::vector<std:: string> fileNames ;
4949static int pageSize = PAGESIZE;
5050
5151typedef std::shared_ptr<std::vector<unsigned char >> FileContents;
@@ -1556,7 +1556,7 @@ static bool printNeeded = false;
15561556static bool noDefaultLib = false ;
15571557
15581558template <class ElfFile >
1559- static void patchElf2 (ElfFile && elfFile)
1559+ static void patchElf2 (ElfFile && elfFile, std::string fileName )
15601560{
15611561 if (printInterpreter)
15621562 printf (" %s\n " , elfFile.getInterpreter ().c_str ());
@@ -1598,17 +1598,19 @@ static void patchElf2(ElfFile && elfFile)
15981598
15991599static void patchElf ()
16001600{
1601- if (!printInterpreter && !printRPath && !printSoname && !printNeeded)
1602- debug (" patching ELF file '%s'\n " , fileName.c_str ());
1601+ for (auto fileName : fileNames) {
1602+ if (!printInterpreter && !printRPath && !printSoname && !printNeeded)
1603+ debug (" patching ELF file '%s'\n " , fileName.c_str ());
16031604
1604- debug (" Kernel page size is %u bytes\n " , getPageSize ());
1605+ debug (" Kernel page size is %u bytes\n " , getPageSize ());
16051606
1606- auto fileContents = readFile (fileName);
1607+ auto fileContents = readFile (fileName);
16071608
1608- if (getElfType (fileContents).is32Bit )
1609- patchElf2 (ElfFile<Elf32_Ehdr, Elf32_Phdr, Elf32_Shdr, Elf32_Addr, Elf32_Off, Elf32_Dyn, Elf32_Sym, Elf32_Verneed>(fileContents));
1610- else
1611- patchElf2 (ElfFile<Elf64_Ehdr, Elf64_Phdr, Elf64_Shdr, Elf64_Addr, Elf64_Off, Elf64_Dyn, Elf64_Sym, Elf64_Verneed>(fileContents));
1609+ if (getElfType (fileContents).is32Bit )
1610+ patchElf2 (ElfFile<Elf32_Ehdr, Elf32_Phdr, Elf32_Shdr, Elf32_Addr, Elf32_Off, Elf32_Dyn, Elf32_Sym, Elf32_Verneed>(fileContents), fileName);
1611+ else
1612+ patchElf2 (ElfFile<Elf64_Ehdr, Elf64_Phdr, Elf64_Shdr, Elf64_Addr, Elf64_Off, Elf64_Dyn, Elf64_Sym, Elf64_Verneed>(fileContents), fileName);
1613+ }
16121614}
16131615
16141616
@@ -1731,11 +1733,12 @@ int mainWrapped(int argc, char * * argv)
17311733 printf (PACKAGE_STRING " \n " );
17321734 return 0 ;
17331735 }
1734- else break ;
1736+ else {
1737+ fileNames.push_back (arg);
1738+ }
17351739 }
17361740
1737- if (i == argc) error (" missing filename" );
1738- fileName = argv[i];
1741+ if (fileNames.empty ()) error (" missing filename" );
17391742
17401743 patchElf ();
17411744
0 commit comments