Abstract
Chapter 5 already provided a short overview of dynamic libraries (also known as shared objects). This chapter will revisit dynamic libraries and expand our knowledge by introducing the concepts of the Program Linkage Table and the Global Offset Table. As a result, we will be able to build a shared library in pure assembly and C, compare the results, and study its structure. We will also study a concept of code models, which is rarely discussed but gives a consistent view of several important details of assembly code generation.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 1.
We will not provide the details on what the hash tables are or how are they implemented, but if you do not know about them, we highly advise you to read about them! This is an absolutely classic data structure used everywhere. A good explanation can be found in [10]
- 2.
Do not confuse with -O flag for the compiler!
- 3.
A probabilistic data structure that is widely used. It allows us to quickly check whether an element is contained in a certain set, but the answer “yes” is subject to an additional check, while “no” is always certain.
- 4.
This is not always the case, for example, OS X recommends that all executables are made position independent.
- 5.
This name is specific to ELF and should be changed for other systems. See section 9.2.1 of [27].
- 6.
The -fpic option implies a limit on GOT size for some architectures, which is often faster.
- 7.
Not all compilers and GCC versions support the large model.
- 8.
Note that there are different descriptions for different architectures.
- 9.
If you encounter the movabs instruction, consider it equivalent to the mov instruction.
- 10.
Obviously, here r15 and rbx hold not the beginning of GOT but its end, but it does not matter.
Author information
Authors and Affiliations
Rights and permissions
Copyright information
© 2017 Igor Zhirkov
About this chapter
Cite this chapter
Zhirkov, I. (2017). Shared Objects and Code Models. In: Low-Level Programming. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-2403-8_15
Download citation
DOI: https://doi.org/10.1007/978-1-4842-2403-8_15
Published:
Publisher Name: Apress, Berkeley, CA
Print ISBN: 978-1-4842-2402-1
Online ISBN: 978-1-4842-2403-8
eBook Packages: Professional and Applied ComputingProfessional and Applied Computing (R0)Apress Access Books