This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH: resolve unique sections before writing the constant pool
- From: Jaka Močnik <jaka at xlab dot si>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Erich Focht <efocht at hpce dot nec dot com>
- Date: Thu, 05 Mar 2009 13:07:37 +0100
- Subject: PATCH: resolve unique sections before writing the constant pool
hi!
attached is a rather obvious patch against current trunk to
gcc/varasm.c:assemble_start_function() that calls
resolve_unique_section() *before* outputting constant pool (when the
pool is output before actual function code).
in this manner, select_rtx_section hook that is called for each constant
while writing the constant pool, is able to retrieve the real function
code section using
function_section (current_function_decl);
namely: right now, when you compile with -ffunction-sections for a
target that puts constant pool before the function, the above returns
the default .text section, while the code for function foo() is put in
section .text.foo, which seems like a bug.
(otoh, if the target writes the constant pool after the function, the
above call returns the proper section .text.foo, as
resolve_unique_sections was called before: this is OK, but it's
confusing that the behaviour differs depending on whether the pool is
before or after the function)
the patch fixes this problem, and also unifies the constant pool writing
behaviour regardless of whether the pool is put before or after the
function, which seems the right thing to do.
the changelog:
2009-02-12 Jaka Mocnik <jaka@xlab.si>
* gcc/varasm.c (assemble_start_function): call
resolve_unique_section() before outputting the
constant pool. this enables the pool output code
to access the actual function code section.
regards,
jaKa
--
email: jaka@xlab.si
w3: http://www.gmajna.net/svojat/jaka/
Index: gcc/varasm.c
===================================================================
--- gcc/varasm.c (revision 144638)
+++ gcc/varasm.c (working copy)
@@ -1658,11 +1658,11 @@
app_disable ();
+ resolve_unique_section (decl, 0, flag_function_sections);
+
if (CONSTANT_POOL_BEFORE_FUNCTION)
output_constant_pool (fnname, decl);
- resolve_unique_section (decl, 0, flag_function_sections);
-
/* Make sure the not and cold text (code) sections are properly
aligned. This is necessary here in the case where the function
has both hot and cold sections, because we don't want to re-set