public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: joel@rtems.org
Cc: gdb@sourceware.org, Nick Clifton <nickc@redhat.com>
Subject: Re: Running programs on aarch64 simulator
Date: Fri, 8 May 2020 13:17:16 -0400	[thread overview]
Message-ID: <802bfcc2-2a74-ef30-eca0-b247a6d5b8f1@simark.ca> (raw)
In-Reply-To: <CAF9ehCUyGMc2mQW_n65saKx7jNd4R_-DGtcews-yDEbdf88NLg@mail.gmail.com>

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


  reply	other threads:[~2020-05-08 17:17 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-08 13:44 Joel Sherrill
2020-05-08 16:09 ` Simon Marchi
2020-05-08 16:57   ` Joel Sherrill
2020-05-08 17:17     ` Simon Marchi [this message]
2020-05-11  2:35       ` Simon Marchi
2020-05-11 14:26       ` Nick Clifton
2020-05-11 14:40         ` Joel Sherrill
2020-05-11 17:58           ` Jim Wilson
2020-05-11 18:30             ` Joel Sherrill
2020-05-11 22:13               ` Jim Wilson
2020-05-08 16:16 ` Luis Machado
2020-05-08 16:44   ` Joel Sherrill

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=802bfcc2-2a74-ef30-eca0-b247a6d5b8f1@simark.ca \
    --to=simark@simark.ca \
    --cc=gdb@sourceware.org \
    --cc=joel@rtems.org \
    --cc=nickc@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).