Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

4.1 A Linker Puzzle (10 pts) After implementing the link checker in exercise 2, a student applied their implementation to a small project consisting of

image text in transcribedimage text in transcribed

4.1 A Linker Puzzle (10 pts) After implementing the link checker in exercise 2, a student applied their implementation to a small project consisting of 4 files modulel.c, compiled to modulelo module2.c, compiled to module2.o module3.c, compiled to module3.o lib.c, compiled to lib.o using gcc -Wall -Wmissing-prototypes -c module*.c lib.c. After obtaining the symbol ta- bles of each .o file using for 1 in module*o lib.o do nm -S $1 > basename $1 .0 .nm done the link checker reported this: Weak symbol "buf' overridden, defined in module2 and overridden as D in module3 Global symbol "DESCRIPTION' defined in "modulet is not referenced by any other file, should be static Global symbol "data' defined in 'module2 is not referenced by any other file, should be static The 2 global symbols exported by library "lib' share common prefix lib_fun The link-checker was run with: link-checker.py -1 lib.nm module?.nm The-1 switch here denotes that the link checker exempts lib.o from the requirement that its global symbols are referenced in other compilation units, and it also asks the link checker that a consistent prefix is used for all exported symbols. The program was then linked with gcc module?. lib.o -o main. The symbol table of the main executable contained the following symbols 0000000000201020 D buf 0000000000201018 D data 0000000000201010 D DESCRIPTION 000000000000065f I lib_fun1 0000000000000666 T lib_fun2 000000000000061a T main 0000000000000636 T module2_fun 000000000000062f t module2_fun2 000000000000064e T module3_fun 0000000000000647 t module3_fun2 where internal symbols introduced by the compiler and runtime library are omitted. Your task is to reconstruct modulei.c to module3.c and lib.c, along with a header file defs.h that must be included by all 4.c files. Any reconstruction will be accepted that meets the following requirements: The modules must compile with the above flags on gec 8 or later The modules must link and produce an executable without linker error The symbols listed above must occur in the symbol table of the executable All declarations of global nonstatic functions must be contained in defs.h The link checker should not report errors other than those shown. 4.1 A Linker Puzzle (10 pts) After implementing the link checker in exercise 2, a student applied their implementation to a small project consisting of 4 files modulel.c, compiled to modulelo module2.c, compiled to module2.o module3.c, compiled to module3.o lib.c, compiled to lib.o using gcc -Wall -Wmissing-prototypes -c module*.c lib.c. After obtaining the symbol ta- bles of each .o file using for 1 in module*o lib.o do nm -S $1 > basename $1 .0 .nm done the link checker reported this: Weak symbol "buf' overridden, defined in module2 and overridden as D in module3 Global symbol "DESCRIPTION' defined in "modulet is not referenced by any other file, should be static Global symbol "data' defined in 'module2 is not referenced by any other file, should be static The 2 global symbols exported by library "lib' share common prefix lib_fun The link-checker was run with: link-checker.py -1 lib.nm module?.nm The-1 switch here denotes that the link checker exempts lib.o from the requirement that its global symbols are referenced in other compilation units, and it also asks the link checker that a consistent prefix is used for all exported symbols. The program was then linked with gcc module?. lib.o -o main. The symbol table of the main executable contained the following symbols 0000000000201020 D buf 0000000000201018 D data 0000000000201010 D DESCRIPTION 000000000000065f I lib_fun1 0000000000000666 T lib_fun2 000000000000061a T main 0000000000000636 T module2_fun 000000000000062f t module2_fun2 000000000000064e T module3_fun 0000000000000647 t module3_fun2 where internal symbols introduced by the compiler and runtime library are omitted. Your task is to reconstruct modulei.c to module3.c and lib.c, along with a header file defs.h that must be included by all 4.c files. Any reconstruction will be accepted that meets the following requirements: The modules must compile with the above flags on gec 8 or later The modules must link and produce an executable without linker error The symbols listed above must occur in the symbol table of the executable All declarations of global nonstatic functions must be contained in defs.h The link checker should not report errors other than those shown

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Design Implementation And Management

Authors: Peter Robb,Carlos Coronel

5th Edition

061906269X, 9780619062699

More Books

Students also viewed these Databases questions