Question: In Section 7.7, why does the size of executable file differ so dramatically when we use shared libraries for such a trivial program? Most UNIX

In Section 7.7, why does the size of executable file differ so dramatically when we use shared libraries for such a trivial program?

In Section 7.7, why does the size of executable file differ so

Most UNIX systems today support shared libraries. Arnold [1986] describes an early implementation under System V, and Gingell et al. 1987] describe a different implementation under SunOS. Shared libraries remove the common library routines from the executable file, instead maintaining a single copy of the library routine somewhere in memory that all processes reference. This reduces the size of each executable file but may add some runtime overhead, either when the program is first executed or the first time each shared library function is called. Another advantage of shared libraries is that library functions can be replaced with new versions without having to relink edit every program that uses the library (assuming that the number and type of arguments haven't changed). rogram to say that it wants to use or not use the shared libraries. Options for the cc(1) and ld(1) commands are typical. As wing executable file-the classic hello.c Different systems provide different ways for a p an example of the size differences, the follo program-was first created without shared libraries: prevent gcc from using shared libraries $ gcc -static hellol.c $ ls -l a.out -rwxr-xr-x 1 sar $ size a.out 879443 Sep 2 10:39 a.out hex filename data 6128 11272 805175 C4937 a.out text bss dec 787775 If we compile this program to use shared libraries, the text and data sizes of the executable file are greatly decreased gec defaults to use shared libraries $ gcc hellol.c $ ls -l a.out -rwxr-xr-x $ size a.out 1 sar 8378 Sep 2 10:39 a.out text 1176 data 504 bss 16 dec 1696 hex filename 6a0 a.out

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!