Merged kernel support for ELF executable format from karolina.lindqvist.
Now kernel can directly run executables generated by gcc.
This commit is contained in:
@@ -55,7 +55,7 @@ int fgethdr (text, h)
|
||||
register FILE *text;
|
||||
register struct exec *h;
|
||||
{
|
||||
h->a_magic = fgetword (text);
|
||||
h->a_midmag = fgetword (text);
|
||||
h->a_text = fgetword (text);
|
||||
h->a_data = fgetword (text);
|
||||
h->a_bss = fgetword (text);
|
||||
@@ -235,7 +235,7 @@ void disasm (fname)
|
||||
return;
|
||||
}
|
||||
if (rflag) {
|
||||
if (hdr.a_magic != RMAGIC) {
|
||||
if (N_GETMAGIC(hdr) != RMAGIC) {
|
||||
fprintf (stderr, "aout: %s is not relocatable\n",
|
||||
fname);
|
||||
rflag = 0;
|
||||
@@ -250,9 +250,9 @@ void disasm (fname)
|
||||
}
|
||||
printf ("File %s:\n", fname);
|
||||
printf (" a_magic = %08x (%s)\n", hdr.a_magic,
|
||||
hdr.a_magic == RMAGIC ? "relocatable" :
|
||||
hdr.a_magic == OMAGIC ? "OMAGIC" :
|
||||
hdr.a_magic == NMAGIC ? "NMAGIC" : "unknown");
|
||||
N_GETMAGIC(hdr) == RMAGIC ? "relocatable" :
|
||||
N_GETMAGIC(hdr) == OMAGIC ? "OMAGIC" :
|
||||
N_GETMAGIC(hdr) == NMAGIC ? "NMAGIC" : "unknown");
|
||||
printf (" a_text = %08x (%u bytes)\n", hdr.a_text, hdr.a_text);
|
||||
printf (" a_data = %08x (%u bytes)\n", hdr.a_data, hdr.a_data);
|
||||
printf (" a_bss = %08x (%u bytes)\n", hdr.a_bss, hdr.a_bss);
|
||||
@@ -261,7 +261,7 @@ void disasm (fname)
|
||||
printf (" a_syms = %08x (%u bytes)\n", hdr.a_syms, hdr.a_syms);
|
||||
printf (" a_entry = %08x\n", hdr.a_entry);
|
||||
|
||||
addr = (hdr.a_magic == RMAGIC) ? 0 : USER_CODE_START;
|
||||
addr = ((hdr.a_magic) == RMAGIC) ? 0 : USER_CODE_START;
|
||||
|
||||
if (hdr.a_text > 0) {
|
||||
printf ("\nSection .text:\n");
|
||||
|
||||
@@ -2339,7 +2339,7 @@ void makeheader (rtsize, rdsize)
|
||||
{
|
||||
struct exec hdr;
|
||||
|
||||
hdr.a_magic = RMAGIC;
|
||||
hdr.a_midmag = RMAGIC;
|
||||
hdr.a_text = count [STEXT];
|
||||
hdr.a_data = count [SDATA] + count [SSTRNG];
|
||||
hdr.a_bss = count [SBSS];
|
||||
|
||||
@@ -172,7 +172,7 @@ int fgethdr (text, h)
|
||||
register FILE *text;
|
||||
register struct exec *h;
|
||||
{
|
||||
h->a_magic = fgetword (text);
|
||||
h->a_midmag = fgetword (text);
|
||||
h->a_text = fgetword (text);
|
||||
h->a_data = fgetword (text);
|
||||
h->a_bss = fgetword (text);
|
||||
@@ -860,7 +860,7 @@ void readhdr (loc)
|
||||
fseek (text, loc, 0);
|
||||
if (! fgethdr (text, &filhdr))
|
||||
error (2, "bad format");
|
||||
if (filhdr.a_magic != RMAGIC)
|
||||
if (N_GETMAGIC(filhdr) != RMAGIC)
|
||||
error (2, "bad magic");
|
||||
if (filhdr.a_text % W)
|
||||
error (2, "bad length of text");
|
||||
@@ -880,7 +880,7 @@ int load1 (loc, libflg, nloc)
|
||||
int savindex, ndef, type, symlen, nsymbol;
|
||||
|
||||
readhdr (loc);
|
||||
if (filhdr.a_magic != RMAGIC) {
|
||||
if (N_GETMAGIC(filhdr) != RMAGIC) {
|
||||
error (1, "file not relocatable");
|
||||
return (0);
|
||||
}
|
||||
@@ -1293,7 +1293,7 @@ void setupout ()
|
||||
} else {
|
||||
close(fd);
|
||||
}
|
||||
|
||||
|
||||
tcreat (&toutb, 1);
|
||||
tcreat (&doutb, 1);
|
||||
|
||||
@@ -1494,7 +1494,7 @@ void finishout ()
|
||||
while (ssize++ % W)
|
||||
putc (0, outb);
|
||||
}
|
||||
filhdr.a_magic = output_relinfo ? RMAGIC : OMAGIC;
|
||||
filhdr.a_midmag = output_relinfo ? RMAGIC : OMAGIC;
|
||||
filhdr.a_text = tsize;
|
||||
filhdr.a_data = dsize;
|
||||
filhdr.a_bss = bsize;
|
||||
|
||||
@@ -35,7 +35,7 @@ strip(name)
|
||||
status = 1;
|
||||
goto out;
|
||||
}
|
||||
if (head.a_syms == 0 && head.a_magic != RMAGIC)
|
||||
if (head.a_syms == 0 && (head.a_magic) != RMAGIC)
|
||||
goto out;
|
||||
|
||||
size = N_DATOFF(head) + head.a_data;
|
||||
@@ -45,7 +45,7 @@ strip(name)
|
||||
status = 1;
|
||||
goto out;
|
||||
}
|
||||
head.a_magic = OMAGIC;
|
||||
head.a_midmag = OMAGIC;
|
||||
head.a_reltext = 0;
|
||||
head.a_reldata = 0;
|
||||
head.a_syms = 0;
|
||||
|
||||
Reference in New Issue
Block a user