Assignment
2
(Marks 10)
- Date of assignment out: 27.07.2006
- Last date of report: 13.08.2006
- Compile
the following C program with -c option in
SunFire (10.5.18.61 or 10.5.18.62)
gcc -Wall -O0 -c what.c
You get the relocatable file (object
module) what.o. Use the file command to see its type -
file what.o
- Use ELF Manual for the
denotation of different portions of the binary file what.o. The
structure of different
sections are also available in /usr/include/sys/elf.h
and
in /usr/include/sys/elf_SPARC.h
on SunFire.
elfdump -s what.o
it shows the
content of the symbol table of the
ELF object module.
- Write a C program
that reads an ELF object
module and prints the following
information from the symbol table
(.symtab).
- Total
number of entries in the symbol table
- Symbol
name e.g. data1, merge etc.
- Type
of the symbol e.g. function,
object etc.
- Binding
of a symbol - local or global
- Size
for a function and also for an object
You are not suppose to use
elfdump or such system
utility
- A sample C
program, object module and partially commented byte dump is shown:
merge.c
merge.o
merge.o.dump Lecture II (ps) (pdf)
- The file name
of the C program should be <rollNo>_02.c,
it should contain your identity e.g name, roll number, assignment
number etc.
- Create a subdirectory
under your home directory with the name
<roll_number>.oslab e.g.
04cs1048.oslab with the protection bits set properly. Assignment
with proper name should be available under this directory on or before the
last date of report.