This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] PR target/25376 Restore named section functionality to darwin
- From: Josh Conner <jconner at apple dot com>
- To: Geoffrey Keating <geoffk at geoffk dot org>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Wed, 14 Dec 2005 08:35:51 -0800
- Subject: Re: [PATCH] PR target/25376 Restore named section functionality to darwin
- References: <439DC00E.50800@apple.com> <m264ps7bhb.fsf@greed.local>
Geoffrey Keating wrote:
> Josh Conner <jconner@apple.com> writes:
>
>
>>Use of the section attribute for a function is silently ignored for
>>targets that define USE_SELECT_SECTION_FOR_FUNCTIONS (currently, only
>>darwin).
>>
>>The attached patch restores this functionality by not using
>>select_section for named sections. I chose not to implement the logic
>>inside of select_section itself because this logic is not handled by
>>select_section on other targets.
>
>
> Yes, that's the right approach; select_selection is supposed to behave
> the same way whether it's given a variable or a function. Since
> variables have the section attribute handled by the generic code,
> functions should have it too.
>
> But, you need to update current_function_section, too, or it'll be
> inconsistent. Send a new patch with that change?
Thanks for the review. Attached is an updated patch - I hand-verified
by testing with a function containing a jump table which was incorrectly
split with my previous patch. OK for mainline if it passes regression
testing?
- Josh
Index: gcc/varasm.c
===================================================================
--- gcc/varasm.c (revision 108463)
+++ gcc/varasm.c (working copy)
@@ -424,14 +424,14 @@ function_section (tree decl)
if (first_function_block_is_cold)
reloc = 1;
-#ifdef USE_SELECT_SECTION_FOR_FUNCTIONS
- return targetm.asm_out.select_section (decl, reloc, DECL_ALIGN (decl));
-#else
if (decl != NULL_TREE
&& DECL_SECTION_NAME (decl) != NULL_TREE
&& targetm.have_named_sections)
return get_named_section (decl, NULL, 0);
else
+#ifdef USE_SELECT_SECTION_FOR_FUNCTIONS
+ return targetm.asm_out.select_section (decl, reloc, DECL_ALIGN (decl));
+#else
return text_section;
#endif
}
@@ -442,6 +442,11 @@ current_function_section (void)
#ifdef USE_SELECT_SECTION_FOR_FUNCTIONS
int reloc = 0;
+ if (current_function_decl != NULL_TREE
+ && DECL_SECTION_NAME (current_function_decl) != NULL_TREE
+ && targetm.have_named_sections)
+ return get_named_section (current_function_decl, NULL, 0);
+
if (unlikely_text_section_p (last_text_section))
reloc = 1;