summaryrefslogtreecommitdiffstats
path: root/src/patchelf.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/patchelf.cc')
-rw-r--r--src/patchelf.cc21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/patchelf.cc b/src/patchelf.cc
index 5ddee41..4d299e9 100644
--- a/src/patchelf.cc
+++ b/src/patchelf.cc
@@ -238,12 +238,11 @@ static void growFile(off_t newSize)
}
-static void readFile(string fileName, mode_t * fileMode)
+static void readFile(string fileName)
{
struct stat st;
if (stat(fileName.c_str(), &st) != 0) error("stat");
fileSize = st.st_size;
- *fileMode = st.st_mode;
maxSize = fileSize + 32 * 1024 * 1024;
contents = (unsigned char *) malloc(fileSize + maxSize);
@@ -629,7 +628,7 @@ void ElfFile<ElfFileParamNames>::rewriteSectionsLibrary()
/* Write out the replaced sections. */
Elf_Off curOff = startOffset + phdrs.size() * sizeof(Elf_Phdr);
writeReplacedSections(curOff, startPage, startOffset);
- assert((off_t) curOff == startOffset + neededSpace);
+ assert(curOff == startOffset + neededSpace);
/* Move the program header to the start of the new area. */
@@ -698,7 +697,7 @@ void ElfFile<ElfFileParamNames>::rewriteSectionsExecutable()
Elf_Addr firstPage = startAddr - startOffset;
debug("first page is 0x%llx\n", (unsigned long long) firstPage);
- if ((off_t) rdi(hdr->e_shoff) < startOffset) {
+ if (rdi(hdr->e_shoff) < startOffset) {
/* The section headers occur too early in the file and would be
overwritten by the replaced sections. Move them to the end of the file
before proceeding. */
@@ -754,7 +753,7 @@ void ElfFile<ElfFileParamNames>::rewriteSectionsExecutable()
/* Write out the replaced sections. */
writeReplacedSections(curOff, firstPage, 0);
- assert((off_t) curOff == neededSpace);
+ assert(curOff == neededSpace);
rewriteHeaders(firstPage + rdi(hdr->e_phoff));
@@ -1398,7 +1397,7 @@ static bool printNeeded = false;
static bool noDefaultLib = false;
template<class ElfFile>
-static void patchElf2(ElfFile & elfFile, mode_t fileMode)
+static void patchElf2(ElfFile & elfFile)
{
elfFile.parse();
@@ -1447,9 +1446,7 @@ static void patchElf()
debug("Kernel page size is %u bytes\n", getPageSize());
- mode_t fileMode;
-
- readFile(fileName, &fileMode);
+ readFile(fileName);
/* Check the ELF header for basic validity. */
@@ -1462,13 +1459,13 @@ static void patchElf()
contents[EI_VERSION] == EV_CURRENT)
{
ElfFile<Elf32_Ehdr, Elf32_Phdr, Elf32_Shdr, Elf32_Addr, Elf32_Off, Elf32_Dyn, Elf32_Sym> elfFile;
- patchElf2(elfFile, fileMode);
+ patchElf2(elfFile);
}
else if (contents[EI_CLASS] == ELFCLASS64 &&
contents[EI_VERSION] == EV_CURRENT)
{
ElfFile<Elf64_Ehdr, Elf64_Phdr, Elf64_Shdr, Elf64_Addr, Elf64_Off, Elf64_Dyn, Elf64_Sym> elfFile;
- patchElf2(elfFile, fileMode);
+ patchElf2(elfFile);
}
else {
error("ELF executable is not 32/64-bit, little/big-endian, version 1");
@@ -1482,7 +1479,7 @@ void showHelp(const string & progName)
[--set-interpreter FILENAME]\n\
[--print-interpreter]\n\
[--print-soname]\t\tPrints 'DT_SONAME' entry of .dynamic section. Raises an error if DT_SONAME doesn't exist\n\
- [--set-soname SONAME]\t\tSets 'DT_SONAME' entry to SONAME. Raises an error if DT_SONAME doesn't exist\n\
+ [--set-soname SONAME]\t\tSets 'DT_SONAME' entry to SONAME.\n\
[--set-rpath RPATH]\n\
[--remove-rpath]\n\
[--shrink-rpath]\n\