Linker Script
Linker Script
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??
Re: Linker Script
.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??
ok, thanks for replying!!!
Since I'm using a binary format for my kernel I guess that the BSS section won't be write to the file, so I putted the BSS at the end of the memory ( with the linker script) and I created two pointers ( one for the beginning of the section and one for the end ), this way I can zero-fill this memory at my kernel start. But is the script ok:
Since I'm using a binary format for my kernel I guess that the BSS section won't be write to the file, so I putted the BSS at the end of the memory ( with the linker script) and I created two pointers ( one for the beginning of the section and one for the end ), this way I can zero-fill this memory at my kernel start. But is the script ok:
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;
From the LD manual, section "Assignment: Defining Symbols":
![Smile :)](./images/smilies/icon_smile.gif)
You may create global symbols, and assign values (addresses) to global symbols, (...)
![Smile :)](./images/smilies/icon_smile.gif)