Now that we know how to write a linker, scripts will attempt to write a program and place the data
section in the Ram.
So the code is updated.
Uh, add s is updated to load two values from Ram, add them, and store the result back to Ram.
So if you see the previous code, which we had here, we were keeping a um, like this in a byte of
array.
But here I am having uh, two labels value one and value two.
Well, I am assigning the value 1 to 10 and value to 30.
And then I am storing a result.
I am having a four byte space for the result and the remaining is updated accordingly.
Like instead of using EO and RR, we are using value one and value two, installing back in the result.
So this is the code update and I will just compile this one.
And I have this linker script as it is.
Uh.
This is the same, uh, linker script, except we have the data section updated because we have our
Ram starting with A30 and four zeros.
Right.
So that's the reason this script is updated for that.
Now we can compile this, uh, convert the assembler to the object code, and.
Convert.
Into Elf file and pass linker script as an output.
Input input.
And then this one.
Now we can see that, uh, value one is placed at uh, 03040 value to the result.
And start and stop are placed, uh, here the text section is placed at this location location counter
and data section is placed at this.
And if you see the D is there D stands for data section, T stands for text section.
But this is not sufficient enough.
I'm just making this change is not sufficient enough.
We have to make few more changes.
Ram is a volatile memory so you cannot.
It is not possible to directly make the data available in Ram on power up.
First, all the code and data should be stored in the flash before power up and after the power up on
power up, a start up code is supposed to copy the data from flash to Ram, and then proceed with the
execution of the program.
So a program in this case the data section has two addresses a load address where you have everything
to operate in the Ram and the flash, and a runtime address which is address in the Ram.
So in case of LD is a linker load address is called as load LM load memory address, and the runtime
address is called as VM a virtual memory address.
So these two modifications has to be done.
If I want to make the program work correctly, the linker script has to be modified to specify both
the load address and the runtime address for the data section, and a small piece of code has should
copy the data section from the load address to the Ram.
The runtime address.
So important here is if you just write like this.
Uh, in the linker script, it will not copy this in the Ram because Ram is volatile.
Each time you power up, the contents are cleared up.
So there should be a code in the flash.
This text section which copies this content, which is in the into the Ram.
So in that case this will have data section will have two addresses.
One is a load memory address.
The address for this in the flash section and the other is a virtual memory address the address in the
Ram.
And we have to make modifications in the linker script for making the required changes to make sure
we have two addresses, and we have the start up code as well.