Linker Script
Posted: Fri Aug 03, 2007 2:35 pm
I'm trying to write a linker script ( so I reading LD documentation ), but looking into someones linker script I got a section named ".rodata" and I want to know what is this section for??
.rodata = Read-Only Data (i.e. run-time constants.)artrecks wrote:I'm trying to write a linker script ( so I reading LD documentation ), but looking into someones linker script I got a section named ".rodata" and I want to know what is this section for??
Code: Select all
OUTPUT_FORMAT("binary")
ENTRY(kfstart)
SECTIONS{
. = 0x00100000;
.text :{
*(.text)
}
.rodata ALIGN (0x1000) : {
*(.rodata)
}
.data ALIGN (0x1000) : {
*(.data)
}
.bss : {
_start_bss = .;
*(.bss)
_end_bss = .;
}
}
Try taking the address of start_bss in the C code. Because of the way that the variables are represented you have to take the address of them to get the correct value.artrecks wrote:but using this I could not get the address of (_start_bss ) and (_end_bss). I used them in C code ( extern unsigned long start_bss ) but I got number 0 for start_bss and 0x89D189C3 for end_bss
Why this is happening?
Code: Select all
/* The correct way to get the start of the bss section would be something like this */
DWORD start_of_bss = (DWORD)&start_bss;
You may create global symbols, and assign values (addresses) to global symbols, (...)