From 12511797aa829ce4d79e86d82e1277d1d2ce6f1a Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 24 Nov 2021 10:45:01 -0500 Subject: Fix bin2obj compile error --- tools/bin2obj/bin2obj.cpp | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) (limited to 'tools/bin2obj/bin2obj.cpp') diff --git a/tools/bin2obj/bin2obj.cpp b/tools/bin2obj/bin2obj.cpp index 160bb2d2..ec5ba065 100644 --- a/tools/bin2obj/bin2obj.cpp +++ b/tools/bin2obj/bin2obj.cpp @@ -2,6 +2,7 @@ #include #include #include +#include extern "C" { #include "elf.h" } @@ -188,27 +189,28 @@ int main(int argc, char** argv) { binfile.seekg(0); // Elf header - Elf32_Ehdr ehdr = { - .e_ident = { - ELFMAG0, // EI_MAG0 - ELFMAG1, // EI_MAG1 - ELFMAG2, // EI_MAG2 - ELFMAG3, // EI_MAG3 - ELFCLASS32, // EI_CLASS - endian, // EI_DATA - EV_CURRENT, // EI_VERSION - ELFOSABI_NONE, // EI_OSABI - 0, // EI_ABIVERSION - }, - .e_type = ET_REL, - .e_machine = proc, - .e_version = EV_CURRENT, - .e_shoff = sizeof(Elf32_Ehdr), - .e_ehsize = sizeof(Elf32_Ehdr), - .e_shentsize = sizeof(Elf32_Shdr), - .e_shnum = 5, - .e_shstrndx = 1, + Elf32_Ehdr ehdr; + + static const unsigned char _eident[EI_NIDENT] { + ELFMAG0, // EI_MAG0 + ELFMAG1, // EI_MAG1 + ELFMAG2, // EI_MAG2 + ELFMAG3, // EI_MAG3 + ELFCLASS32, // EI_CLASS + endian, // EI_DATA + EV_CURRENT, // EI_VERSION + ELFOSABI_NONE, // EI_OSABI + 0, // EI_ABIVERSION }; + memcpy(ehdr.e_ident, _eident, EI_NIDENT); + ehdr.e_type = ET_REL; + ehdr.e_machine = proc; + ehdr.e_version = EV_CURRENT; + ehdr.e_shoff = sizeof(Elf32_Ehdr); + ehdr.e_ehsize = sizeof(Elf32_Ehdr); + ehdr.e_shentsize = sizeof(Elf32_Shdr); + ehdr.e_shnum = 5; + ehdr.e_shstrndx = 1; // Five sections: NULL, user section, symtab, strtab, shstrtab Elf32_Shdr shdr[5] = {}; -- cgit v1.2.3