This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: ISO C violation (really -- style & string pasting)
If the user codes the name GLOBAL_OFFSET_TABLE_ (no "_") as a global
symbol in C, and on a system that prefixes underscores to user-space
names (as in Win32/Intel and a.out, at least), the user-space name
becomes _GLOBAL_OFFSET_TABLE_ in the .s file generated
by the compiler. _GLOBAL_OFFSET_TABLE_ is also generated by
the compiler as an internal symbol (for PIC), and the two
collide. GLOBAL_OFFSET_TABLE_, although an "odd" spelling, is
certainly a legal user namespace symbol.
Since the current uses of _GLOBAL_OFFSET_TABLE_ (which would
NOT present a problem for, e.g., ELF) are hardcoded into literal
strings in the compiler source (as part of instruction
source lines), which in turn becomes part of the .s file,
the symbol name needs to be changed in those strings,
which becomes a preprocessor trick.
Donn
Martin v. Loewis wrote:
>
> > The easy fix to this is to use a #define and (ISO) string-pasting.
> > However, I suspect the style rules disallow string-pasting.
>
> I have problems understanding how this fixes the problem (and probably
> what the problem is). The symbol _GLOBAL_OFFSET_TABLE_ only appears in
> assembler files, right? And it would only collide with a symbol of the
> same name appearing in application source code, right? How can you
> solve this conflict with the preprocessor?
>
> Curious,
> Martin
--
===================================================
Donn Terry mailto:donn@interix.com
Softway Systems, Inc. http://www.interix.com
2850 McClelland Dr, Ste. 1800 Ft.Collins CO 80525
Tel: +1-970-204-9900 Fax: +1-970-204-9951
===================================================