confusion about CONFIG_SYS_TEXT_BASE and gd->relocaddr
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 1 line · tamzikin at sina.com
Hi Marek,
Hi,
CC the list next time.
Quoted 11 lines
I am Kin, nice to meet you, I know you because I saw your u-boot video on Youtube.
I am a learner of u-boot, and I have a big confusion on it, so I would like to find answer from you.
For compiling, some platform have CONFIG_SYS_TEXT_BASE set to some value, and CONFIG_SYS_TEXT_BASE will be used when linking all sections into one u-boot, so it can be said that the address of the first instruction in u-boot will be bound to addressCONFIG_SYS_TEXT_BASE, and every variable and function will also be bound to address based onCONFIG_SYS_TEXT_BASE.
Yes, that's the link address.
Quoted 3 lines
Before relocation, gd->relocaddr is calculated, and if
gd->relocaddrdoesn't equal toCONFIG_SYS_TEXT_BASE, u-boot is relocated togd->relocaddrbut notCONFIG_SYS_TEXT_BASE.
Right, U-Boot gets relocated to the end of RAM , so it's out of the way.
Quoted 3 lines
Since all the functions and variables are bound to address based on
CONFIG_SYS_TEXT_BASEduring compilation, so if we don't locate u-boot toCONFIG_SYS_TEXT_BASE, u-boot cannot reach functions and variable correctly.
Take a look at relocate_code function and search for R_ARM_REL32 for example, it should give you an idea how that relocation stuff works and how the function pointers get adjusted to match the binary location.
Quoted 4 lines
But this is actually how u-boot is designed, so I am confused, could you give me any hint for that?
Thanks.
Signature · 2 lines
Best regards, Marek Vasut