Question: a. In which segments of the executable are a, b, s, and func stored? Use the command readelf -hSs out to verify your solution. Locate

 a. In which segments of the executable are a, b, s,

a. In which segments of the executable are a, b, s, and func stored? Use the command readelf -hSs out to verify your solution. Locate each object in the symbol table (.symtab) and match the section index given in the Ndx column with the section headers. Hint: The compiler may have renamed s to s.n with n being some decimal number to prevent name clashes.

Consider the following C program that does some random computations. Download the source code of the program gcc with the following command line: gcc -g main.c func.c -o out You should now have an executable file called out. main.c: #include #include "func.h" func.c: const int a = 42; int b = 1; int main() { int *parg, result; int func(int *parg) { static int s = 0; int r; parg = (int*)malloc(sizeof(int)); if (parg == NULL) exit(1); *parg = 10; result = func(parg); free (parg); if (s == 0) { r = *parg + a; s = 1; } else { r = *parg + b; b++; } return result; } func.h: int func(int *parg); return r; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!