Consider the following assembly: ``` $ cat adrp.s .global _start _start: adrp x0, 0x8000 ``` After assembling and linking: ``` $ aarch64-none-elf-as -o adrp.o adrp.s $ aarch64-none-elf-ld -Ttext=0x0 -o adrp.elf adrp.o aarch64-none-elf-ld: adrp.o: in function `_start': (.text+0x0): undefined reference to `no symbol' ``` Note, the following trick works (if e.g. _start is known to be 0): ``` $ cat adrp.s .global _start _start: adrp x0, 0x8000 + _start ``` which assembles as desired: ``` $ aarch64-none-elf-objdump -d adrp.elf adrp.elf: file format elf64-littleaarch64 Disassembly of section .text: 0000000000000000 <_start>: 0: 90000040 adrp x0, 8000 <_start+0x8000> ``` However, this only works if _start is fixed and known. Being able to specify an absolute (rather than relative) value for the immediate of the adrp instruction is useful for e.g. referencing peripherals at fixed locations which are known to be in the +/- 4GB range of the current address. My particular use case is referencing Raspberry Pi peripheral base addresses when the MMU is not enabled. Originally reported in bug 27217 comment 30. ``` $ aarch64-none-elf-ld --version GNU ld (GNU Binutils) 2.39 ```
Hi Pete, This bug is fixed in the 2.41 release: $ as adrp.s -o adrp.o $ ld -Ttext=0 adrp.o Cheers Nick
Many thanks Nick for quick response! Sorry for not testing on 2.41 before, I should have done that. On that note, I just went to test this on 2.41 and hit the issue described in bug 30703 comment 16... Thanks, Pete