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]
Other format: [Raw text]

Is this a GCC bug?


Hello,
I encountered a problem in porting GCC (4.3.0) when I tried to make
contructor/destructor work. The following is the error message compiling
crtstuff.c.  

../../src/gcc/crtstuff.c: In function 'call___do_global_ctors_aux': 
../../src/gcc/crtstuff.c:562: error: expected string literal before '('
token 

Line 562 is:
...
CRT_CALL_STATIC_FUNCTION (INIT_SECTION_ASM_OP, __do_global_ctors_aux)
...

The following is how the macro CRT_CALL_STATIC_FUNCTION is defined. 

#ifndef CRT_CALL_STATIC_FUNCTION
# define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
static void __attribute__((__used__))   \
call_ ## FUNC (void)     \
{       \
  asm (SECTION_OP);     \
  FUNC ();      \
  FORCE_CODE_SECTION_ALIGN    \
  asm (TEXT_SECTION_ASM_OP);    \
}
#endif

Here is the C code of line 562 after preprocessing in our porting:
static void __attribute__((__used__)) call___do_global_ctors_aux (void)
{ asm ("\t.section\t.init"); __do_global_ctors_aux (); asm
((firepath_fnsc ? "\t.section .textc, \"axC\"" : "\t.section .text,
\"axU\"")); }


The error is because inline asm only accepts string literal, not an
expression.  Our definitiion of TEXT_SECTION_ASM_OP is a string depends
on one of our particular targets. 

According to GCC internal manual, it is clearly stated that
TEXT_SECTION_ASM_OP can be an expression. 

TEXT_SECTION_ASM_OP
A C expression whose value is a string, including spacing, containing
the assembler
operation that should precede instructions and read-only data. Normally
"\t.text"
is right.

So I guess either internal manual or crtstuff.c is wrong. Or I am making
some stupid mistake here. Could someone have a look at this?  Thanks in
advance.

Cheers,
Bingfeng Mei
Broadcom UK


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