please see more details of this link:
http://sourceware.org/binutils/docs-2.16/ld/Scripts.html#Scripts
First of all, let me introduce what the linker does:
after you compile the program:
gcc -c -g -Wall main.c
gcc -c -g -Wall swap.c
you will get two relocatable binary file: main.o and swap.o file. By using linker(ld), you will relocate the two .o files into a executable binary file named a.out.
if you want more detail information about linker, please see the slides 14:
http://www.cs.gmu.edu/~setia/cs367/slides/index.html
Every link is controlled by a linker script. This script is written in the linker command language.
for example, smm.ld is link script.
please see man ld or info ld, you could use option: -T to add the link script.
If you don't specify -T option, the linker will use the default linker script.
I also attached a sample of the formate of linker command language:
/* Maximum number of CPUs/cores */
CPUS = 4;
SECTIONS
{
/* This is the actual SMM handler.
*
* We just put code, rodata, data and bss all in a row.
*/
. = 0xa0000;
.handler (.): {
/* Assembler stub */
*(.handler)
/* C code of the SMM handler */
*(.text);
*(.text.*);
/* C read-only data of the SMM handler */
. = ALIGN(16);
*(.rodata)
*(.rodata.*)
/* C read-write data of the SMM handler */
. = ALIGN(4);
*(.data)
/* C uninitialized data of the SMM handler */
. = ALIGN(4);
*(.bss)
*(.sbss)
/* What is this? */
*(COMMON)
. = ALIGN(4);
}
/* We are using the ASEG interleaved to stuff the SMM handlers
* for all CPU cores in there. The jump table redirects the execution
* to the actual SMM handler
*/
. = 0xa8000 - (( CPUS - 1) * 0x400);
.jumptable : {
*(.jumptable)
}
/DISCARD/ : {
*(.comment)
*(.note)
*(.note.*)
}
}
No comments:
Post a Comment