官术网_书友最值得收藏!

  • Expert C++
  • Vardan Grigoryan Shunguang Wu
  • 362字
  • 2021-06-24 16:33:55

Platforms and object files

The abstract output that we just saw is somewhat similar to the actual object file structure that the compiler produces after the compilation of a unit. The structure of an object file depends on the platform; for example, in Linux, it is represented in ELF format (ELF stands for Executable and Linkable Format). A platform is an environment in which a program is executed. In this context, by platform, we mean the combination of the computer architecture (more specifically, the instruction set architecture) and operating system. Hardware and operating systems are designed and created by different teams and companies. Each of them has different solutions to design problems, which leads to major differences between platforms. Platforms differ in many ways, and those differences are projected onto the executable file format and structure as well. For example, the executable file format in Windows systems is Portable Executable (PE), which has a different structure, number, and sequence of sections than the ELF format in Linux. 

An object file is divided into sections. Most important for us are the code sections (marked as .text) and the data section (.data). The .text section holds the program instructions and the .data section holds the data used by instructions. Data itself may be split into several sections, such as initialized, uninitialized, and read-only data.

An important part of the object files in addition to the .text and .data sections is the symbol table. The symbol table stores the mappings of strings (symbols) to locations in the object file. In the preceding example, the compiler-generated output had two portions, the second portion of which was marked as information:, which holds the names of the functions used in the code and their relative addresses. This information: is the abstract version of the actual symbol table of the object file. The symbol table holds both symbols defined in the code and symbols used in the code that need to be resolved. This information is then used by the linker in order to link the object files together to form the final executable file.

主站蜘蛛池模板: 乐亭县| 西宁市| 荥经县| 苍山县| 宣城市| 宜昌市| 聂荣县| 富锦市| 兰西县| 盈江县| 西昌市| 汽车| 华宁县| 信丰县| 大洼县| 珲春市| 阜新市| 焉耆| 乌恰县| 介休市| 奉化市| 芒康县| 昭觉县| 万荣县| 东平县| 吉木萨尔县| 中阳县| 咸丰县| 合川市| 喜德县| 藁城市| 旺苍县| 麟游县| 大兴区| 九龙坡区| 新建县| 长丰县| 饶平县| 扎兰屯市| 皮山县| 特克斯县|