Skip to main content

Shared Objects and Code Models

  • Chapter
  • First Online:
Low-Level Programming
  • 4492 Accesses

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.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 79.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 99.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 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. 2.

    Do not confuse with -O flag for the compiler!

  3. 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. 4.

    This is not always the case, for example, OS X recommends that all executables are made position independent.

  5. 5.

    This name is specific to ELF and should be changed for other systems. See section 9.2.1 of [27].

  6. 6.

    The -fpic option implies a limit on GOT size for some architectures, which is often faster.

  7. 7.

    Not all compilers and GCC versions support the large model.

  8. 8.

    Note that there are different descriptions for different architectures.

  9. 9.

    If you encounter the movabs instruction, consider it equivalent to the mov instruction.

  10. 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

Authors

Rights and permissions

Reprints 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

Publish with us

Policies and ethics