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]

RE: Documentation problem with TEXT_SECTION_ASM_OP


On Wed, 24 Oct 2012, Paulo Matos wrote:

> I gave it a go with TEXT_SECTION_ASM_OP.

Given what you've found, maybe other macros are easier to convert....

> I started by changing crtstuff.c to use __LIBGCC_TEXT_SECTION_ASM_OP__ 
> instead of TEXT_SECTION_ASM_OP. I noticed crtstuff.c is not compiled 
> with -fbuilding-libgcc so I added the flags to CRTSTUFF_T_CFLAGS in my 
> makefile fragment.

That would seem to make sense anyway.

>       /* For libgcc crtstuff.c. */
> #ifdef TEXT_SECTION_ASM_OP
>       builtin_define_with_value ("__LIBGCC_TEXT_SECTION_ASM_OP__",
> 				 TEXT_SECTION_ASM_OP, true);
> #else
>       /* Is text_section always an unnamed section? */
>       builtin_define_with_value ("__LIBGCC_TEXT_SECTION_ASM_OP__",
> 				 (const char *)text_section->unnamed.data, true);
> #endif
>     }
> 
> The reason for the ifdef is because the docs allow the backend to define 
> either TEXT_SECTION_ASM_OP or the text_section directly in 
> TARGET_ASM_INIT_SECTIONS.
> Therefore if we don't have TEXT_SECTION_ASM_OP we need to grab the text 
> string from text_section. I assumed text_section was defined in 
> TARGET_ASM_INIT_SECTIONS with an unnamed section (that's how I did it) 
> but I am unsure if this is a general assumption.

I don't like this #else.  Presumably the libgcc code already works if 
TEXT_SECTION_ASM_OP isn't defined at all.  So the equivalent is simply not 
to define __LIBGCC_TEXT_SECTION_ASM_OP__ in that case, rather than 
synthesizing a definition from other information.

If however you want to synthesize a definition, then I think 
TEXT_SECTION_ASM_OP should be converted to a target hook (at least to the 
extent of targhooks.c being the only place testing it, if it remains at 
all), so that the logic generating predefined macros is unconditional.

> #define __LIBGCC_TEXT_SECTION_ASM_OP__ "        .section .text, "axU""

So you should teach builtin_define_with_value to generate proper escapes 
when producing a string.

-- 
Joseph S. Myers
joseph@codesourcery.com


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