From ec46643124d144b49bb1baebd5d79e9abdea09c2 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 9 Sep 2018 14:29:34 +0200 Subject: [PATCH] Allow the ELF processor flags to be set. Generate MIPS ELF executables, not PowerPC ones. --- plat/linuxmips/descr | 2 +- util/amisc/aelflod.1 | 4 ++++ util/amisc/aelflod.c | 11 ++++++++--- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/plat/linuxmips/descr b/plat/linuxmips/descr index ad7f5180f..1afa470a7 100644 --- a/plat/linuxmips/descr +++ b/plat/linuxmips/descr @@ -82,6 +82,6 @@ name cv from .out to .exe program {EM}/bin/aelflod - args -m20 -b < > + args -m8 -l -f0x70000000 < > outfile linuxmips.exe end diff --git a/util/amisc/aelflod.1 b/util/amisc/aelflod.1 index e6af7ef2e..9c6134b33 100644 --- a/util/amisc/aelflod.1 +++ b/util/amisc/aelflod.1 @@ -35,6 +35,10 @@ The default value is \fI3\fP for Intel 386 (i386). Other values are \fI4\fP for Motorola 68000 (m68k) and \fI20\fP for PowerPC. .TP +.BI \-f number +Set the processor flags in the ELF header to \fInumber\fP. +The default value is 0. +.TP .B \-v Be verbose. .PP diff --git a/util/amisc/aelflod.c b/util/amisc/aelflod.c index dbaafc9b5..de4bcedd8 100644 --- a/util/amisc/aelflod.c +++ b/util/amisc/aelflod.c @@ -33,6 +33,7 @@ int bigendian = 0; int elfabi = 3; /* abi = Linux */ int elfmachine = 3; /* machine = EM_386 */ +uint32_t elfflags = 0; /* elf processor flags */ /* Header and section table of an ack object file. */ @@ -643,7 +644,7 @@ int main(int argc, char* argv[]) switch (argv[1][1]) { case 'a': - elfabi = atoi(&argv[1][2]); + elfabi = strtoul(&argv[1][2], NULL, 0); break; case 'b': @@ -660,7 +661,11 @@ int main(int argc, char* argv[]) break; case 'm': - elfmachine = atoi(&argv[1][2]); + elfmachine = strtoul(&argv[1][2], NULL, 0); + break; + + case 'f': + elfflags = strtoul(&argv[1][2], NULL, 0); break; case 'v': @@ -808,7 +813,7 @@ int main(int argc, char* argv[]) emit32(outsect[TEXT].os_base); /* entry point */ emit32(ELF_HEADER_SIZE); /* program header offset */ emit32(sh_offset); /* section header offset */ - emit32(0); /* flags */ + emit32(elfflags); /* flags */ emit16(ELF_HEADER_SIZE); /* elf header size */ emit16(PROGRAM_HEADER_SIZE); /* program header entry size */ emit16(1); /* number of program header entries */ -- 2.34.1