https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119386
--- Comment #4 from Franz Sirl <sirl at gcc dot gnu.org> ---
> Note that the GCC man page is pretty clear about this:
>
> -mdirect-extern-access
> -mno-direct-extern-access
>
> Do not use or use GOT to access external symbols. The default is
> -mno-direct-extern-access: GOT is used for external symbols with default
> visibility, but not used for other external symbols.
>
> With -mdirect-extern-access, GOT is not used and all external
> symbols are PC-relatively addressed. It is only suitable for
> environments where no dynamic link is performed, like firmwares, OS
> kernels, executables linked with -static or -static-pie.
> -mdirect-extern-access is not compatible with -fPIC or -fpic.
This is a quote from the LoongArch option, the x86 option reads:
'-mno-direct-extern-access'
Without '-fpic' nor '-fPIC', always use the GOT pointer to access
external symbols. With '-fpic' or '-fPIC', treat access to
protected symbols as local symbols. The default is
'-mdirect-extern-access'.
*Warning:* shared libraries compiled with
'-mno-direct-extern-access' and executable compiled with
'-mdirect-extern-access' may not be binary compatible if protected
symbols are used in shared libraries and executable.