On Sat, Jan 31, 2015 at 05:09:29PM -0700, Simon Glass wrote: > I have been fighting with a strange problem on ARM where gcc puts all > the .rodata from a number of files lumped into a single .rodata > section even when -fdata-sections is used. > > I searched and found a bug report here: > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54303 > > which exactly describes the problem I see.
You could try this patch. I think there were still some problems with it, there must have been some reason I didn't submit it. Cannot have been just laziness :-P Cheers, Segher >From 1c1ebc41fca45f497e019a5ab433c68d23010f31 Mon Sep 17 00:00:00 2001 Message-Id: <1c1ebc41fca45f497e019a5ab433c68d23010f31.1422864485.git.seg...@kernel.crashing.org> From: Segher Boessenkool <seg...@kernel.crashing.org> Date: Sat, 12 Oct 2013 15:41:50 -0700 Subject: [PATCH] Make mergeable read-only sections per-function, if requested. --- gcc/varasm.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/gcc/varasm.c b/gcc/varasm.c index 295c27d..ee57a45 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -740,6 +740,16 @@ default_no_function_rodata_section (tree decl ATTRIBUTE_UNUSED) return readonly_data_section; } +const char * +function_mergeable_rodata_prefix (void) +{ + section *s = targetm.asm_out.function_rodata_section (current_function_decl); + if (SECTION_STYLE (s) == SECTION_NAMED) + return s->named.name; + else + return targetm.asm_out.mergeable_rodata_prefix; +} + /* Return the section to use for string merging. */ static section * @@ -761,7 +771,7 @@ mergeable_string_section (tree decl ATTRIBUTE_UNUSED, const char *str; HOST_WIDE_INT i; int j, unit; - const char *prefix = targetm.asm_out.mergeable_rodata_prefix; + const char *prefix = function_mergeable_rodata_prefix (); char *name = (char *) alloca (strlen (prefix) + 30); mode = TYPE_MODE (TREE_TYPE (TREE_TYPE (decl))); @@ -814,7 +824,7 @@ mergeable_constant_section (enum machine_mode mode ATTRIBUTE_UNUSED, && align <= 256 && (align & (align - 1)) == 0) { - const char *prefix = targetm.asm_out.mergeable_rodata_prefix; + const char *prefix = function_mergeable_rodata_prefix (); char *name = (char *) alloca (strlen (prefix) + 30); sprintf (name, "%s.cst%d", prefix, (int) (align / 8)); -- 1.8.1.4