public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: "Maciej W. Rozycki" <macro@orcam.me.uk>
To: YunQiang Su <syq@gcc.gnu.org>
Cc: Nick Clifton <nickc@redhat.com>, Xi Ruoyao <xry111@xry111.site>,
	 binutils@sourceware.org
Subject: Re: [PATCH] MIPS: support PCREL GOT access
Date: Fri, 1 Mar 2024 17:38:29 +0000 (GMT)	[thread overview]
Message-ID: <alpine.DEB.2.21.2403011724430.42226@angie.orcam.me.uk> (raw)
In-Reply-To: <CAKcpw6VaERuikC7dJnXnSOGRHrnokxipq8MWfTx+-bbs3ir_Hg@mail.gmail.com>

On Mon, 26 Feb 2024, YunQiang Su wrote:

> >  We can try and do our best to produce correctly linked executables and
> > shared libraries and provide testsuite coverage for what we do, and then
> 
> What my plan is (although I have no idea how to archive it with dejagnu):
>    1. f.c
>        int f() {return 0;}
>        mipsel-linux-gnu-gcc -O2 -mabi=32 f.c -shared -o libf.so
>    2. f1.c
>        extern int f();
>        int f1 () {return f();}
>        mipsel-linux-gnu-gcc -O2 f1.c -shared -L. -lf -o libf1.so

 But why do you want to write this code in C?  It's so trivial you can 
produce assembly for all the ABIs you want to cover (you can even start 
with compiler output if you don't want to handcode it from scratch) and 
use that as the test sources.  We'll be able to verify it reliably then, 
without a need for external components.

>    3. Let's inspect libf1.so with `objdump -DTC`
>        3.1 We can see the symbol 'f' is in an address, 00000520.
>              00000520      DF *UND*  00000000 f
>        3.2 We can see a line "00000520 <_MIPS_STUBS_>"
>        3.3 We can see the address of .got is "00010570 <__TMC_END__>"
>        3.3 We can see " 50c:   8f998040        lw      t9,-32704(gp)"
> in <f1>, and
>              GOT_ADR   +   GP_MAGIC + LW_OFFSET  = GOT_SLOT_OF_F
>              0x00010570 +  0x7ff0           + (-32704)          = 0x105a0
>        3.4 The content of address GOT_SLOT_OF_F (0x105a0) is 0x00000520.

 There are existing test cases in ld/testsuite/ld-mips-elf/mips-elf.exp 
that do various kinds of checks, including running multiple dump tools on 
single linker output.  Check the various `run_ld_link_tests' invocations.  
You can examine GOT entries in a cooked way with `readelf -A' BTW.

  Maciej

  reply	other threads:[~2024-03-01 17:38 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-31  8:32 YunQiang Su
2024-01-31  9:24 ` Xi Ruoyao
2024-02-02  1:25   ` YunQiang Su
2024-02-05 11:48     ` Nick Clifton
2024-02-05 12:59       ` Maciej W. Rozycki
2024-02-06 16:52         ` YunQiang Su
2024-02-06 19:47           ` Maciej W. Rozycki
2024-02-25 16:00             ` YunQiang Su
2024-03-01 17:38               ` Maciej W. Rozycki [this message]
2024-03-15 13:44                 ` YunQiang Su
2024-02-02  6:39 [PATCH] MIPS: Support " YunQiang Su
2024-02-02  6:42 ` YunQiang Su

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=alpine.DEB.2.21.2403011724430.42226@angie.orcam.me.uk \
    --to=macro@orcam.me.uk \
    --cc=binutils@sourceware.org \
    --cc=nickc@redhat.com \
    --cc=syq@gcc.gnu.org \
    --cc=xry111@xry111.site \
    /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).