Re: Running programs on aarch64 simulator

Simon Marchi <[email protected]>
Newsgroups gmane.comp.gdb.devel
Message-ID <[email protected]>
On 2020-05-08 12:57 p.m., Joel Sherrill wrote:
> On all the elf/eabi targets I have tried over the years, CPU-elf-gcc produced an a.out that was linked with the installed libgloss. I randomly had an sh-elf toolchain laying around and it worked like "sh-elf-gcc m.c" and then both sh-elf-gdb and sh-elf-run could run it on the gdb simulator.
> 
> The aarch64-elf toolchain installs 4 .specs files from libgloss but adding -specs XXX and trying each with the gdb simulator (via aarch64-elf-run) all fail.
> 
> home/joel/test-gcc/install-master/aarch64-elf/lib/aem-validation.specs
> /home/joel/test-gcc/install-master/aarch64-elf/lib/aem-ve.specs
> /home/joel/test-gcc/install-master/aarch64-elf/lib/nosys.specs
> /home/joel/test-gcc/install-master/aarch64-elf/lib/rdimon.specs

Ok, I am not familiar with that.

Well, it did work for me to build with:

$ aarch64-none-elf-gcc test.c -g3 -O0 -o test -specs=nosys.specs

I didn't have to provide my own _exit.  According to the DWARF info, the _exit now
included in my program comes from:

  /tmp/dgboter/bbs/rhev-vm1--rhe6x86_64/buildbot/rhe6x86_64--aarch64-none-elf/build/src/newlib-cygwin/libgloss/libnosys/_exit.c

> 
> This seems to be an odd case where there is a simulator in the source tree and there is no clear way to use it. Assuming it works.

It's also possible to run it directly like this:

$ ./sim/aarch64/run gdb/test
core: 8 byte write to unmapped address 0xfffffff0 at 0x0
program stopped with signal 11 (Segmentation fault).

The result is the same as when I ran it through GDB.  I have no idea if it's the sim that
is faulty, or the binary needs to be compiled differently.

> 
>     Program received signal SIGSEGV, Segmentation fault.
>     0x0000000000000000 in ?? ()
> 
> 
> That matches what luck I had on master. I suspect that is a mismatch between
> the address map of the simulator and whatever the default linker script does.

Perhaps.  With the ARM simulator, when I do "starti" in GDB, I see that it starts
executing at the ELF file's entry point.  With the AArch64 simulator, it starts
at 0 (the entry point of the ELF is not 0).  So I also suspect that the initial
PC is not right.

> 
>     I did not push the investigation further.
> 
> 
> I think Nick may be the key to getting an answer here. 

Added him in CC, we'll see :).

Simon
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.