lilzz
Posts: 411
Joined: Sat Nov 30, 2013 5:27 pm

How does Linker script are being generated and used.

Tue May 24, 2016 8:26 pm

If in a project there's xxx.ld linker script, How's it being generated or being used?

What's the syntax to input the xxx.ld script to the GCC toolchain?

User avatar
Paeryn
Posts: 2698
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: How does Linker script are being generated and used.

Tue May 24, 2016 8:55 pm

Somebody wrote it, it's used by the linker ld to tell it how to link object files. Normally ld will use a default linker script but if you pass a linker script to it it will use that instead.

http://www.math.utah.edu/docs/info/ld_3.html
She who travels light — forgot something.

lilzz
Posts: 411
Joined: Sat Nov 30, 2013 5:27 pm

Re: How does Linker script are being generated and used.

Tue May 24, 2016 9:29 pm

Paeryn wrote:Somebody wrote it, it's used by the linker ld to tell it how to link object files. Normally ld will use a default linker script but if you pass a linker script to it it will use that instead.

http://www.math.utah.edu/docs/info/ld_3.html

So, anytimes you wrote a program, and produce some object files and you grab that linker script as template and link those object files together to produce the final executable?

User avatar
Paeryn
Posts: 2698
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: How does Linker script are being generated and used.

Tue May 24, 2016 9:43 pm

For general compiling of linux programs the default script is all you need, it's comprehensive and designed to work with the toolchain it's provided with for generating code to run on the system the toolchain targets.

You only really need to write your own scripts if you have specific needs (like writing bare-metal programs).
She who travels light — forgot something.

Return to “General programming discussion”