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

            Bug ID: 98952
           Summary: powerpc*: __trampoline_setup inverted test for
                    trampoline size
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libgcc
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tuliom at ascii dot art.br
  Target Milestone: ---

In tramp.S, we have the following:

/* R3 = stack address to store trampoline */
/* R4 = length of trampoline area */
/* R5 = function address */
/* R6 = static chain */

FUNC_START(__trampoline_setup)
...
        li      r8,trampoline_size      /* verify that the trampoline is big
enough */
        cmpw    cr1,r8,r4
...
        blt     cr1,.Labort

It's aborting if r8 < r4.
However, I expected it to abort if r4 < r8, which means the allocated
trampoline area is not enough to fit the trampoline.

One could replace li + cmpw with just:

        cmpwi    cr1,r4,trampoline_size

I can't reproduce this issue on GCC because the allocated length (r4) is always
equals to the required length (r8).

However, this happens when mixing other compilers, e.g.
https://github.com/JuliaLang/julia/issues/32154#issuecomment-766536590

Reply via email to