You are charged with maintaining a large C program, and you come across the following code: typedef struct { int first; a_struct a [CNT]; int last; }b_struct; void test (long i, b_struct *bp) { = int n bp->first + bp->last; a_struct *ap &bp->a[i]; } ap->x[ap->idx] = n; = The declarations of the compile-time constant CNT) and the structure a_struct are in a file for which you do not have the necessary access privilege. Fortunately, you have a copy of the .o version of the code, which you are able to disassemble, yielding the following disassembly: 0000000000000000 : 0: 8b 8e 20 01 00 00 6: 03 0e 48 8d 04 bf 48 8d 04 c6 48 8b 50 08 48 63 c9 48 89 4c de 10 c3 8: C: 10: 14: 17: 1c: mov add lea lea mov movslq %ecx, %rcx 0x120 (%rsi), %ecx (%rsi),%ecx (%rdi, %rdi,4),%rax (%rsi,%rax, 8),%rax mov ret 0x8 (%rax),%rdx %rcx, 0x10 (%rax,%rdx,8) Using your reverse engineering skills, deduce the following: a. The value of CNT. b. A complete declaration of structure a_struct. Assume that the only fields in this structure are idx and x, and that both of these contain signed values.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Please Help ASAP!!!

 

 

You are charged with maintaining a large C program, and you come across the following code:
typedef struct {
int first;
a_struct a[CNT];
int last;
}b_struct;
void test(long i, b_struct *bp) {
int n = bp->first + bp->last;
a_struct *ap &bp->a[i];
ap->x[ap->idx] = n;
}
The declarations of the compile-time constant CNT) and the structure a_struct are in a file for which you do not have
the necessary access privilege. Fortunately, you have a copy of the .o version of the code, which you are able to
disassemble, yielding the following disassembly:
0000000000000000 <test>:
8b 8e 20 01 00 00
0:
6:
8:
03 0e
48 8d 04 bf
48 8d 04 c6
C:
10:
14: 48 63 c9
17:
1c:
48 8b 50 08
48 89 4c de 10
c3
mov
add
lea
lea
mov
0x120 (%rsi), %ecx
(%rsi),%ecx
(%rdi, %rdi,4),%rax
(%rsi,%rax, 8), %rax
0x8 (%rax),%rdx
movslq %ecx,%rcx
mov
ret
%rcx, 0x10 (%rax, %rdx, 8)
Using your reverse engineering skills, deduce the following:
a. The value of CNT.
b. A complete declaration of structure a_struct. Assume that the only fields in this structure are idx) and (x), and that
both of these contain signed values.
Transcribed Image Text:You are charged with maintaining a large C program, and you come across the following code: typedef struct { int first; a_struct a[CNT]; int last; }b_struct; void test(long i, b_struct *bp) { int n = bp->first + bp->last; a_struct *ap &bp->a[i]; ap->x[ap->idx] = n; } The declarations of the compile-time constant CNT) and the structure a_struct are in a file for which you do not have the necessary access privilege. Fortunately, you have a copy of the .o version of the code, which you are able to disassemble, yielding the following disassembly: 0000000000000000 <test>: 8b 8e 20 01 00 00 0: 6: 8: 03 0e 48 8d 04 bf 48 8d 04 c6 C: 10: 14: 48 63 c9 17: 1c: 48 8b 50 08 48 89 4c de 10 c3 mov add lea lea mov 0x120 (%rsi), %ecx (%rsi),%ecx (%rdi, %rdi,4),%rax (%rsi,%rax, 8), %rax 0x8 (%rax),%rdx movslq %ecx,%rcx mov ret %rcx, 0x10 (%rax, %rdx, 8) Using your reverse engineering skills, deduce the following: a. The value of CNT. b. A complete declaration of structure a_struct. Assume that the only fields in this structure are idx) and (x), and that both of these contain signed values.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
ADT and Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education