-
-
Notifications
You must be signed in to change notification settings - Fork 846
06 - Chainloader: understanding core concepts #152
-
Hey,
I have been following along the tutorial and reached the 6th chapter. I am having trouble understanding a few concepts and the assembly in boot.s.
This is me after half a day of googling - could you please share some resources / explanations about:
- what is a "link address"? I know the rpi loads the kernel to 0x8000 (as specified in the
link.ld
file), but why do we need to specify the "link address" in the linker file and not just copy wherever we want? - relative/absolute addressing: why? Home come we use ADR_REL, ADR_ABS and get the load / linked address? I am really confused about this
- the assembly of the copy loop itself is a bit confusing - we load from the load address, than we store it but never increment
__binary_nonzero_start
so I don't see how come the loop ever ends...
Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions
what is a "link address"? I know the rpi loads the kernel to 0x8000 (as specified in the link.ld file), but why do we need to specify the "link address" in the linker file and not just copy wherever we want?
The link address is what the linker uses when it does things like resolving branches
or calculating addresses. What you can do to get an idea is make objdump | less
, and look around a bit. And then change the link address in the script (do a major change, that will make it more obvious to the eye), and do a make objdump | less
again and look at the difference.
The important part to understand here is that whatever you put into the script DOES NOT change the fact that the RPi bootloa...
Replies: 1 comment 1 reply
-
what is a "link address"? I know the rpi loads the kernel to 0x8000 (as specified in the link.ld file), but why do we need to specify the "link address" in the linker file and not just copy wherever we want?
The link address is what the linker uses when it does things like resolving branches
or calculating addresses. What you can do to get an idea is make objdump | less
, and look around a bit. And then change the link address in the script (do a major change, that will make it more obvious to the eye), and do a make objdump | less
again and look at the difference.
The important part to understand here is that whatever you put into the script DOES NOT change the fact that the RPi bootloaders will load the binary at 0x8000
.
relative/absolute addressing: why? Home come we use ADR_REL, ADR_ABS and get the load / linked address? I am really confused about this
ADR_REL
makes the CPU calculate addresses by using the CPU's current program counter. ADR_ABS
will resort to hardcoded addresses.
I think it could make sense to skip forward and additionally read the first parts of the README of chapter 15 if you want to get more into the details here. I hope this sheds some more light on what's going on.
the assembly of the copy loop itself is a bit confusing - we load from the load address, than we store it but never increment __binary_nonzero_start so I don't see how come the loop ever ends...
Post-indexed addressing mode is used. Here is the relevant snippet from the ARM ARM:
image
Beta Was this translation helpful? Give feedback.
All reactions
-
Thanks for the detailed reply, it helped a lot :)
Beta Was this translation helpful? Give feedback.