Warning
This page is located in archive. Go to the latest version of this course pages. Go the latest version of this page.

The Forth Homework - Code Analysis

The task assignment is provided to the students in the paper form.

The task assignment is available in PDF format as well on http://cmp.felk.cvut.cz/~pisa/apo/du4/.

Each student receives number from the seminar tutor.

Information sources for homework 4. solution

Example of little more complex program analysis than are programs in students assignments is available in archive.

homework-4-example.zip

Each task includes same algorithm compiled for i386 Linux system and MIPS Linux system.

i386 assembler syntax uses AT&T and GNU assembler/disassembler variant.

GNU Assembler Syntax

Description of the small subset of used system calls which are used in the code fragments can be found in the materials to the lecture

Parameters Passing to Subroutines and Operating System Implemented Virtual Instructions (System Calls)

This lecture includes enough information for i386 system calls. The MIPS architecture uses same system calls set but system calls numeric codes are different. The assignment can be found directly in GLIBC or Linux kernel sources cross-reference

http://lxr.linux.no/#linux+v3.8.8/arch/mips/include/uapi/asm/unistd.h

or directly in the Linux kernel sources GIT repository

arch/mips/include/uapi/asm/unistd.h

System calls use for the call return value which is 32 or 64-bit usually the same register(s) as are used for regular function calls return value. The additional information which has to be passed to the caller is information about call failure/error. Linux kernel uses special range of the return values. The system call failure is indicated by return value in the range of “small negative number”. The impact of this selection is that system calls cannot return negative values or pointer values near the top of the address range (addresses are taken as unsigned) as a valid results. The C library then check if syscall result is in this reserved range and setups thread specific global variable errno in such case and usually return minus one (for some syscalls NULL) as indication of syscall failure to the calling program according to the POSIX specification. List of the error codes is included in GLIBC documentation and can be found in Linux kernel sources include files as well

https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/uapi/asm-generic/errno.h

The actual return value of the syscall in the case of error is negated value of the listed error code (this is -ENOSYS for nonexistent system call for example). LIBC errno then hold positive value of the error code.

An complete description of the callin convention for MIPS architecture (variant used for GNU/Linux system) can be found in the document MIPSpro N32 ABI Handbook https://www.linux-mips.org/pub/linux/mips/doc/ABI/MIPS-N32-ABI-Handbook.pdf

courses/b35apo/en/homeworks/04/start.txt · Last modified: 2018/02/11 17:30 (external edit)