{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Homework9_sol - 11 R_386_32 ap 15 8b 10 mov(x,x 17 a1 00...

Info icon This 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 d: 00 00 00 8: R_386_32 bp c: R_386_32 b 10: a1 00 00 00 00 mov 0x0,%eax
Image of page 1

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

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 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 Object UNDEF Extern sum NULL NULL NULL ap Object .data GLOBAL bp Object COMMON GLOBAL add FUNC .text GLOBAL 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? Sol: 0x08048324 + 0x12 = 0x08048336 b) What is the hex value of the relocated reference to add? Sol: 0x08048360 - 0x08048336 - 0x4 = 0x2a - 0x4 = 0x26...
View Full Document

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern