@@ -45,7 +45,7 @@ static bool debugMode = false;
45
45
46
46
static bool forceRPath = false ;
47
47
48
- static std::string fileName ;
48
+ static std::vector<std:: string> fileNames ;
49
49
static int pageSize = PAGESIZE;
50
50
51
51
typedef std::shared_ptr<std::vector<unsigned char >> FileContents;
@@ -1556,7 +1556,7 @@ static bool printNeeded = false;
1556
1556
static bool noDefaultLib = false ;
1557
1557
1558
1558
template <class ElfFile >
1559
- static void patchElf2 (ElfFile && elfFile)
1559
+ static void patchElf2 (ElfFile && elfFile, std::string fileName )
1560
1560
{
1561
1561
if (printInterpreter)
1562
1562
printf (" %s\n " , elfFile.getInterpreter ().c_str ());
@@ -1598,17 +1598,19 @@ static void patchElf2(ElfFile && elfFile)
1598
1598
1599
1599
static void patchElf ()
1600
1600
{
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 ());
1603
1604
1604
- debug (" Kernel page size is %u bytes\n " , getPageSize ());
1605
+ debug (" Kernel page size is %u bytes\n " , getPageSize ());
1605
1606
1606
- auto fileContents = readFile (fileName);
1607
+ auto fileContents = readFile (fileName);
1607
1608
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
+ }
1612
1614
}
1613
1615
1614
1616
@@ -1731,11 +1733,12 @@ int mainWrapped(int argc, char * * argv)
1731
1733
printf (PACKAGE_STRING " \n " );
1732
1734
return 0 ;
1733
1735
}
1734
- else break ;
1736
+ else {
1737
+ fileNames.push_back (arg);
1738
+ }
1735
1739
}
1736
1740
1737
- if (i == argc) error (" missing filename" );
1738
- fileName = argv[i];
1741
+ if (fileNames.empty ()) error (" missing filename" );
1739
1742
1740
1743
patchElf ();
1741
1744
0 commit comments