public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
To: Noah Goldstein <goldstein.w.n@gmail.com>
Cc: GNU C Library <libc-alpha@sourceware.org>
Subject: Re: [PATCH] nptl: x86_64: Use stackinfo.h definition for CURRENT_STACK_FRAME
Date: Mon, 29 Aug 2022 17:20:25 -0300	[thread overview]
Message-ID: <adbafd37-8666-9454-b740-b6a71ebdeba6@linaro.org> (raw)
In-Reply-To: <CAFUsyfJmnMUDAtAvZtqWpj-iYKes9K39Y2t6u2WmGaQ9QzSa7A@mail.gmail.com>



On 29/08/22 16:24, Noah Goldstein wrote:
> On Mon, Aug 29, 2022 at 12:00 PM Adhemerval Zanella via Libc-alpha
> <libc-alpha@sourceware.org> wrote:
>>
>> It avoids the possible warning of uninitialized 'frame' variable when
>> building with clang:
>>
>>   ../sysdeps/nptl/jmp-unwind.c:27:42: error: variable 'frame' is
>>   uninitialized when used here [-Werror,-Wuninitialized]
>>     __pthread_cleanup_upto (env->__jmpbuf, CURRENT_STACK_FRAME);
>>
>> It increases the generated code by one instruction:
>>
>> --- master
>> +++ patch
>> @@ -25068,11 +25068,11 @@ Disassembly of section .text:
>>     3db1b:      00 00
>>     3db1d:      48 89 44 24 08          mov    %rax,0x8(%rsp)
>>     3db22:      31 c0                   xor    %eax,%eax
>> -   3db24:      48 8b 44 24 08          mov    0x8(%rsp),%rax
>> -   3db29:      64 48 2b 04 25 28 00    sub    %fs:0x28,%rax
>> -   3db30:      00 00
>> -   3db32:      75 0c                   jne    3db40
>>     <_longjmp_unwind+0x30>
>> -   3db34:      48 89 e6                mov    %rsp,%rsi
>> +   3db24:      48 89 e6                mov    %rsp,%rsi
>> +   3db27:      48 8b 44 24 08          mov    0x8(%rsp),%rax
>> +   3db2c:      64 48 2b 04 25 28 00    sub    %fs:0x28,%rax
>> +   3db33:      00 00
>> +   3db35:      75 09                   jne    3db40
>>     <_longjmp_unwind+0x30>
>>     3db37:      48 83 c4 18             add    $0x18,%rsp
>>     3db3b:      e9 60 31 05 00          jmp    90ca0
>> <__GI___pthread_cleanup_upto>
>>     3db40:      e8 4b ec 0e 00          call   12c790 <__stack_chk_fail>
>>
>> Checked on x86_64-linux-gnu.
>> ---
>>  sysdeps/x86/nptl/pthreaddef.h | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/sysdeps/x86/nptl/pthreaddef.h b/sysdeps/x86/nptl/pthreaddef.h
>> index 63fdbcb27c..3ff95efee6 100644
>> --- a/sysdeps/x86/nptl/pthreaddef.h
>> +++ b/sysdeps/x86/nptl/pthreaddef.h
>> @@ -42,7 +42,7 @@
>>  #ifdef __x86_64__
>>  /* The frame pointer is not usable.  */
>>  # define CURRENT_STACK_FRAME \
>> -  ({ register char *frame __asm__("rsp"); frame; })
>> +  ({ void *p__; asm volatile ("mov %%" RSP_REG ", %0" : "=r" (p__)); p__; })
> 
> Is the mov instruction needed at all?
> 
> Would:
> ```
> ({ register void * p__ __asm__("rsp"); asm volatile("" : "=r"(p__)); p__; });
> ```
> work?

This works, thanks. I will send an update version.

      reply	other threads:[~2022-08-29 20:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-29 19:00 Adhemerval Zanella
2022-08-29 19:24 ` Noah Goldstein
2022-08-29 20:20   ` Adhemerval Zanella Netto [this message]

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=adbafd37-8666-9454-b740-b6a71ebdeba6@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=goldstein.w.n@gmail.com \
    --cc=libc-alpha@sourceware.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).