Praxeolitic
Praxeolitic

Reputation: 24079

What are the uses for custom linker scripts?

What are the common uses for custom linker scripts? When would I want to use one? What important things can I do with a custom linker script that I can't do with the default linker script? When do they provide advantages over the default linker script and what are those advantages?

I have in mind C++ if it affects the answer.

Upvotes: 2

Views: 679

Answers (2)

Thomas Schmid
Thomas Schmid

Reputation: 116

I don't know the common uses, but in our case it is customization, because of a non standard os. We use it to set some symbols to identify special variables, which get another treatment while loading.

Upvotes: 0

LThode
LThode

Reputation: 1963

The linker script can be considered a mapping from the "generic" data/code/uninitialized-data/read-only-constants/symbols sections in an ELF relocatable object file to the peculiarities required by the target system's executable loader. In general, the "default" linker script for a toolchain and target OS is provided with the toolchain; custom linker scripts are used primarily in the embedded world, where there may not be an OS at all, or when writing low-level code such as bootloaders or OS kernels, as in those applications, you may not have the same guarantees (or any guarantees) as to "what goes where" vs. what an OS' executable loader provides for you.

Upvotes: 1

Related Questions