From ae50823599ce693b76ef2048598710017c4dc4cb Mon Sep 17 00:00:00 2001 From: Bahadir Balban Date: Wed, 13 May 2009 16:37:08 +0300 Subject: [PATCH] Elf file checking - Added the test that data and text are at least a page apart. --- tasks/fs0/src/syscalls.c | 2 +- tasks/mm0/src/lib/elf/elf.c | 5 ++++- tasks/test0/src/exectest.c | 6 +++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/tasks/fs0/src/syscalls.c b/tasks/fs0/src/syscalls.c index d161978..c83bf9d 100644 --- a/tasks/fs0/src/syscalls.c +++ b/tasks/fs0/src/syscalls.c @@ -71,7 +71,7 @@ int pager_open_bypath(struct tcb *pager, char *pathname) struct vnode *v; int retval; - printf("%s/%s\n", __TASKNAME__, __FUNCTION__); + //printf("%s/%s\n", __TASKNAME__, __FUNCTION__); if (pager->tid != PAGER_TID) return -EINVAL; diff --git a/tasks/mm0/src/lib/elf/elf.c b/tasks/mm0/src/lib/elf/elf.c index ea805c3..3f6a62f 100644 --- a/tasks/mm0/src/lib/elf/elf.c +++ b/tasks/mm0/src/lib/elf/elf.c @@ -97,7 +97,10 @@ int elf_mark_segments(struct elf_section_header *sect_header, int nsections, "bss segment in ELF file.\n", __FUNCTION__); } - /* Data and text are less than page apart and unaligned */ + /* Data and text are on the same page and not on a page boundary */ + if (!((is_page_aligned(task->data_start) && + task->data_start == task->text_end) || + (page_align(task->data_start) > page_align(task->text_end)))) if ((task->data_start - task->text_end) < PAGE_SIZE && !is_page_aligned(task->text_end)) { printf("%s: Error: Distance between data and text" diff --git a/tasks/test0/src/exectest.c b/tasks/test0/src/exectest.c index 5bbb74d..239f710 100644 --- a/tasks/test0/src/exectest.c +++ b/tasks/test0/src/exectest.c @@ -24,7 +24,7 @@ int exectest(void) char filename[128]; memset(filename, 0, 128); - sprintf(filename, "/home/bahadir/execfile%d.txt", getpid()); + sprintf(filename, "/home/bahadir/execfile%d", getpid()); /* First create a new file and write the executable data to that file */ if ((fd = open(filename, O_RDWR | O_CREAT | O_TRUNC, S_IRWXU)) < 0) { @@ -33,7 +33,7 @@ int exectest(void) } left = size; - printf("Writing %d bytes to %s\n", left, filename); + test_printf("Writing %d bytes to %s\n", left, filename); while (left != 0) { if ((cnt = write(fd, exec_start, left)) < 0) goto out_err; @@ -51,7 +51,7 @@ int exectest(void) argv[4] = 0; /* Execute the file */ - execve("/home/bahadir/test1.axf", argv, 0); + execve(filename, argv, 0); out_err: printf("EXECVE TEST -- FAILED --\n");