mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Andre McCurdy <armccurdy@gmail.com>
To: musl@lists.openwall.com
Subject: Re: How to handle attempts to combine ARM Thumb with frame pointers?
Date: Fri, 27 Oct 2017 17:48:28 -0700	[thread overview]
Message-ID: <CAJ86T=WeKpULx=mrUtKqDuDQSxWakEizrEzbO5CyR5t4-AJk4Q@mail.gmail.com> (raw)
In-Reply-To: <CAJ86T=XxaAf9AjQDdVM5ux49T5Q2=ceu=_0_e87FKG1ND-Pr9g@mail.gmail.com>

On Thu, Oct 26, 2017 at 7:17 PM, Andre McCurdy <armccurdy@gmail.com> wrote:
> On Thu, Oct 26, 2017 at 5:33 PM, Rich Felker <dalias@libc.org> wrote:
>> On Thu, Oct 26, 2017 at 11:51:17AM -0700, Andre McCurdy wrote:
>>> >> But perhaps an alternative way to detect whether the current
>>> >> combination of compiler + cflags is going to try to use frame pointers
>>> >> is to compile a trivial function to assembler and parse the output. I
>>> >> haven't tested clang, but gcc adds a helpful "frame_needed" comment
>>> >> which is easy to grep for.
>>> >
>>> > This is not a good approach. It depends on specific compiler behavior
>>> > (text that's not part of the code) and thus has both false negatives
>>> > and false positives (it would break on compilers that allow you to use
>>> > r7 in asm constraints even when the compiler is using frame pointers).
>>>
>>> Yes, agreed. Just checking for the gcc comment isn't robust. But I
>>> think there are other differences between the two cases which could be
>>> detected reliably with a slightly more elaborate test, e.g. checking
>>> for the use of r7 in the object code (assuming that for a trivial
>>> function which just returns there's no reason that the compiler would
>>> ever use of r7 except for a frame pointer).
>>
>> That's not really a reasonable assumption. There are all sorts of
>> reasons the compiler might use a particular register even in a trivial
>> function, for instrumentation, sanitizer, etc. type reasons.
>
> True. But these are all false positives. If any of these other reasons
> were to cause musl to use out of line syscalls then there's no real
> negative impact, apart from a missed optimisation.
>
> If I understand the glibc approach correctly it doesn't do any kind of
> test and always falls back to out of line syscalls for Thumb. Even if
> musl added a test which could generate a false positive it would be
> doing better than glibc.

For some additional context, this appears to be the glibc solution for
similar issues on x86:

  https://sourceware.org/bugzilla/show_bug.cgi?id=21029
  https://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=3b33d6ed6096c1d20d05a650b06026d673f7399a

It seems to be based around a configure test which relies on the gcc
compile time error to determine whether or not it's possible to inline
syscalls.


  reply	other threads:[~2017-10-28  0:48 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-07  0:53 Andre McCurdy
2017-10-07  1:24 ` Khem Raj
2017-10-07  1:41 ` Andre McCurdy
2017-10-08  3:21 ` Rich Felker
2017-10-09 16:48   ` Andre McCurdy
2017-10-25 21:16     ` Szabolcs Nagy
2017-10-26 16:48       ` Adhemerval Zanella
2017-10-26 17:00         ` Rich Felker
2017-10-26 17:48           ` Andre McCurdy
2017-10-26 17:54             ` Rich Felker
2017-10-26 18:51               ` Andre McCurdy
2017-10-27  0:33                 ` Rich Felker
2017-10-27  2:17                   ` Andre McCurdy
2017-10-28  0:48                     ` Andre McCurdy [this message]
2017-10-26 18:46           ` Adhemerval Zanella
2017-10-27  0:30             ` Rich Felker
2017-10-27 11:47             ` Szabolcs Nagy

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='CAJ86T=WeKpULx=mrUtKqDuDQSxWakEizrEzbO5CyR5t4-AJk4Q@mail.gmail.com' \
    --to=armccurdy@gmail.com \
    --cc=musl@lists.openwall.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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).