ref: 29af2173e02d3d9deff6aac96ae0155f97cfb860
parent: d3db16d8b8927794ba3ed4d5921f27731033ee8f
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Fri Jul 10 19:56:39 EDT 2015
kernel: use HDR_MAGIC constant to handle Exec header extension, make rebootcmd() handle AOUT_MAGIC macro
--- a/sys/src/9/port/rebootcmd.c
+++ b/sys/src/9/port/rebootcmd.c
@@ -70,14 +70,17 @@
text = l2be(exec.text);
data = l2be(exec.data);
- if(AOUT_MAGIC == S_MAGIC || AOUT_MAGIC == I_MAGIC){- if(magic != S_MAGIC && magic != I_MAGIC)
+ if(!(magic == AOUT_MAGIC)){+ switch(magic){+ case I_MAGIC:
+ case S_MAGIC:
+ if((I_MAGIC == AOUT_MAGIC) || (S_MAGIC == AOUT_MAGIC))
+ break;
+ default:
error(Ebadexec);
- } else if(magic != AOUT_MAGIC)
- error(Ebadexec);
-
- /* amd64 extra header */
- if(magic == S_MAGIC)
+ }
+ }
+ if(magic & HDR_MAGIC)
readn(c, &exec, 8);
/* round text out to page boundary */
--- a/sys/src/9/port/sysproc.c
+++ b/sys/src/9/port/sysproc.c
@@ -282,15 +282,16 @@
error(Ebadexec);
magic = l2be(exec.magic);
if(n == sizeof(Exec) && (magic == AOUT_MAGIC)){- text = l2be(exec.text);
entry = l2be(exec.entry);
- switch(magic){- case S_MAGIC:
+ text = l2be(exec.text);
+ if(magic & HDR_MAGIC)
text += 8;
- align = 0x200000; /* 2MB segment alignment for amd64 */
+ switch(magic){+ case S_MAGIC: /* 2MB segment alignment for amd64 */
+ align = 0x200000;
break;
- case V_MAGIC:
- align = 0x4000; /* MIPS has 16K page alignment */
+ case V_MAGIC: /* 16K segment alignment for mips */
+ align = 0x4000;
break;
}
if(text >= (USTKTOP-USTKSIZE)-(UTZERO+sizeof(Exec))
--
⑨