Allow the ELF processor flags to be set. Generate MIPS ELF executables, not

PowerPC ones.
This commit is contained in:
David Given 2018-09-09 14:29:34 +02:00
parent 5dfef6f180
commit ec46643124
3 changed files with 13 additions and 4 deletions

View file

@ -82,6 +82,6 @@ name cv
from .out from .out
to .exe to .exe
program {EM}/bin/aelflod program {EM}/bin/aelflod
args -m20 -b < > args -m8 -l -f0x70000000 < >
outfile linuxmips.exe outfile linuxmips.exe
end end

View file

@ -35,6 +35,10 @@ The default value is \fI3\fP for Intel 386 (i386).
Other values are \fI4\fP for Motorola 68000 (m68k) Other values are \fI4\fP for Motorola 68000 (m68k)
and \fI20\fP for PowerPC. and \fI20\fP for PowerPC.
.TP .TP
.BI \-f number
Set the processor flags in the ELF header to \fInumber\fP.
The default value is 0.
.TP
.B \-v .B \-v
Be verbose. Be verbose.
.PP .PP

View file

@ -33,6 +33,7 @@
int bigendian = 0; int bigendian = 0;
int elfabi = 3; /* abi = Linux */ int elfabi = 3; /* abi = Linux */
int elfmachine = 3; /* machine = EM_386 */ int elfmachine = 3; /* machine = EM_386 */
uint32_t elfflags = 0; /* elf processor flags */
/* Header and section table of an ack object file. */ /* Header and section table of an ack object file. */
@ -643,7 +644,7 @@ int main(int argc, char* argv[])
switch (argv[1][1]) switch (argv[1][1])
{ {
case 'a': case 'a':
elfabi = atoi(&argv[1][2]); elfabi = strtoul(&argv[1][2], NULL, 0);
break; break;
case 'b': case 'b':
@ -660,7 +661,11 @@ int main(int argc, char* argv[])
break; break;
case 'm': 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; break;
case 'v': case 'v':
@ -808,7 +813,7 @@ int main(int argc, char* argv[])
emit32(outsect[TEXT].os_base); /* entry point */ emit32(outsect[TEXT].os_base); /* entry point */
emit32(ELF_HEADER_SIZE); /* program header offset */ emit32(ELF_HEADER_SIZE); /* program header offset */
emit32(sh_offset); /* section header offset */ emit32(sh_offset); /* section header offset */
emit32(0); /* flags */ emit32(elfflags); /* flags */
emit16(ELF_HEADER_SIZE); /* elf header size */ emit16(ELF_HEADER_SIZE); /* elf header size */
emit16(PROGRAM_HEADER_SIZE); /* program header entry size */ emit16(PROGRAM_HEADER_SIZE); /* program header entry size */
emit16(1); /* number of program header entries */ emit16(1); /* number of program header entries */