mirror of
https://github.com/NixOS/patchelf.git
synced 2025-10-22 16:17:50 +08:00
* Use the e_type field instead of trying to guess whether we’re
dealing with an executable or dynamic library. Fixes NIXPKGS-98.
This commit is contained in:
@@ -579,7 +579,7 @@ void ElfFile<ElfFileParamNames>::rewriteSectionsLibrary()
|
|||||||
|
|
||||||
|
|
||||||
/* Add a segment that maps the replaced sections and program
|
/* Add a segment that maps the replaced sections and program
|
||||||
headers into memory.. */
|
headers into memory. */
|
||||||
phdrs.resize(rdi(hdr->e_phnum) + 1);
|
phdrs.resize(rdi(hdr->e_phnum) + 1);
|
||||||
wri(hdr->e_phnum, rdi(hdr->e_phnum) + 1);
|
wri(hdr->e_phnum, rdi(hdr->e_phnum) + 1);
|
||||||
Elf_Phdr & phdr = phdrs[rdi(hdr->e_phnum) - 1];
|
Elf_Phdr & phdr = phdrs[rdi(hdr->e_phnum) - 1];
|
||||||
@@ -725,13 +725,13 @@ void ElfFile<ElfFileParamNames>::rewriteSections()
|
|||||||
debug("replacing section `%s' with size %d\n",
|
debug("replacing section `%s' with size %d\n",
|
||||||
i->first.c_str(), i->second.size());
|
i->first.c_str(), i->second.size());
|
||||||
|
|
||||||
if (!findSection2(".interp")) {
|
if (rdi(hdr->e_type) == ET_DYN) {
|
||||||
debug("no .interp section; this is a dynamic library\n");
|
debug("this is a dynamic library\n");
|
||||||
rewriteSectionsLibrary();
|
rewriteSectionsLibrary();
|
||||||
} else {
|
} else if (rdi(hdr->e_type) == ET_EXEC) {
|
||||||
debug("found .interp section; this is an executable\n");
|
debug("this is an executable\n");
|
||||||
rewriteSectionsExecutable();
|
rewriteSectionsExecutable();
|
||||||
}
|
} else error("unknown ELF type");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user