https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106834
--- Comment #8 from Alexander Monakov <amonakov at gcc dot gnu.org> ---
Right, sorry, due to presence of 'main' I overlooked -fPIC in comment #0, and
then after my prompt it got dropped in comment #3.
If you modify the testcase as follows and compile it with -fPIC, it's evident
that GCC is treating both external symbols the same, but gas does not. Similar
to PR 106835, it seems Binutils is special-casing by symbol name. But here the
situation is worse, because GCC output is mentioning the intended relocation
kind:
movq _GLOBAL_OFFSET_TABLE_@GOTPCREL(%rip), %rax
so silently using R_X86_64_GOTOFF64 instead doesn't look right.
#include <stdio.h>
extern char _GLOBAL_OFFSET_TABLE_[];
extern char xGLOBAL_OFFSET_TABLE_[];
int main() {
printf("%lx", (unsigned long)_GLOBAL_OFFSET_TABLE_);
printf("%lx", (unsigned long)xGLOBAL_OFFSET_TABLE_);
}