public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug dynamic-link/27279] New: x86_64 _dl_runtime_resolve should preserve r10/r11
@ 2021-01-29 19:35 foom at fuhm dot net
  2021-02-01  8:45 ` [Bug dynamic-link/27279] " fweimer at redhat dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: foom at fuhm dot net @ 2021-01-29 19:35 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=27279

            Bug ID: 27279
           Summary: x86_64 _dl_runtime_resolve should preserve r10/r11
           Product: glibc
           Version: unspecified
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: dynamic-link
          Assignee: unassigned at sourceware dot org
          Reporter: foom at fuhm dot net
  Target Milestone: ---

This is arguably _not_ actually a bug. Yet, I still think it should probably be
fixed.

The x86-64 abi does not specify which registers should be preserved through a
lazy PLT stub resolution (unlike, say, the AARCH64 psABI which specifies that
all registers but r16, r17 must be preserved). Thus, it's arguably unacceptable
to use _any_ non-standard calling convention when calling through a PLT that
might invoke lazy binding.

However, users do this, and expect it to work, and are upset when it doesn't
work.

Because of that, the current state of x86_64's _dl_runtime_resolve is that it
_does_ preserve nearly every register, even those which are not required by any
specification. This changed most recently in 2017, via bug 21265, after some
debate -- seemingly resulting in grudging agreement that supporting other
calling conventions was a reasonable thing to do after all (grumble grumble).

After that change, _almost_ all registers -- vector, float, and GPR -- are now
preserved either explicitly in the assembly code, or implicitly via being
callee-save in the C function it calls.

But unfortunately, there are two GPRs which still get clobbered: r10 and r11.
And, there's a calling convention which expects all GPRs except r11 to be
preserved: <https://clang.llvm.org/docs/AttributeReference.html#preserve-most>.
This has caused a bug in a piece of software, where the developer didn't
realize that the "preserve_most" calling convention was incompatible with calls
that might go through a PLT stub.

So -- since lazy PLT resolution is already _so close_ to saving literally
everything, and the cost of additionally saving r10/r11 is so low compared to
everything else it's doing, I'd propose that _dl_runtime_resolve should be
modified to save those final 2 still-clobbered GPRs.

And thus, finally, be transparent to ANY calling convention anyone might want
to use.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-03-02  5:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-29 19:35 [Bug dynamic-link/27279] New: x86_64 _dl_runtime_resolve should preserve r10/r11 foom at fuhm dot net
2021-02-01  8:45 ` [Bug dynamic-link/27279] " fweimer at redhat dot com
2021-02-01 22:46 ` martijn.vels at gmail dot com
2021-03-02  5:06 ` foom at fuhm dot net

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).