Is there a way to use a symbol constant defined in the LDF file in compiled C code and use it in run time? For Example if a symbol in the LDF that gets the size of an input section from an application?
There is no simple method to find the size of an input section directly within your code. We would recommend checking the XML Map file, which can be generated by enabling "Project Options:Link:General:Generate symbol map".
There is a way to access the size in code, however, which involves defining symbols in your LDF and you can then access the LDF symbols in your source code, and use them to calculate the size of the section. You will need to declare the symbols globally in your C source code.
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.
You can check stack_size has the correct value by checking the address of ldf_stack_length in the Disassembly Window.