Question:
Is there any way to use the symbol which was defined in LDF from C code for accessing the size of input section?
Answer:
Yes. This can be done by defining symbols in LDF and then access the LDF symbol in C source code and use them to calculate the size of the section. We need to declare those symbols globally in our C source code.
For example:
extern "asm" void* ldf_stack_space;
extern "asm" void* ldf_stack_end;
int main( void )
{
int stack_start_address = (int)&ldf_stack_space;
int stack_end_address = (int)&ldf_stack_end;
int stack_size = stack_end_address - stack_start_address;
}
Note that the size of the stack is calculated via simple subtraction. We can check stack_size has the correct value by checking the address of ldf_stack_length in the Disassembly Window.