kernel: use HDR_MAGIC constant to handle Exec header extension, make rebootcmd() handle AOUT_MAGIC macro
This commit is contained in:
parent
3ca9ac70c4
commit
4ec93f94c9
2 changed files with 17 additions and 13 deletions
|
@ -70,14 +70,17 @@ rebootcmd(int argc, char *argv[])
|
||||||
text = l2be(exec.text);
|
text = l2be(exec.text);
|
||||||
data = l2be(exec.data);
|
data = l2be(exec.data);
|
||||||
|
|
||||||
if(AOUT_MAGIC == S_MAGIC || AOUT_MAGIC == I_MAGIC){
|
if(!(magic == AOUT_MAGIC)){
|
||||||
if(magic != S_MAGIC && magic != I_MAGIC)
|
switch(magic){
|
||||||
|
case I_MAGIC:
|
||||||
|
case S_MAGIC:
|
||||||
|
if((I_MAGIC == AOUT_MAGIC) || (S_MAGIC == AOUT_MAGIC))
|
||||||
|
break;
|
||||||
|
default:
|
||||||
error(Ebadexec);
|
error(Ebadexec);
|
||||||
} else if(magic != AOUT_MAGIC)
|
}
|
||||||
error(Ebadexec);
|
}
|
||||||
|
if(magic & HDR_MAGIC)
|
||||||
/* amd64 extra header */
|
|
||||||
if(magic == S_MAGIC)
|
|
||||||
readn(c, &exec, 8);
|
readn(c, &exec, 8);
|
||||||
|
|
||||||
/* round text out to page boundary */
|
/* round text out to page boundary */
|
||||||
|
|
|
@ -282,15 +282,16 @@ sysexec(va_list list)
|
||||||
error(Ebadexec);
|
error(Ebadexec);
|
||||||
magic = l2be(exec.magic);
|
magic = l2be(exec.magic);
|
||||||
if(n == sizeof(Exec) && (magic == AOUT_MAGIC)){
|
if(n == sizeof(Exec) && (magic == AOUT_MAGIC)){
|
||||||
text = l2be(exec.text);
|
|
||||||
entry = l2be(exec.entry);
|
entry = l2be(exec.entry);
|
||||||
switch(magic){
|
text = l2be(exec.text);
|
||||||
case S_MAGIC:
|
if(magic & HDR_MAGIC)
|
||||||
text += 8;
|
text += 8;
|
||||||
align = 0x200000; /* 2MB segment alignment for amd64 */
|
switch(magic){
|
||||||
|
case S_MAGIC: /* 2MB segment alignment for amd64 */
|
||||||
|
align = 0x200000;
|
||||||
break;
|
break;
|
||||||
case V_MAGIC:
|
case V_MAGIC: /* 16K segment alignment for mips */
|
||||||
align = 0x4000; /* MIPS has 16K page alignment */
|
align = 0x4000;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(text >= (USTKTOP-USTKSIZE)-(UTZERO+sizeof(Exec))
|
if(text >= (USTKTOP-USTKSIZE)-(UTZERO+sizeof(Exec))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue