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

            Bug ID: 94729
           Summary: aarch64:
                    __attribute__((target("branch-protection=pac-ret")))
                    is accepted in ilp32
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nsz at gcc dot gnu.org
  Target Milestone: ---

-mbranch-protection=pac-ret is not supported in ilp32
so i would expect the related attribute to be a compile
time error. (or a warning that it is ignored on ilp32)

gcc generates pac-ret instructions with -mabi=ilp32
which will almost surely fail at runtime on a pac-ret
enabled system:

long bar(void);
__attribute__((target("branch-protection=pac-ret")))
long foo(void)
{
    return bar()+1;
} 

becomes

foo:
        hint    25 // paciasp
        stp     x29, x30, [sp, -16]!
        mov     x29, sp
        bl      bar
        add     w0, w0, 1
        ldp     x29, x30, [sp], 16
        hint    29 // autiasp
        ret

Reply via email to