How kernel, compiler, and C library work together: Difference between revisions

[unchecked revision][unchecked revision]
Content deleted Content added
Frank (talk | contribs)
Frank (talk | contribs)
Line 59:
== Shared Libraries ==
 
A popular strategy is to ''share'' dynamically linked libraries across multiple executables. This means that, instead of attaching the binary of the library to the executable image, the references in the executable are tweaked, so that all executables refer to the same in-memory representation of the required library.
 
This requires some trickery. For one, the library must either not have any ''state'' (static or global data) at all, or it must provide a seperateseparate ''state'' for each executable. This gets even trickier with multithreadedmulti-threaded systems, where one executable might have more than one simultaneous control flow.
 
Second, in a virtual memory environment, it is usually impossible to provide a library to all executables in the system at the same virtual memory address. To access library code at an arbitrary virtual address requires the library code to be ''position independent'' (which can be achieved e.g. by setting the -PIC command line option for the [[GCC]] compiler). This requires support of the feature by the binary format (relocation tables), and can result in slightly less efficient code on some architectures.
 
== ABI - Application Binary Interface ==