mirror of
https://github.com/rui314/mold.git
synced 2024-12-25 17:34:02 +03:00
temporary
This commit is contained in:
parent
22f8add31c
commit
59da68d156
6
mold.h
6
mold.h
@ -951,11 +951,7 @@ struct ComdatGroup {
|
||||
|
||||
class InputFile {
|
||||
public:
|
||||
InputFile(MemoryMappedFile mb)
|
||||
: mb(mb), name(mb.name), obj(mb), ehdr(*(ElfEhdr *)mb.data) {
|
||||
elf_sections = obj.get_sections();
|
||||
is_dso = (ehdr.e_type == ET_DYN);
|
||||
}
|
||||
InputFile(MemoryMappedFile mb);
|
||||
|
||||
MemoryMappedFile mb;
|
||||
ElfFile obj;
|
||||
|
@ -3,6 +3,22 @@
|
||||
#include <cstring>
|
||||
#include <regex>
|
||||
|
||||
InputFile::InputFile(MemoryMappedFile mb)
|
||||
: mb(mb), name(mb.name), obj(mb), ehdr(*(ElfEhdr *)mb.data),
|
||||
is_dso(ehdr.e_type == ET_DYN) {
|
||||
if (mb.size < sizeof(ElfEhdr))
|
||||
error(mb.name + ": file too small");
|
||||
if (memcmp(mb.data, "\177ELF", 4))
|
||||
error(mb.name + ": not an ELF file");
|
||||
|
||||
u8 *sh_begin = mb.data + ehdr.e_shoff;
|
||||
u8 *sh_end = sh_begin + ehdr.e_shnum * sizeof(ElfShdr);
|
||||
if (mb.data + mb.size < sh_end)
|
||||
error(mb.name + ": e_shoff or e_shnum corrupted: " +
|
||||
std::to_string(mb.size) + " " + std::to_string(ehdr.e_shnum));
|
||||
elf_sections = {(ElfShdr *)sh_begin, (ElfShdr *)sh_end};
|
||||
}
|
||||
|
||||
ObjectFile::ObjectFile(MemoryMappedFile mb, std::string_view archive_name)
|
||||
: InputFile(mb), archive_name(archive_name),
|
||||
is_in_archive(archive_name != "") {
|
||||
|
Loading…
Reference in New Issue
Block a user