Hi
I now have gcc and friends running natively on my OS (Thanks pcmattman!!). It does produce valid looking executables but my lazy loading routines have always barfed on non-page aligned sections. As a result I've always had to specify a linker script when compiling anything.
That aside, how do I control the default behavior of LD? I've followed the 'OS Specfic Toolchain' tutorial to add my OS as a target then Canadian cross built native binutils/gcc with it. I'm guessing this must be done at compile time as it uses a 'builtin' linker script... but where is that configured?
Thanks
LD builtin linker script
LD builtin linker script
All your base are belong to us.
-
- Member
- Posts: 2566
- Joined: Sun Jan 14, 2007 9:15 pm
- Libera.chat IRC: miselin
- Location: Sydney, Australia (I come from a land down under!)
- Contact:
Re: LD builtin linker script
Hi,
On the (OS_Specific_Toolchain) article, you will create a "myos_<arch>.sh" file. This contains a heap of information that basically defines the built-in linker scripts (and other similar behavior).
There is a line in this script which the article specifies as:
This address will be the base of the binary - all other sections will follow this. For most people, all they need to do is specify the base address and they're happy. Your OS may differ - perhaps wanting to have the data starting at a totally different location. In that case, you have other variables - DATA_START_ADDR for instance. A quick Google for TEXT_START_ADDR got me a heap of example GCC emulation scripts, so it shouldn't be too hard to find the information you need
Any further questions, feel free to ask!
EDIT: Also, should it also be trying to squeeze in other sections outside of the main ones, you should specify MAXPAGESIZE, COMMONPAGESIZE, and NOP (as the article says). If that still doesn't create binaries with the alignment you need, please post an objdump that lets us see the unaligned sections
On the (OS_Specific_Toolchain) article, you will create a "myos_<arch>.sh" file. This contains a heap of information that basically defines the built-in linker scripts (and other similar behavior).
There is a line in this script which the article specifies as:
Code: Select all
TEXT_START_ADDR=0x40000000
Any further questions, feel free to ask!
EDIT: Also, should it also be trying to squeeze in other sections outside of the main ones, you should specify MAXPAGESIZE, COMMONPAGESIZE, and NOP (as the article says). If that still doesn't create binaries with the alignment you need, please post an objdump that lets us see the unaligned sections
Re: LD builtin linker script
I don't know if it is related but on my Linux I have a path /usr/lib/ldscripts/ which contains many scripts for ld
I have no proof of this but it could be possible that ld uses them by default
Same for a cross-compiler: /usr/local/(cross compiler target)/lib/ldscripts/
They seem to be generated when 'make install'ing binutils
I have no proof of this but it could be possible that ld uses them by default
Same for a cross-compiler: /usr/local/(cross compiler target)/lib/ldscripts/
They seem to be generated when 'make install'ing binutils
MysteriOS
Currently working on: TCP/IP
Currently working on: TCP/IP