This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[lto]: PATCH: New section names.
- From: Kenneth Zadeck <zadeck at naturalbridge dot com>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>, "Zadeck, Kenneth" <zadeck at naturalbridge dot com>, "Mitchell, Mark" <mark at codesourcery dot com>
- Date: Fri, 08 Sep 2006 14:17:00 -0400
- Subject: [lto]: PATCH: New section names.
As mark suggested:
> > One piece of the api that has slipped through the cracks is what am I to
> > name the sections that the output is in.
> I suggest ".lto_$name", where $name is the function's
DECL_ASSEMBLER_NAME. We > should also select an ELF section type number
from the reserved portion of the number > space, but that's a detail we
can postpone.
Kenny
2006-09-08 Kenneth Zadeck <zadeck@naturalbridge.com>
* gcc/lto-function-out.c (produce_asm): Changed section name.
* gcc/lto-tags.h (LTO_SECTION_NAME_PREFIX): New symbol.
Index: gcc/lto-function-out.c
===================================================================
--- gcc/lto-function-out.c (revision 116759)
+++ gcc/lto-function-out.c (working copy)
@@ -1419,7 +1419,7 @@ produce_asm (struct output_block *ob, tr
int index;
tree decl;
tree type;
- tree fn = DECL_SECTION_NAME (function);
+ tree fn = DECL_ASSEMBLER_NAME (function);
char * section_name = xmalloc (SECTION_NAME_SIZE + 1);
const char * function_name;
@@ -1427,37 +1427,9 @@ produce_asm (struct output_block *ob, tr
unsigned int header_size = 8 + (7 * byte_size);
lto_out_ref out_ref = {0, NULL, NULL};
- /* FIXME!!!! While this got me thru a bootstrap, this will not fly
- in general. We must have a canonical mapping from function name
- to section names or we will never be able to find all of the
- functions. */
- if (fn == NULL_TREE)
- {
- int i = 0;
- int j;
- char c;
- strcpy (section_name, "____LTO____");
-
- function_name = IDENTIFIER_POINTER (DECL_NAME (function));
- j = strlen (section_name);
- while ((function_name[i]) && (j < SECTION_NAME_SIZE))
- {
- c = function_name[i++];
- if (isspace (c))
- section_name[j] = '_';
- else
- section_name[j] = c;
- j++;
- }
- section_name[j] = 0;
- }
- else
- {
- function_name = TREE_STRING_POINTER (fn);
- sprintf (section_name, "____LTO____%s", function_name);
- }
-
-
+ gcc_assert (fn);
+ function_name = IDENTIFIER_POINTER (fn);
+ sprintf (section_name, "%s%s", LTO_SECTION_NAME_PREFIX, function_name);
switch_to_section (get_section (section_name, SECTION_DEBUG, function));
/* Write the header which says how to decode the pieces of the
Index: gcc/lto-tags.h
===================================================================
--- gcc/lto-tags.h (revision 116759)
+++ gcc/lto-tags.h (working copy)
@@ -391,6 +391,10 @@
#define LTO_local_var_decl_body0 0x0B0
#define LTO_parm_decl_body0 0x0C0
+/* The string that is prepended on the DECL_ASSEMBLER_NAME to make the
+ section name for the function. */
+#define LTO_SECTION_NAME_PREFIX ".lto_"
+
extern sbitmap lto_types_needed_for;
void lto_static_init (void);