public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libgcc/114060] New: asm constraints getting GOT address for ARM/FDPIC look wrong
@ 2024-02-22 18:32 bugdal at aerifal dot cx
  2024-02-22 18:59 ` [Bug libgcc/114060] " pinskia at gcc dot gnu.org
  2024-02-22 19:05 ` [Bug target/114060] " bugdal at aerifal dot cx
  0 siblings, 2 replies; 3+ messages in thread
From: bugdal at aerifal dot cx @ 2024-02-22 18:32 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114060

            Bug ID: 114060
           Summary: asm constraints getting GOT address for ARM/FDPIC look
                    wrong
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libgcc
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bugdal at aerifal dot cx
  Target Milestone: ---

Reading the code added for unwind-pe.h for FDPIC, I came across the ARM
implementation that uses FDPIC_REGNUM as an input constraint to __asm to get
the GOT register value. As I understand it, this is not correct, as there is no
contract that this register permanently hold the GOT address for the executing
code; it's just a hidden argument register for making function calls, which the
callee can throw away if it does not need to access the GOT or any global data,
or spill and reload.

To reliably get the GOT register, I think you need to make an actual external
call to an asm function that movs the GOT register to the return-value register
and returns.

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

* [Bug libgcc/114060] asm constraints getting GOT address for ARM/FDPIC look wrong
  2024-02-22 18:32 [Bug libgcc/114060] New: asm constraints getting GOT address for ARM/FDPIC look wrong bugdal at aerifal dot cx
@ 2024-02-22 18:59 ` pinskia at gcc dot gnu.org
  2024-02-22 19:05 ` [Bug target/114060] " bugdal at aerifal dot cx
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-02-22 18:59 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114060

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
https://github.com/mickael-guene/fdpic_doc/blob/master/abi.txt

>as there is no contract that this register permanently hold the GOT address for the executing code

So I am reading the GCC code, it looks like it is though.

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

* [Bug target/114060] asm constraints getting GOT address for ARM/FDPIC look wrong
  2024-02-22 18:32 [Bug libgcc/114060] New: asm constraints getting GOT address for ARM/FDPIC look wrong bugdal at aerifal dot cx
  2024-02-22 18:59 ` [Bug libgcc/114060] " pinskia at gcc dot gnu.org
@ 2024-02-22 19:05 ` bugdal at aerifal dot cx
  1 sibling, 0 replies; 3+ messages in thread
From: bugdal at aerifal dot cx @ 2024-02-22 19:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114060

--- Comment #2 from Rich Felker <bugdal at aerifal dot cx> ---
How could there be such a contract? In order to call any other function, the
GOT address of the callee needs to be loaded, replacing the caller's value,
which must be spilled and reloaded if it's needed again -- but if it's not
needed again, it makes sense to just discard it.

On SH (and AFAIK FRV, the original FDPIC), GCC happily discards the FDPIC/GOT
register when it won't be used again.

Maybe as an implementation detail GCC is not doing that on ARM right now, but
if not, that's probably a big missed optimization and not something libgcc
unwinder code should be relying on.

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

end of thread, other threads:[~2024-02-22 19:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-22 18:32 [Bug libgcc/114060] New: asm constraints getting GOT address for ARM/FDPIC look wrong bugdal at aerifal dot cx
2024-02-22 18:59 ` [Bug libgcc/114060] " pinskia at gcc dot gnu.org
2024-02-22 19:05 ` [Bug target/114060] " bugdal at aerifal dot cx

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