Relocation base address is always zero also when defining memory regions in linker script
Johannes Krottmayer
krotti83@proton.me
Thu Mar 26 21:10:25 GMT 2026
Hi!
Don't know where to ask this question. Also tried it on
Stackoverflow for a few months, but unfortunately didn't
get an answer. So therefore I try it here. Hope somebody
can clarify my question.
I'm working on a bare-metal project (simple operating
system kernel) targeting AArch64. Currently I have
defined multiple memory regions in my linker script:
MEMORY {
RAM_LOCORE (rwx) : ORIGIN = 0x0000000041000000, LENGTH = 2M
RAM_HICORE (rwx) : ORIGIN = 0xFFFF000041000000, LENGTH = 2M
RAM_LOKERN (rwx) : ORIGIN = 0x0000000041200000, LENGTH = 256M
RAM_HIKERN (rwx) : ORIGIN = 0xFFFF000041200000, LENGTH = 256M
}
I have implemented relocation support for the type
R_AARCH64_RELATIVE before the kernel starts in assembly.
The calculation for R_AARCH64_RELATIVE should be the following:
Fixed Address = Base Address + Offset + Addend
But I'm wondering why the base address is always zero. Here the
current relocation entries with 'readelf':
Relocati
on section '.rela.dyn' at offset 0x2000 contains 20 entries:
Offset Info Type Sym. Value Sym. Name
+ Addend
0000410001a8 000000000403 R_AARCH64_RELATIV 41002000
0000410001b0 000000000403 R_AARCH64_RELATIV
-ffffbedfe8b0
0000410002e0 000000000403 R_AARCH64_RELATIV 41002000
0000410002e8 000000000403 R_AARCH64_RELATIV 41003000
0000410002f8 000000000403 R_AARCH64_RELATIV 41004000
000041000358 000000000403 R_AARCH64_RELATIV 41005000
000041000360 000000000403 R_AARCH64_RELATIV 41006000
ffff0000412017c0 000000000403 R_AARCH64_RELATIV
-ffffaee00000
ffff0000412017c8 000000000403 R_AARCH64_RELATIV
-ffffaf600000
ffff000041201900 000000000403 R_AARCH64_RELATIV
-ffffbedec000
ffff000041201908 000000000403 R_AARCH64_RELATIV
-ffffbedebb04
ffff000041201920 000000000403 R_AARCH64_RELATIV
-ffffbee00000
ffff000041213008
000000000403 R_AARCH64_RELATIV
-ffffbedf2000
ffff000041213010 000000000403 R_AARCH64_RELATIV
-ffffbedf0000
ffff000041213018 000000000403 R_AARCH64_RELATIV
-ffffbedebcf0
ffff000041213020 000000000403 R_AARCH64_RELATIV
-ffffafe00000
ffff000041213028 000000000403 R_AARCH64_RELATIV
-ffffbedf1ff0
ffff000041213030 000000000403 R_AARCH64_RELATIV
-ffffbedefff0
ffff000041213038 000000000403 R_AARCH64_RELATIV
-ffffbedeb000
ffff000041213040 000000000403 R_AARCH64_RELATIV
-ffffbedec000
What's missing in my linker script? Can be the base address also defined
in linker script?
--
Kind regards,
Johannes K.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: publickey - krotti83@proton.me - 0x1A5D6E0E.asc
Type: application/pgp-keys
Size: 888 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20260326/68344031/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 322 bytes
Desc: OpenPGP digital signature
URL: <https://sourceware.org/pipermail/binutils/attachments/20260326/68344031/attachment.sig>
More information about the Binutils
mailing list