end of binary
end of binary
Hello, I was wondering if there is a way I can specify a label to be at the end of a binary after linking. I haven't been able to find anything directly associated with ld, but I thought perhaps there was a trick I was overlooking or some such thing. Thanks for the help.
Re: end of binary
You can use a linker script with LD. This is the one I've been using for a kernel.
You then define any labels like _kstart & _kend as external and you can use the values as memory references.
Code: Select all
SECTIONS {
.text 0xc0100000 :{
_kstart = .;
_text = .;
*(.text);
_etext = .;
}
.data ALIGN(0x1000):{
_data = .;
*(.data);
_edata = .;
}
.bss ALIGN(0x1000):{
_bss = .;
*(COMMON);
*(.bss);
_ebss = .;
}
_kend = .;
}
"God! Not Unix" - Richard Stallman
Website: venom Dev
OS project: venom OS
Hexadecimal Editor: hexed
Website: venom Dev
OS project: venom OS
Hexadecimal Editor: hexed
Re: end of binary
Do you use a linker script? You should. The solution to your problem can be solved using LD's "." variable. At any point in the script, "." has the value of the current virtual address. This is useful for many reasons, one being that you can assign its value to variables.
Re: end of binary
Okay, got switched over to the script system and got everything up and running. Thanks guys, was very helpful
- Now in kernel space
- Now in kernel space