summaryrefslogtreecommitdiff
path: root/user
diff options
context:
space:
mode:
Diffstat (limited to 'user')
-rw-r--r--user/user.ld36
-rw-r--r--user/usertests.c111
2 files changed, 105 insertions, 42 deletions
diff --git a/user/user.ld b/user/user.ld
new file mode 100644
index 0000000..0ca922b
--- /dev/null
+++ b/user/user.ld
@@ -0,0 +1,36 @@
+OUTPUT_ARCH( "riscv" )
+ENTRY( _main )
+
+
+SECTIONS
+{
+ . = 0x0;
+
+ .text : {
+ *(.text .text.*)
+ }
+
+ .rodata : {
+ . = ALIGN(16);
+ *(.srodata .srodata.*) /* do not need to distinguish this from .rodata */
+ . = ALIGN(16);
+ *(.rodata .rodata.*)
+ . = ALIGN(0x1000);
+ }
+
+ .data : {
+ . = ALIGN(16);
+ *(.sdata .sdata.*) /* do not need to distinguish this from .data */
+ . = ALIGN(16);
+ *(.data .data.*)
+ }
+
+ .bss : {
+ . = ALIGN(16);
+ *(.sbss .sbss.*) /* do not need to distinguish this from .bss */
+ . = ALIGN(16);
+ *(.bss .bss.*)
+ }
+
+ PROVIDE(end = .);
+}
diff --git a/user/usertests.c b/user/usertests.c
index 60d1762..7c31013 100644
--- a/user/usertests.c
+++ b/user/usertests.c
@@ -2508,17 +2508,40 @@ stacktest(char *s)
exit(xstatus);
}
+// check that writes to text segment fault
+void
+texttest(char *s)
+{
+ int pid;
+ int xstatus;
+
+ pid = fork();
+ if(pid == 0) {
+ volatile int *addr = (int *) 0;
+ *addr = 10;
+ exit(1);
+ } else if(pid < 0){
+ printf("%s: fork failed\n", s);
+ exit(1);
+ }
+ wait(&xstatus);
+ if(xstatus == -1) // kernel killed child?
+ exit(0);
+ else
+ exit(xstatus);
+}
+
// regression test. copyin(), copyout(), and copyinstr() used to cast
// the virtual page address to uint, which (with certain wild system
// call arguments) resulted in a kernel page faults.
+void *big = (void*) 0xeaeb0b5b00002f5e;
void
pgbug(char *s)
{
char *argv[1];
argv[0] = 0;
- exec((char*)0xeaeb0b5b00002f5e, argv);
-
- pipe((int*)0xeaeb0b5b00002f5e);
+ exec(big, argv);
+ pipe(big);
exit(0);
}
@@ -2607,6 +2630,7 @@ sbrklast(char *s)
exit(1);
}
+
// does sbrk handle signed int32 wrap-around with
// negative arguments?
void
@@ -2617,6 +2641,7 @@ sbrk8000(char *s)
*(top-1) = *(top-1) + 1;
}
+
// regression test. does write() with an invalid buffer pointer cause
// a block to be allocated for a file that is then not freed when the
// file is deleted? if the kernel has this bug, it will panic: balloc:
@@ -2896,9 +2921,6 @@ main(int argc, char *argv[])
void (*f)(char *);
char *s;
} tests[] = {
- {diskfull, "diskfull"},
- {manywrites, "manywrites"},
- {execout, "execout"},
{copyin, "copyin"},
{copyout, "copyout"},
{copyinstr1, "copyinstr1"},
@@ -2908,58 +2930,63 @@ main(int argc, char *argv[])
{truncate1, "truncate1"},
{truncate2, "truncate2"},
{truncate3, "truncate3"},
- {reparent2, "reparent2"},
- {pgbug, "pgbug" },
- {sbrkbugs, "sbrkbugs" },
- // {badwrite, "badwrite" },
- {badarg, "badarg" },
+ {openiputtest, "openiput"},
+ {exitiputtest, "exitiput"},
+ {iputtest, "iput"},
+ {opentest, "opentest"},
+ {writetest, "writetest"},
+ {writebig, "writebig"},
+ {createtest, "createtest"},
+ {dirtest, "dirtest"},
+ {exectest, "exectest"},
+ {pipe1, "pipe1"},
+ {killstatus, "killstatus"},
+ {preempt, "preempt"},
+ {exitwait, "exitwait"},
{reparent, "reparent" },
{twochildren, "twochildren"},
{forkfork, "forkfork"},
{forkforkfork, "forkforkfork"},
- {argptest, "argptest"},
+ {reparent2, "reparent2"},
+ {mem, "mem"},
+ {sharedfd, "sharedfd"},
+ {fourfiles, "fourfiles"},
{createdelete, "createdelete"},
- {linkunlink, "linkunlink"},
- {linktest, "linktest"},
{unlinkread, "unlinkread"},
+ {linktest, "linktest"},
{concreate, "concreate"},
+ {linkunlink, "linkunlink"},
+ {bigdir, "bigdir"}, // slow
{subdir, "subdir"},
- {fourfiles, "fourfiles"},
- {sharedfd, "sharedfd"},
- {dirtest, "dirtest"},
- {exectest, "exectest"},
- {bigargtest, "bigargtest"},
{bigwrite, "bigwrite"},
- {bsstest, "bsstest"},
+ {manywrites, "manywrites"},
+ {bigfile, "bigfile"},
+ {fourteen, "fourteen"},
+ {rmdot, "rmdot"},
+ {dirfile, "dirfile"},
+ {iref, "iref"},
+ {forktest, "forktest"},
{sbrkbasic, "sbrkbasic"},
{sbrkmuch, "sbrkmuch"},
{kernmem, "kernmem"},
+ {MAXVAplus, "MAXVAplus"},
{sbrkfail, "sbrkfail"},
{sbrkarg, "sbrkarg"},
- {sbrklast, "sbrklast"},
- {sbrk8000, "sbrk8000"},
{validatetest, "validatetest"},
+ {bsstest, "bsstest"},
+ {bigargtest, "bigargtest"},
+ {argptest, "argptest"},
{stacktest, "stacktest"},
- {opentest, "opentest"},
- {writetest, "writetest"},
- {writebig, "writebig"},
- {createtest, "createtest"},
- {openiputtest, "openiput"},
- {exitiputtest, "exitiput"},
- {iputtest, "iput"},
- {mem, "mem"},
- {pipe1, "pipe1"},
- {killstatus, "killstatus"},
- {preempt, "preempt"},
- {exitwait, "exitwait"},
- {rmdot, "rmdot"},
- {fourteen, "fourteen"},
- {bigfile, "bigfile"},
- {dirfile, "dirfile"},
- {iref, "iref"},
- {forktest, "forktest"},
- {MAXVAplus, "MAXVAplus"},
- {bigdir, "bigdir"}, // slow
+ {pgbug, "pgbug" },
+ {sbrkbugs, "sbrkbugs" },
+ {sbrklast, "sbrklast"},
+ {sbrk8000, "sbrk8000"},
+ {badwrite, "badwrite" },
+ {badarg, "badarg" },
+ {execout, "execout"},
+ {diskfull, "diskfull"},
+ {texttest, "texttest"},
+
{ 0, 0},
};