mirror of
https://github.com/rui314/mold.git
synced 2024-11-11 16:58:12 +03:00
wip
This commit is contained in:
parent
53f4a7f03c
commit
ca30fa7e55
22
elf.h
22
elf.h
@ -485,6 +485,9 @@ template <typename E> struct ElfChdr;
|
||||
|
||||
struct X86_64 {
|
||||
static constexpr bool is_rela = true;
|
||||
static constexpr bool is_64 = true;
|
||||
static constexpr bool is_le = true;
|
||||
static constexpr u32 e_machine = EM_X86_64;
|
||||
};
|
||||
|
||||
template <> struct ElfSym<X86_64> : public Elf64Sym {};
|
||||
@ -498,3 +501,22 @@ template <> struct ElfVernaux<X86_64> : public Elf64Vernaux {};
|
||||
template <> struct ElfVerdef<X86_64> : public Elf64Verdef {};
|
||||
template <> struct ElfVerdaux<X86_64> : public Elf64Verdaux {};
|
||||
template <> struct ElfChdr<X86_64> : public Elf64Chdr {};
|
||||
|
||||
struct I386 {
|
||||
static constexpr bool is_rela = false;
|
||||
static constexpr bool is_64 = false;
|
||||
static constexpr bool is_le = true;
|
||||
static constexpr u32 e_machine = EM_386;
|
||||
};
|
||||
|
||||
template <> struct ElfSym<I386> : public Elf32Sym {};
|
||||
template <> struct ElfShdr<I386> : public Elf32Shdr {};
|
||||
template <> struct ElfEhdr<I386> : public Elf32Ehdr {};
|
||||
template <> struct ElfPhdr<I386> : public Elf32Phdr {};
|
||||
template <> struct ElfRel<I386> : public Elf32Rel {};
|
||||
template <> struct ElfDyn<I386> : public Elf32Dyn {};
|
||||
template <> struct ElfVerneed<I386> : public Elf64Verneed {};
|
||||
template <> struct ElfVernaux<I386> : public Elf64Vernaux {};
|
||||
template <> struct ElfVerdef<I386> : public Elf64Verdef {};
|
||||
template <> struct ElfVerdaux<I386> : public Elf64Verdaux {};
|
||||
template <> struct ElfChdr<I386> : public Elf32Chdr {};
|
||||
|
@ -25,11 +25,11 @@ void OutputEhdr<E>::copy_buf(Context<E> &ctx) {
|
||||
memset(&hdr, 0, sizeof(hdr));
|
||||
|
||||
memcpy(&hdr.e_ident, "\177ELF", 4);
|
||||
hdr.e_ident[EI_CLASS] = ELFCLASS64;
|
||||
hdr.e_ident[EI_DATA] = ELFDATA2LSB;
|
||||
hdr.e_ident[EI_CLASS] = E::is_64 ? ELFCLASS64 : ELFCLASS32;
|
||||
hdr.e_ident[EI_DATA] = E::is_le ? ELFDATA2LSB : ELFDATA2MSB;
|
||||
hdr.e_ident[EI_VERSION] = EV_CURRENT;
|
||||
hdr.e_type = ctx.arg.pic ? ET_DYN : ET_EXEC;
|
||||
hdr.e_machine = EM_X86_64;
|
||||
hdr.e_machine = E::e_machine;
|
||||
hdr.e_version = EV_CURRENT;
|
||||
if (!ctx.arg.entry.empty())
|
||||
hdr.e_entry = Symbol<E>::intern(ctx, ctx.arg.entry)->get_addr(ctx);
|
||||
|
Loading…
Reference in New Issue
Block a user