[PATCH - darwin] PR target/25376

Josh Conner jconner@apple.com
Mon Feb 6 17:48:00 GMT 2006


Roger Sayle wrote:
> Hi Josh,
> 
> On Fri, 3 Feb 2006, Josh Conner wrote:
>> target-supports.exp was incorrectly identifying darwin compilers as not
>> supporting named sections because they didn't compile this code:
>>
>>   int __attribute__ ((section("whatever"))) foo;
>>
>> In fact, named sections are supported by the darwin compiler, but
>> because "whatever" isn't a valid section identifier, the assembler was
>> rejecting it.
> 
> I'm just trying to understand some of the issues...  So I was
> wondering why "whatever" isn't a valid section identifier on darwin,
> and which identifiers are valid?

The darwin assembler requires a section specification in the form:

	.section segname, sectname

Such as:

	.section __TEXT, __foobar

> For example, it seems curious why we'd compile this test without
> assembling it.  Perhaps the compiler should issue a diagnostic if
> the __attribute__ ((section ...)) name isn't valid, or perhaps this
> code should be mangling the name so that it becomes valid.

The compiler will emit a diagnostic if the compiler doesn't support
named sections.  Otherwise, it simply passes the value along to the
assembler just like other inline-assembly-esque constructs.  One would
expect that any user specifying a section name is familiar with the
assembly-language constructs used on their system.

> That a user can't compile the code above, indicates that darwin has
> diminished functionality, though it isn't clear whether this is a
> restriction of the OS or a limition of the tool chain.  Perhaps we
> need a finer distinction such as SUPPORTS_ARBITRARY_NAMED_SECTIONS?
> Perhaps based upon compile vs. link testing.

I wouldn't say that Darwin has diminished functionality, any more than I
would say that another platform has diminished functionality for not
accepting:

	.section __TEXT, __foobar

They simply have different syntaxes.  While making a distinction in the
test suite may some day become necessary, right now we can accomplish
the same level of compiler testing without making that distinction --
none of the current tests that use section attributes are compromised by
stopping at assembly code.

>> 	* gcc/varasm.c (function_section) Check for section name before
>> 	calling select_section on targets that define
>> 	USE_SELECT_SECTION_FOR_FUNCTIONS.  On other targets, use
>> 	unlikely_text_section instead of named_section if
>> 	first_function_block_is_cold.
> 
> This should start "* varasm.c (function_section): Check for ..." as
> varasm.c is in the same directory as the ChangeLog, and the colon is
> required after the file location.

Yes, of course.  Thanks for pointing that out.

> This isn't a review.  Other maintainers are better qualified to
> judge the merits of this patch, this is just an asynchronous
> (non-blocking) discussion to help bring me up to speed.

Thanks - I really appreciate you looking at this.

- Josh



More information about the Gcc-patches mailing list