qemu-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Arm64 ELF not loading


From: Peter Maydell
Subject: Re: Arm64 ELF not loading
Date: Sun, 4 Sep 2022 19:52:17 +0100

On Sat, 3 Sept 2022 at 02:30, Little Tree <littletreetrunk32@gmail.com> wrote:
>
> Hi,
>
> I have built a simple hello world program for aarch64 like this
>
> $aarch64-none-elf-gcc -c -march=armv8-a -g hello.c hello.o
> $aarch64-none-elf-gcc -specs=aem-ve.specs -Wl,-Map=linkmap.txt hello.o -o 
> hello.axf
>
> Then I tried to load and execute the file QEMU as given below
>
> $ qemu-system-aarch64 -semihosting -m 128M -nographic  -monitor none -serial 
> stdio  -machine virt,gic-version=2,secure=on,virtualization=on -cpu 
> cortex-a53 -kernel hello.axf -S -gdb tcp::9000
>
> I have also tried another method for loading
> $qemu-system-aarch64 -device loader,file=./hello.axf -machine virt -cpu max 
> -m 256M  -S -gdb tcp::9000
>
> In both the cases it looks like the binary is not loaded properly
>
> $ readelf -h hello.axf | grep Entry
> Entry point address:               0x80001148
>
> (gdb) target remote localhost:9000
> Remote debugging using localhost:9000
> 0x0000000000000000 in ?? ()
> (gdb) disas _start
> Dump of assembler code for function _start:
>    0x0000000080001148 <+0>: .inst 0x00000000 ; undefined
>    0x000000008000114c <+4>: .inst 0x00000000 ; undefined
>    0x0000000080001150 <+8>: .inst 0x00000000 ; undefined
>    0x0000000080001154 <+12>: .inst 0x00000000 ; undefined
>    0x0000000080001158 <+16>: .inst 0x00000000 ; undefined
>    0x000000008000115c <+20>: .inst 0x00000000 ; undefined
> ....
>
> Could you please shed some light why this binary is not loading properly?

The virt board has no RAM at address 0x8000_0000, so QEMU has successfully
loaded your ELF file into nothing. You need to link your baremetal
binary so that it is linked where the RAM is (or the flash, if
you prefer)...

-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]