public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libgcc/114158] New: Wrong FDPIC special-casing in crtstuff produces invalid pointer in init_array
@ 2024-02-28 20:36 bugdal at aerifal dot cx
  2024-02-28 21:17 ` [Bug libgcc/114158] " pinskia at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: bugdal at aerifal dot cx @ 2024-02-28 20:36 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 114158
           Summary: Wrong FDPIC special-casing in crtstuff produces
                    invalid pointer in init_array
           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: ---

Commit 11189793b6ef60645d5d1126d0bd9d0dd83e6583 introduced wrong special-casing
of FDPIC to __do_global_dtors_aux handling in crtstuff.c. For some reason, it
was assumed that, on FDPIC targets, init/fini arrays would contain instruction
addresses rather than function addresses (which are addresses of descriptors,
on FDPIC targets). This is NOT the case. The gABI contract of the init/fini
arrays is that they contain ABI-callable function pointers, and in fact GCC
correctly emits FUNCDESC-type relocations referencing then when translating
ctors/dtors, on ARM as well as sh.

It seems to have been realized that this was not working, as
6bcbf80c6e2bd8a60d88bbcac3d70ffb67f4888f disabled initfini arrays on ARM/FDPIC,
but didn't identify the root cause.

Commit 11189793b6ef60645d5d1126d0bd9d0dd83e6583 should be reverted ASAP, and
backported to all maintained versions, as it's actively breaking other targets
by putting an invalid function pointer in the init_array.

Commit 6bcbf80c6e2bd8a60d88bbcac3d70ffb67f4888f should also be reverted in
theory, but may need coordination with uclibc if they want to work around
binaries built with broken versions.

Further discussion of the issue can be found on the musl mailing list, in this
thread where myself and the author of the in-progress xtensa/fdpic port were
trying to figure out what's going on here:

https://www.openwall.com/lists/musl/2024/02/28/12

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

* [Bug libgcc/114158] Wrong FDPIC special-casing in crtstuff produces invalid pointer in init_array
  2024-02-28 20:36 [Bug libgcc/114158] New: Wrong FDPIC special-casing in crtstuff produces invalid pointer in init_array bugdal at aerifal dot cx
@ 2024-02-28 21:17 ` pinskia at gcc dot gnu.org
  2024-02-28 21:20 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-02-28 21:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
>6bcbf80c6e2bd8a60d88bbcac3d70ffb67f4888f

that seems unrelated "retain debug stmt order when moving to successors":
https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=6bcbf80c6e2bd8a60d88bbcac3d70ffb67f4888f

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

* [Bug libgcc/114158] Wrong FDPIC special-casing in crtstuff produces invalid pointer in init_array
  2024-02-28 20:36 [Bug libgcc/114158] New: Wrong FDPIC special-casing in crtstuff produces invalid pointer in init_array bugdal at aerifal dot cx
  2024-02-28 21:17 ` [Bug libgcc/114158] " pinskia at gcc dot gnu.org
@ 2024-02-28 21:20 ` pinskia at gcc dot gnu.org
  2024-02-28 22:07 ` jcmvbkbc at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-02-28 21:20 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #1)
> >6bcbf80c6e2bd8a60d88bbcac3d70ffb67f4888f
> 
> that seems unrelated "retain debug stmt order when moving to successors":
> https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;
> h=6bcbf80c6e2bd8a60d88bbcac3d70ffb67f4888f

so I think you mean 67b0605494f32811364e25328d3522467aaf0638 but that never was
committed upstream, it is only in the https://github.com/jcmvbkbc/gcc-xtensa
git repo.

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

* [Bug libgcc/114158] Wrong FDPIC special-casing in crtstuff produces invalid pointer in init_array
  2024-02-28 20:36 [Bug libgcc/114158] New: Wrong FDPIC special-casing in crtstuff produces invalid pointer in init_array bugdal at aerifal dot cx
  2024-02-28 21:17 ` [Bug libgcc/114158] " pinskia at gcc dot gnu.org
  2024-02-28 21:20 ` pinskia at gcc dot gnu.org
@ 2024-02-28 22:07 ` jcmvbkbc at gcc dot gnu.org
  2024-02-28 22:12 ` [Bug target/114158] " jcmvbkbc at gcc dot gnu.org
  2024-02-28 23:33 ` bugdal at aerifal dot cx
  4 siblings, 0 replies; 6+ messages in thread
From: jcmvbkbc at gcc dot gnu.org @ 2024-02-28 22:07 UTC (permalink / raw)
  To: gcc-bugs

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

jcmvbkbc at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jcmvbkbc at gcc dot gnu.org

--- Comment #3 from jcmvbkbc at gcc dot gnu.org ---
67b0605494f32811364e25328d3522467aaf0638 is my local fix to the change that was
introduced by the 5d727a4b20257275df59182b00f3bf240772cd0d. I believe that the
changes done in the latter commit to the libgcc/unwind-pe.h and
libstdc++-v3/libsupc++/eh_personality.cc need to be restricted to ARM only, if
needed at all. But that's separate from the crtstuff issue.

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

* [Bug target/114158] Wrong FDPIC special-casing in crtstuff produces invalid pointer in init_array
  2024-02-28 20:36 [Bug libgcc/114158] New: Wrong FDPIC special-casing in crtstuff produces invalid pointer in init_array bugdal at aerifal dot cx
                   ` (2 preceding siblings ...)
  2024-02-28 22:07 ` jcmvbkbc at gcc dot gnu.org
@ 2024-02-28 22:12 ` jcmvbkbc at gcc dot gnu.org
  2024-02-28 23:33 ` bugdal at aerifal dot cx
  4 siblings, 0 replies; 6+ messages in thread
From: jcmvbkbc at gcc dot gnu.org @ 2024-02-28 22:12 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from jcmvbkbc at gcc dot gnu.org ---
> It seems to have been realized that this was not working, as
> 6bcbf80c6e2bd8a60d88bbcac3d70ffb67f4888f disabled initfini arrays on ARM/FDPIC,
> but didn't identify the root cause.

I believe that 9c560cf23996271ee26dfc4a1d8484b85173cd12 was meant here.

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

* [Bug target/114158] Wrong FDPIC special-casing in crtstuff produces invalid pointer in init_array
  2024-02-28 20:36 [Bug libgcc/114158] New: Wrong FDPIC special-casing in crtstuff produces invalid pointer in init_array bugdal at aerifal dot cx
                   ` (3 preceding siblings ...)
  2024-02-28 22:12 ` [Bug target/114158] " jcmvbkbc at gcc dot gnu.org
@ 2024-02-28 23:33 ` bugdal at aerifal dot cx
  4 siblings, 0 replies; 6+ messages in thread
From: bugdal at aerifal dot cx @ 2024-02-28 23:33 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Rich Felker <bugdal at aerifal dot cx> ---
I don't know how I ended up copying the wrong commit id, but the one I meant to
reference was 9c560cf23996271ee26dfc4a1d8484b85173cd12.

Actually, I do know now. I got it out of the gitweb url which gratuitously ahs
the parent hash in a place where it's easy to accidentally copy instead of the
hash of the commit you're viewing (one of the many reasons I prefer cgit):

https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=9c560cf23996271ee26dfc4a1d8484b85173cd12;hp=6bcbf80c6e2bd8a60d88bbcac3d70ffb67f4888f

So indeed, the breakage was detected upstream and worked around, as I said.

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

end of thread, other threads:[~2024-02-28 23:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-28 20:36 [Bug libgcc/114158] New: Wrong FDPIC special-casing in crtstuff produces invalid pointer in init_array bugdal at aerifal dot cx
2024-02-28 21:17 ` [Bug libgcc/114158] " pinskia at gcc dot gnu.org
2024-02-28 21:20 ` pinskia at gcc dot gnu.org
2024-02-28 22:07 ` jcmvbkbc at gcc dot gnu.org
2024-02-28 22:12 ` [Bug target/114158] " jcmvbkbc at gcc dot gnu.org
2024-02-28 23:33 ` 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).