Homework9 - d: 00 00 00 8: R_386_32 bp c: R_386_32 b 10: a1...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Homework 9 The program below consists of tow source files: main.c and add.c. The following is C code of main.c and add.c main.c: extern void add(); int a = 100; int b = 200; int main (){ add(); return 0; } add.c: extern int a; extern int b; int * ap = &a; int * bp; void add(){ bp = &b; int sum; sum = *ap + *ap; } The following is .text section of main.o and add.o 00000000 <main>: 0: 8d 4c 24 04 lea 0x4(%esp),%ecx 4: 83 e4 f0 and $0xfffffff0,%esp 7: ff 71 fc pushl 0xfffffffc(%ecx) a: 55 push %ebp b: 89 e5 mov %esp,%ebp d: 51 push %ecx e: 83 ec 04 sub $0x4,%esp 11: e8 fc ff ff ff call 12 <main+0x12> 12: R_386_PC32 add 16: b8 00 00 00 00 mov $0x0,%eax 1b: 83 c4 04 add $0x4,%esp 1e: 59 pop %ecx 1f: 5d pop %ebp 20: 8d 61 fc lea 0xfffffffc(%ecx),%esp 23: c3 ret 00000000 <add>: 0: 55 push %ebp 1: 89 e5 mov %esp,%ebp 3: 83 ec 10 sub $0x10,%esp 6: c7 05 00 00 00 00 00 movl $0x0,0x0
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: d: 00 00 00 8: R_386_32 bp c: R_386_32 b 10: a1 00 00 00 00 mov 0x0,%eax 11: R_386_32 ap 15: 8b 10 mov (%eax),%edx 17: a1 00 00 00 00 mov 0x0,%eax 18: R_386_32 ap 1c: 8b 00 mov (%eax),%eax 1e: 8d 04 02 lea (%edx,%eax,1),%eax 21: 89 45 fc mov %eax,0xfffffffc(%ebp) 24: c9 leave 25: c3 ret 1. Please fill the symbol table of add.o , if there is no such entry, fill in with “ NULL ”, if the symbol has no entry in section header table, please fill in with ABS , UNDEF , COMOM as shown in textbook. Symbol Type Section Bind b Extern sum ap Object GLOBAL bp Object GLOBAL add .text 2. Suppose the linker had decided to locate function main at 0x08048324 and locate function add at 0x08048360 .(Note: you need to give the reasons for your answer) a) What is the hex address of the relocated reference to add? b) What is the hex value of the relocated reference to add?...
View Full Document

This note was uploaded on 10/19/2011 for the course CS 000 taught by Professor Jing during the Fall '10 term at Fudan University.

Page1 / 2

Homework9 - d: 00 00 00 8: R_386_32 bp c: R_386_32 b 10: a1...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online