Screen Version
School of Computer Science & Engineering
University of New South Wales

 Advanced Operating Systems 
 COMP9242 2011/S2 

M8: ELF Loading

This requires that when creating a process, its code and data section are loaded from the file system into some free memory, and a page table is set up which will satisfy page faults to the text and data sections from the correct frames. The OS's loader must interpret the contents of the executable file (in ELF format). Sample code for reading ELF files is provided.

By this final milestone you should ensure that all I/O is asynchronous. This means that your system must not block waiting on completion of file system or paging I/O, but should be able to run any process that is ready while other processes are blocked on I/O completion.

Code

You have been supplied with code to handle parsing ELF files. You will need to modify apps/sos/src/elf.c to load executables from the file system instead of from the boot image.

You will need to change the following line in the top level MakeFile such that it only includes the rootserver and other applicable binaries (not sosh or your test applications):

from:
sos-package: om_server sos elfloader common kernel_elf dite tty_test sosh
mkdir -p ${STAGE_BASE}/bin/temp
dite -D 0 ${STAGE_BASE}/bin/sos -o ${STAGE_BASE}/bin/temp/sos -R ${STAGE_BASE}/bin/tty_test -R ${STAGE_BASE}/bin/sosh
${SEL4_COMMON}/elfloader/gen_boot_image.sh ${STAGE_BASE}/kernel.elf ${STAGE_BASE}/bin/om_server ${IMAGE_ROOT}/sos-image-arm ${STAGE_BASE}/bin/temp/sos
${CONFIG_CROSS_COMPILER_PREFIX}strip -O binary ${IMAGE_ROOT}/sos-image-arm -o ${IMAGE_ROOT}/bootimg.bin
    
to:
sos-package: om_server sos elfloader common kernel_elf dite
${SEL4_COMMON}/elfloader/gen_boot_image.sh ${STAGE_BASE}/kernel.elf ${STAGE_BASE}/bin/om_server ${IMAGE_ROOT}/sos-image-arm ${STAGE_BASE}/bin/sos
${CONFIG_CROSS_COMPILER_PREFIX}strip -O binary ${IMAGE_ROOT}/sos-image-arm -o ${IMAGE_ROOT}/bootimg.bin
    

You will also need to modify the top level Makefile to automatically copy your executable files into your NFS directory.

Design issues

One design decision is whether to load the whole executable image on process creation, or instead load page-wise on demand at page-fault time.

You will need to change your build system so that executables are no longer added to the boot image, but rather copied into your /var/tftpboot/$USER directory.


Assessment

You will demonstrate (by running a sosh) that your system works even with repeated and concurrent executions, and that you can execute every file (of the right contents) from your NFS directory.


Last modified: 29 Jun 2011.