https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88954
--- Comment #4 from H.J. Lu <hjl.tools at gmail dot com> ---
(In reply to Martin Sebor from comment #3)
> My question is about the change you are proposing. How do you expect g() to
> be called if the test case from comment #0 is modified for example as
> follows:
>
> void f_plt(void);
> void f_noplt(void) __attribute__((noplt));
> void (*p_noplt)(void) = f_noplt;
> void g(void (*)(void));
>
> int main()
> {
> if (getenv ("USE_PLT"))
> p_noplt = f_plt; // should this be diagnosed?
f_plt will be handled by
000000404020 000600000007 R_X86_64_JUMP_SLO 0000000000401040 f_plt + 0
> g (p_noplt);
> }
>
> In most other cases, initializing a pointer with the address of a function
> declared with some function attribute (e.g., const, nonnull, noreturn, pure,
> or warn_unused_result) doesn't transfer the special properties to the
> pointer, so I'm trying to understand what semantics you are after and if
> there is any potential for user errors and decide whether they should be
> detected.
>
> I happen to think it would make sense to make it possible to imbue function
> pointers with some (but not all) of the same attributes as those that apply
> to functions, but there certainly are cases where doing so could cause
> problems, just as there are cases where not doing so can.
__attribute__((noplt)) only applies to functions, which instructors
compiler to avoid PLT when accessing the marked function, via function
pointer nor direct call. The function pointer itself has no impact
on PLT.