[Bug target/98482] -mfentry creates invalid call for -mcmodel=large

crazylht at gmail dot com gcc-bugzilla@gcc.gnu.org
Thu Jan 7 10:44:52 GMT 2021


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

--- Comment #1 from Hongtao.liu <crazylht at gmail dot com> ---
(In reply to Topi Miettinen from comment #0)
> GCC on x86_64 with `-mfentry` generates invalid code for `-mcmodel=large`.
> The call to `__fentry__` uses plain `call` instruction, but this can only
> address locations within 32 bit range while the target may be anywhere in
> the 64 bit range due to `-mcmodel=large`.
> 
> The expected code would be something which loads a 64 bit value to a
> register and then uses register indirect call, so instead of
>         call    __fentry__
> there needs to be
>         movabsq $__fentry__, %rax
>         call    *%rax

according to PSabi, %rax is not safe.
%rax
temporary register; with variable arguments No
passes information about the number of vector
registers used; 1 st return register

and by the time of output __fentry__ in gcc, register is already accocated, is
there any regs supposed to be safe in the entry of function? or we need to
spill reg to stack and load it back after call, it looks inefficient.


More information about the Gcc-bugs mailing list