|
@@ -17,6 +17,7 @@
|
|
|
|
|
|
#include "../port/edf.h"
|
|
|
#include <a.out.h>
|
|
|
+#include "elf.h"
|
|
|
#include "kexec.h"
|
|
|
|
|
|
|
|
@@ -45,10 +46,23 @@ l2be(int32_t l)
|
|
|
return (cp[0]<<24) | (cp[1]<<16) | (cp[2]<<8) | cp[3];
|
|
|
}
|
|
|
|
|
|
+/*
|
|
|
typedef struct {
|
|
|
Exec;
|
|
|
uint64_t hdr[1];
|
|
|
} Khdr;
|
|
|
+*/
|
|
|
+
|
|
|
+typedef struct {
|
|
|
+ union{
|
|
|
+ struct {
|
|
|
+ Exec; /* a.out.h */
|
|
|
+ uint64_t hdr[1];
|
|
|
+ };
|
|
|
+ E64hdr; /* elf */
|
|
|
+ } e;
|
|
|
+ int32_t dummy; /* padding to ensure extra long */
|
|
|
+} Khdr;
|
|
|
|
|
|
enum {
|
|
|
AsmNONE = 0,
|
|
@@ -205,23 +219,23 @@ kforkexecac(Proc *p, int core, char *ufile, char **argv)
|
|
|
}
|
|
|
|
|
|
// p = (char*)&hdr;
|
|
|
- magic = l2be(hdr.magic);
|
|
|
+ magic = l2be(hdr.e.magic);
|
|
|
DBG("badexec3\n");
|
|
|
|
|
|
if(hdrsz != sizeof(Khdr) || magic != AOUT_MAGIC || magic != ELF_MAGIC)
|
|
|
error(Ebadexec);
|
|
|
if(magic & HDR_MAGIC){
|
|
|
- entry = vl2be(hdr.hdr[0]);
|
|
|
+ entry = vl2be(hdr.e.hdr[0]);
|
|
|
hdrsz = sizeof(Khdr);
|
|
|
}
|
|
|
else{
|
|
|
- entry = l2be(hdr.entry);
|
|
|
+ entry = l2be(hdr.e.entry);
|
|
|
hdrsz = sizeof(Exec);
|
|
|
}
|
|
|
|
|
|
- textsz = l2be(hdr.text);
|
|
|
- datasz = l2be(hdr.data);
|
|
|
- bsssz = l2be(hdr.bss);
|
|
|
+ textsz = l2be(hdr.e.text);
|
|
|
+ datasz = l2be(hdr.e.data);
|
|
|
+ bsssz = l2be(hdr.e.bss);
|
|
|
|
|
|
tbase = p->seg[TSEG]->base;
|
|
|
tsize = tbase - p->seg[TSEG]->top;
|
|
@@ -255,7 +269,6 @@ kforkexecac(Proc *p, int core, char *ufile, char **argv)
|
|
|
DBG("kexec: testing if sizes overflow limits\n");
|
|
|
if(textsz >= textlim || datasz > datalim || bsssz > bsslim)
|
|
|
error(Ebadexec);
|
|
|
-
|
|
|
DBG("kexec: do the top of the segments overflow limits?\n");
|
|
|
if(textlim >= tbase+tsize || datalim >= dbase+dsize || bsslim >= bbase+bsize)
|
|
|
error(Ebadexec);
|