* [Bug c/106835] [i386] Taking an address of _GLOBAL_OFFSET_TABLE_ produces a wrong value
2022-09-05 8:53 [Bug c/106835] New: [i386] Taking an address of _GLOBAL_OFFSET_TABLE_ produces a wrong value rui314 at gmail dot com
@ 2022-09-05 8:57 ` amonakov at gcc dot gnu.org
2022-09-05 9:37 ` jakub at gcc dot gnu.org
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: amonakov at gcc dot gnu.org @ 2022-09-05 8:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106835
Alexander Monakov <amonakov at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |amonakov at gcc dot gnu.org
--- Comment #1 from Alexander Monakov <amonakov at gcc dot gnu.org> ---
Surely this is a Binutils (assembler) bug? gcc emits
ptr:
.long _GLOBAL_OFFSET_TABLE_
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c/106835] [i386] Taking an address of _GLOBAL_OFFSET_TABLE_ produces a wrong value
2022-09-05 8:53 [Bug c/106835] New: [i386] Taking an address of _GLOBAL_OFFSET_TABLE_ produces a wrong value rui314 at gmail dot com
2022-09-05 8:57 ` [Bug c/106835] " amonakov at gcc dot gnu.org
@ 2022-09-05 9:37 ` jakub at gcc dot gnu.org
2022-09-05 11:18 ` amonakov at gcc dot gnu.org
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-09-05 9:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106835
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Perhaps s/bug/feature/
Some symbol names are simply special in certain assembler dialects and imply
certain relocations, in other assembler dialects all relocations are explicit.
_GLOBAL_OFFSET_TABLE_ begins with underscore and upper case letter, so it is a
reserved name, so it is fine if the above testcase means something different
from what you expect.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c/106835] [i386] Taking an address of _GLOBAL_OFFSET_TABLE_ produces a wrong value
2022-09-05 8:53 [Bug c/106835] New: [i386] Taking an address of _GLOBAL_OFFSET_TABLE_ produces a wrong value rui314 at gmail dot com
2022-09-05 8:57 ` [Bug c/106835] " amonakov at gcc dot gnu.org
2022-09-05 9:37 ` jakub at gcc dot gnu.org
@ 2022-09-05 11:18 ` amonakov at gcc dot gnu.org
2022-09-05 11:21 ` jakub at gcc dot gnu.org
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: amonakov at gcc dot gnu.org @ 2022-09-05 11:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106835
--- Comment #3 from Alexander Monakov <amonakov at gcc dot gnu.org> ---
It would be unfortunate if that makes it difficult or even impossible to make a
R_386_32 relocation for the address of GOT in hand-written assembly.
In any case, it seems GCC is not making the rules here, so this should be
reported against Binutils so they can clarify the situation?
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c/106835] [i386] Taking an address of _GLOBAL_OFFSET_TABLE_ produces a wrong value
2022-09-05 8:53 [Bug c/106835] New: [i386] Taking an address of _GLOBAL_OFFSET_TABLE_ produces a wrong value rui314 at gmail dot com
` (2 preceding siblings ...)
2022-09-05 11:18 ` amonakov at gcc dot gnu.org
@ 2022-09-05 11:21 ` jakub at gcc dot gnu.org
2022-09-05 16:46 ` hjl.tools at gmail dot com
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-09-05 11:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106835
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I think there are ways to get around it, adding an alias to _G_O_T_ and using
that alias.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c/106835] [i386] Taking an address of _GLOBAL_OFFSET_TABLE_ produces a wrong value
2022-09-05 8:53 [Bug c/106835] New: [i386] Taking an address of _GLOBAL_OFFSET_TABLE_ produces a wrong value rui314 at gmail dot com
` (3 preceding siblings ...)
2022-09-05 11:21 ` jakub at gcc dot gnu.org
@ 2022-09-05 16:46 ` hjl.tools at gmail dot com
2022-09-06 1:05 ` rui314 at gmail dot com
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: hjl.tools at gmail dot com @ 2022-09-05 16:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106835
--- Comment #5 from H.J. Lu <hjl.tools at gmail dot com> ---
To access this special symbol:
[hjl@gnu-tgl-3 tmp]$ cat c.c
#include <stdio.h>
extern char GLOBAL_OFFSET_TABLE[];
char *ptr = GLOBAL_OFFSET_TABLE;
int main() {
printf("%lx\n", (unsigned long)ptr);
}
[hjl@gnu-tgl-3 tmp]$ gcc -m32 c.c
/usr/local/bin/ld: /tmp/ccK14eSl.o:(.data+0x0): undefined reference to
`GLOBAL_OFFSET_TABLE'
collect2: error: ld returned 1 exit status
[hjl@gnu-tgl-3 tmp]$ gcc -m32 c.c
-Wl,--defsym,GLOBAL_OFFSET_TABLE=_GLOBAL_OFFSET_TABLE_
[hjl@gnu-tgl-3 tmp]$ ./a.out
804bff4
[hjl@gnu-tgl-3 tmp]$
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c/106835] [i386] Taking an address of _GLOBAL_OFFSET_TABLE_ produces a wrong value
2022-09-05 8:53 [Bug c/106835] New: [i386] Taking an address of _GLOBAL_OFFSET_TABLE_ produces a wrong value rui314 at gmail dot com
` (4 preceding siblings ...)
2022-09-05 16:46 ` hjl.tools at gmail dot com
@ 2022-09-06 1:05 ` rui314 at gmail dot com
2022-09-06 15:55 ` hjl.tools at gmail dot com
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: rui314 at gmail dot com @ 2022-09-06 1:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106835
--- Comment #6 from Rui Ueyama <rui314 at gmail dot com> ---
If it silently produces a value that doesn't make sense, shouldn't we ban the
use of the variable or at least show a warning?
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c/106835] [i386] Taking an address of _GLOBAL_OFFSET_TABLE_ produces a wrong value
2022-09-05 8:53 [Bug c/106835] New: [i386] Taking an address of _GLOBAL_OFFSET_TABLE_ produces a wrong value rui314 at gmail dot com
` (5 preceding siblings ...)
2022-09-06 1:05 ` rui314 at gmail dot com
@ 2022-09-06 15:55 ` hjl.tools at gmail dot com
2022-09-06 21:58 ` hjl.tools at gmail dot com
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: hjl.tools at gmail dot com @ 2022-09-06 15:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106835
H.J. Lu <hjl.tools at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://sourceware.org/bugz
| |illa/show_bug.cgi?id=29551
--- Comment #7 from H.J. Lu <hjl.tools at gmail dot com> ---
(In reply to Rui Ueyama from comment #6)
> If it silently produces a value that doesn't make sense, shouldn't we ban
> the use of the variable or at least show a warning?
I opened:
https://sourceware.org/bugzilla/show_bug.cgi?id=29551
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c/106835] [i386] Taking an address of _GLOBAL_OFFSET_TABLE_ produces a wrong value
2022-09-05 8:53 [Bug c/106835] New: [i386] Taking an address of _GLOBAL_OFFSET_TABLE_ produces a wrong value rui314 at gmail dot com
` (6 preceding siblings ...)
2022-09-06 15:55 ` hjl.tools at gmail dot com
@ 2022-09-06 21:58 ` hjl.tools at gmail dot com
2022-10-21 2:54 ` pinskia at gcc dot gnu.org
2022-10-21 2:55 ` pinskia at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: hjl.tools at gmail dot com @ 2022-09-06 21:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106835
--- Comment #8 from H.J. Lu <hjl.tools at gmail dot com> ---
GCC generates _GLOBAL_OFFSET_TABLE_ to indicate GOTPC32 relocation. It can't
be
treated as a normal symbol.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c/106835] [i386] Taking an address of _GLOBAL_OFFSET_TABLE_ produces a wrong value
2022-09-05 8:53 [Bug c/106835] New: [i386] Taking an address of _GLOBAL_OFFSET_TABLE_ produces a wrong value rui314 at gmail dot com
` (7 preceding siblings ...)
2022-09-06 21:58 ` hjl.tools at gmail dot com
@ 2022-10-21 2:54 ` pinskia at gcc dot gnu.org
2022-10-21 2:55 ` pinskia at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-10-21 2:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106835
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |INVALID
--- Comment #9 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
_GLOBAL_OFFSET_TABLE_ is in the implementation reserved namespace (due to the
underscore and capital letter) so an user using it and thinking it should do
something is just undefined.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c/106835] [i386] Taking an address of _GLOBAL_OFFSET_TABLE_ produces a wrong value
2022-09-05 8:53 [Bug c/106835] New: [i386] Taking an address of _GLOBAL_OFFSET_TABLE_ produces a wrong value rui314 at gmail dot com
` (8 preceding siblings ...)
2022-10-21 2:54 ` pinskia at gcc dot gnu.org
@ 2022-10-21 2:55 ` pinskia at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-10-21 2:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106835
--- Comment #10 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Rui Ueyama from comment #6)
> If it silently produces a value that doesn't make sense, shouldn't we ban
> the use of the variable or at least show a warning?
That is PR 51437 for a warning on reserved names.
^ permalink raw reply [flat|nested] 11+ messages in thread