public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: Alistair Francis <alistair23@gmail.com>
Cc: Alistair Francis via Libc-alpha <libc-alpha@sourceware.org>,
	Andreas Schwab <schwab@linux-m68k.org>,
	Alistair Francis <alistair.francis@wdc.com>
Subject: Re: [PATCH] Allow memset local PLT reference for RISC-V.
Date: Mon, 29 Jun 2020 18:53:24 +0200	[thread overview]
Message-ID: <87ftadvmnv.fsf@oldenburg2.str.redhat.com> (raw)
In-Reply-To: <CAKmqyKPKkzBGaYJvh63QEZ0aCUSvJTT-9kMx5fP6VtMDVjBf3w@mail.gmail.com> (Alistair Francis's message of "Mon, 29 Jun 2020 09:39:46 -0700")

* Alistair Francis:

> On Mon, Jun 29, 2020 at 9:39 AM Florian Weimer <fweimer@redhat.com> wrote:
>>
>> * Alistair Francis:
>>
>> > On Mon, Jun 29, 2020 at 9:30 AM Florian Weimer <fweimer@redhat.com> wrote:
>> >>
>> >> * Alistair Francis:
>> >>
>> >> > There is also a PLT memset in libc_pic.a
>> >> >
>> >> >  1bc:   009aa023                sw      s1,0(s5)
>> >> >           memset (result->__data, '\0',
>> >> >  1c0:   865e                    mv      a2,s7
>> >> >  1c2:   4581                    li      a1,0
>> >> >  1c4:   008a8513                addi    a0,s5,8
>> >> >  1c8:   00000097                auipc   ra,0x0
>> >> >                         1c8: R_RISCV_CALL_PLT   __GI_memset
>> >> >                         1c8: R_RISCV_RELAX      *ABS*
>> >> >  1cc:   000080e7                jalr    ra # 1c8 <.LVL39+0x14>
>> >>
>> >> That's weird.  What does a direct call (to a hidden symbol) look like,
>> >> relocation-wise.
>> >
>> > I'm not sure. How can I figure out?
>>
>> Look at different internal calls, e.g. __twalk_r and __libc_updwtmp (for
>> two variants, one with a hidden prototype and one without).
>
> Here is what I see from the libc_pic.a lib.
>
> __twalk_r
>
> 00000000         *UND*  00000000 __GI___twalk_r
> ...
>   __twalk_r (loaded, do_release_shlib, handle);
>  1b2:   4088                    lw      a0,0(s1)
>  1b4:   8622                    mv      a2,s0
>  1b6:   00000597                auipc   a1,0x0
>                         1b6: R_RISCV_PCREL_HI20 do_release_shlib
>                         1b6: R_RISCV_RELAX      *ABS*
>  1ba:   00058593                mv      a1,a1
>                         1ba: R_RISCV_PCREL_LO12_I       .L0
>                         1ba: R_RISCV_RELAX      *ABS*
>  1be:   00000097                auipc   ra,0x0
>                         1be: R_RISCV_CALL       __GI___twalk_r
>                         1be: R_RISCV_RELAX      *ABS*
>  1c2:   000080e7                jalr    ra # 1be <.L52+0xc>
>
> __libc_updwtmp
>
> 000009c0 g     F .text  00000124 .hidden __libc_updwtmp
> ...
> 00000064 <.LVL8>:
>   64:   0141                    addi    sp,sp,16
>   __libc_updwtmp (file_name, utmp);
>   66:   00000317                auipc   t1,0x0
>                         66: R_RISCV_CALL        __libc_updwtmp
>                         66: R_RISCV_RELAX       *ABS*
>   6a:   00030067                jr      t1 # 66 <.LVL8+0x2>

Okay, then the memcpy symbol hack does not work on RISC-V, and it's
worth fixing that.

It would be interesting to build iconv/gconv_open.c with --save-temps
and see what exactly ends up in the assembler file (and also what the
preprocessed sources look like).

Thanks,
Florian


  reply	other threads:[~2020-06-29 16:53 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-22 21:10 Alistair Francis
2020-06-23  7:19 ` Andreas Schwab
2020-06-24 22:25   ` Alistair Francis
2020-06-25  7:20     ` Florian Weimer
2020-06-25 18:16       ` Vineet Gupta
2020-06-25 18:41         ` Florian Weimer
2020-06-26  3:58           ` Vineet Gupta
2020-06-29  9:11     ` Florian Weimer
2020-06-29 15:58       ` Alistair Francis
2020-06-29 16:00         ` Alistair Francis
2020-06-29 16:18           ` Florian Weimer
2020-06-29 16:11         ` Florian Weimer
2020-06-29 16:15           ` Alistair Francis
2020-06-29 16:30             ` Florian Weimer
2020-06-29 16:25               ` Alistair Francis
2020-06-29 16:39                 ` Florian Weimer
2020-06-29 16:39                   ` Alistair Francis
2020-06-29 16:53                     ` Florian Weimer [this message]
2020-06-29 17:01                       ` Andreas Schwab
2020-06-29 17:05                         ` Florian Weimer
2020-06-29 17:44                           ` Andreas Schwab
2020-06-30  0:26                           ` Jim Wilson
2020-07-01  0:45                             ` Maciej W. Rozycki
2020-07-10 21:35                               ` Alistair Francis
2020-07-10 22:34                                 ` H.J. Lu
2020-07-12  1:32                                 ` Maciej W. Rozycki
2020-07-14  2:07                                   ` RISC-V: `ld.so' fails linking against `libgcc.a' built at `-O0' (was: Re: [PATCH] Allow memset local PLT reference for RISC-V.) Maciej W. Rozycki
2020-07-14  5:21                                     ` RISC-V: `ld.so' fails linking against `libgcc.a' built at `-O0' Andreas Schwab
2020-07-14  6:27                                       ` Richard Biener
2020-07-14  9:35                                         ` Maciej W. Rozycki
2020-08-20 22:39                                   ` [PATCH] Allow memset local PLT reference for RISC-V Alistair Francis
2020-08-21 10:44                                     ` Maciej W. Rozycki
2020-08-27 18:31                                       ` Alistair Francis
2020-09-12 21:51                                         ` Alistair Francis
2020-06-29 17:00             ` Andreas Schwab
2020-06-29 17:13               ` Florian Weimer
2020-06-29 17:46                 ` Andreas Schwab
2020-06-25  0:20   ` Vineet Gupta
2020-06-25 21:27 ` Palmer Dabbelt

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=87ftadvmnv.fsf@oldenburg2.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=alistair.francis@wdc.com \
    --cc=alistair23@gmail.com \
    --cc=libc-alpha@sourceware.org \
    --cc=schwab@linux-m68k.org \
    /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).