main.c extern int weight_sum( ) ; int array[ ] = {4, 2}; int main( ){ int total;
ID: 3834396 • Letter: M
Question
main.c extern int weight_sum( ) ; int array[ ] = {4, 2}; int main( ){ int total; total = weight_sum( ) ; return 0; } weight_sum.c extern int *array; int *weight2; int weight1 = 1; int weight_sum( ){ int temp = 0; weight2 = &weight1; temp += weigth1*array[0] ; temp += *weight2*array[1] ; return temp; } For the code above, after the two object files above are linked together with the command line Id -o p main.o weight_sum.o, the sizes of .text and .data sections are list as below. Assume the object files are combined similar to the order shown in the lecture slides and the starting address of the unified executable object file starts at 0x08af3ef4. What is the relocated address of array[0]? The relocated address of array[0]: 0xExplanation / Answer
THe address of the array[0] is : 0x 08af3ef4 + 32 +4 +24= 0x 08af3ef4+3d= 0x 08af3f31
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.