Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/relocations.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ ELF file of a statically linked non-PIE will have relocations to support
[_ifuncs_](https://github.com/sivachandra/elf-by-example/tree/master/examples/ifunc).
ELF file of a statically linked PIE will additional have one specific kind
of dynamic relocations. These relocations are required to adjust for the
load address (a [PIE](pie.md) is loaded at a different address everyone time it
load address (a [PIE](pie.md) is loaded at a different address every time it
runs). See this [example](https://github.com/sivachandra/elf-by-example/tree/master/examples/global_var_ptr)
for more elaborate illustration.
for a more elaborate illustration.

## What are linker generated relocations?

A coworker once asked, "Aren't relocations generated by the compiler/assembler?
What are linker generated relocations?" It is true that the compiler and/or
the assembler generate the relocations. The static linker makes use of these
relocations to performing the linking. Some values, like global variable
relocations to perform the linking. Some values, like global variable
addresses in a PIE, can only be known after the program starts. For such values,
the linker typically replaces the compiler generated relocations with its own
relocations which are most suitable for the linking mode used (for example,
Expand Down
2 changes: 1 addition & 1 deletion docs/static_pie.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ static-pie binary are explained in
A statically linked PIE binary differs from a dynamically linked PIE binary in
the following ways:

1. As there are no dynamic libraries to be loaded, they is no need of the
1. As there are no dynamic libraries to be loaded, there is no need for the
program interpreter. Consequently, there is no `PT_INTERP` segment in a
static-pie binary.
1. The dynamic section will not have `DT_NEEDED` entries as a static-pie binary
Expand Down