On Fri, Apr 4, 2025 at 9:00 AM Ard Biesheuvel <ardb+...@google.com> wrote: > > From: Ard Biesheuvel <a...@kernel.org> > > Commit bde21de1205 ("i386: Honour -mdirect-extern-access when calling > __fentry__") updated the logic that emits mcount() / __fentry__() calls > into function prologues when profiling is enabled, to avoid GOT-based > indirect calls when a direct call would suffice. > > There are two problems with that change: > - it relies on -mdirect-extern-access rather than -fno-plt to decide > whether or not a direct [PLT based] call is appropriate; > - for the PLT case, it falls through to x86_print_call_or_nop(), which > does not emit the @PLT suffix, resulting in the wrong relocation to be > used (R_X86_64_PC32 instead of R_X86_64_PLT32) > > Fix this by testing flag_plt instead of ix86_direct_extern_access, and > updating x86_print_call_or_nop() to take flag_pic and flag_plt into > account. This ensures that -mnop-mcount works as expected when emitting > the PLT based profiling calls. > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119386 > > Signed-off-by: Ard Biesheuvel <a...@kernel.org> > > gcc/ChangeLog: > > * config/i386/i386.cc (x86_function_profiler): Take > ix86_direct_extern_access into account when generating calls > to __fentry__()
I'm not a specialist in this part of the compiler, but all relevant people took part in the (long) discussion in the PR and came to the above consensus. So, I'm rubber-stamping this patch OK. Ard, are you able to commit the patch yourself, or I should commit it for you? Thanks, Uros.