Multifile/Linkers/Data sections Flashcards
ELF Data Sections
.text, .rodata, .data, .bss, .symtab, lreltext, .debug, .strtab
.text
Machine code
.rodata
String literals, switch/jump table
.data
initialized globals and static locals
.bss
uninitialized globals and static locals
.symtab
linker symbol table
.reltext
relocated code
.debug
complete symbol table
-fno-common
prevents weak name conflicts from compiling
.strtab
NULL-terminated strings of names of symbols in .symtab section
(Linker stage) Resolution
Check to make sure each symbol has one def only
(Linker stage) Relocation
Resolve symbol addresses for aggregated sections of of executable
Object Files (ROFs)
Produced by assembler, can be combined by linker
(Multifile coding) Include Guard
Prevents multiple inclusions
(ELF_Symbols) int name
byte offset in .strtab where name is found
(ELF_Symbols) int value
Symbol addr
(ELF_Symbols) int size
size in bytes
(ELF_Symbols) char type
indicates type e.g Data means object, func means function
(ELF_Symbols) char binding
indicates scope
(ELF_Symbols) char section
indicates location, e.g. .text, .rodata, .data, .bss
(Pseudo Sections) ABS
ABSolute, symbols that should not be relocated
(Pseudo Sections) UND
UNDefined, symbols in this ROF defined elsewhere
(Pseudo Sections) COM
COMmon, symbols in .bss which have not been allocated.
- int value = alignment requirements
- int size = minimum size
(Needs Symbol?) static locals
YES
(Needs Symbol?) locals
NO
(Needs Symbol?) params
NO
(Needs Symbol?) global vars
YES
(Needs Symbol?) static globals
YES
(Needs Symbol?) extern vars
YES
(Needs Symbol?) externally defined functions
YES
(Needs Symbol?) static functions
NO
(Needs Symbol?) non-static functions
YES
(Compiler or Linker) local vars
Compiler
(Compiler or Linker) static locals
Kind of both
(Compiler or Linker) globals
Linker