HP-UX HB v13.00 Ch-11 - Software Development

HP-UX Handbook Rev 13.00 Page 21 (of 101)
Chapter 11 Software Development
October 29, 2013
Program Execution
Besides the things the programmer has written, there are several other things that need to be done
in a program. A program life cycle consists of the following steps:
Load the Program
Load shared libraries
Resolve symbols
Execute main()
Terminate the program
Processes are not allowed to access system resources like files, devices or the network directly.
Every process must interact with the kernel via system calls for such actions. Because each of the
above steps needs interaction with the kernel, we can observe them by tracing the system calls of
the new process with tusc ( the example is from IA; the PA display will be essentially the same):
$ tusc HelloWorld
execve("./HelloWorld", 0x87fffffffffff5b0, 0x87fffffffffff5c0) = 0 [32-bit]
mmap(NULL, 8192, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -1,
0) = 0x79808000
open("/usr/lib/hpux32/dld.so", O_RDONLY, 0) .............. = 3
read(3, "7fE L F 0102010101\0\0\0\0\0\0\0".., 1024) ...... = 1024
mmap(NULL, 735056, PROT_READ|PROT_EXEC, MAP_SHARED|MAP_FILE|MAP_SHLIB, 3, 0) =
0xc001c000
sysconf(_SC_PAGE_SIZE) ................................... = 4096
mmap(NULL, 6760, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_SHLIB, -1,
0) = 0x79806000
mmap(0x79803000, 11480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FILE|MAP_SHLIB,
3, 786432) = 0x79803000
close(3) ................................................. = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -1,
0) = 0x79800000
sysconf(_SC_PAGE_SIZE) ................................... = 4096
stat("/usr/lib/hpux32/dpd", 0x7ffff190) .................. = 0
open("/usr/lib/hpux32/dpd", O_RDONLY, 0) ................. = 3
fcntl(3, F_SETFD, 0) ..................................... = 0
mmap(NULL, 16384, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -
1, 0) = 0x797fc000
getdents(3, 0x797fc028, 8192) ............................ = 80
getdents(3, 0x797fc028, 8192) ............................ = 0
close(3) ................................................. = 0
getuid() ................................................. = 116 (116)
getgid() ................................................. = 20 (20)
open("./HelloWorld", O_RDONLY, 0) ........................ = 3
pread(3, "\0\0\002\0\0\0, \0\0\0\aH P \0\0".., 60, 436) .. = 60
close(3) ................................................. = 0
utssys(0x7fffe5f0, 60, 0) ................................ = 0
procxsec(4, -1, 0x7fffe5c0, 40) .......................... = 0
open("/usr/lib/hpux32/libc.so.1", O_RDONLY, 0) ........... = 3
fstat(3, 0x7ffff0e0) ..................................... = 0
read(3, "7fE L F 0102010101\0\0\0\0\0\0\0".., 52) ........ = 52