This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: ISO C violation (really -- style & string pasting)


That won't work. It's exactly what I started with, but ran into
the need for string pasting.  Since "_GLOBAL_OFFSET_TABLE_" is
imbedded in longer literal strings, either I create 4 distinct strings
in the header (obscure, at best) or I use some form of string
pasting.

Here are some code excerpts:

i386.md:  output_asm_insn (\"addl $_GLOBAL_OFFSET_TABLE_+[.-%X1],%0\", operands)
;
i386.c:                                             "$_GLOBAL_OFFSET_TABLE_"),
i386.c:   output_asm_insn ("addl $_GLOBAL_OFFSET_TABLE_,%0", xops);
i386.c:   output_asm_insn ("addl $_GLOBAL_OFFSET_TABLE_+[.-%P1],%0", xops);

I'm sure you're right that no one has noticed before because
no-one (else) uses COFF and PIC.

So back to the question: what can I use to paste the strings
together that's stylistically reasonable.   I'd love to write
something like:

#define GOT_SYMBOL_NAME "__GLOBAL_OFFSET_TABLE_"
output_asm_insn ("addl $"  GOT_SYMBOL_NAME ",%0", xops);

which is perfectly legal ISO C, but I suspect that reliance
on string pasting is not going to fly.  Thus, a new ASn macro
seems at least reasonable (but I don't really like it).

Donn

Richard Henderson wrote:
> 
> On Wed, Mar 24, 1999 at 05:34:18PM -0700, Donn Terry wrote:
> > The easy fix to this is to use a #define and (ISO) string-pasting.
> > However, I suspect the style rules disallow string-pasting.
> > (If they don't, then we're done, and I'm home free.)
> 
> No.  Just create a GLOBAL_OFFSET_TABLE_SYMBOL define to use
> within i386.{h,c,md} instead of the current string literal.
> You can then override this for coff or whatever as needed.
> 
> Probably no one's noticed this before because coff doesn't
> use pic on any currently supported platform.
> 
> r~

-- 

===================================================
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
===================================================


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]