diff options
author | mmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-11-27 04:25:32 +0000 |
---|---|---|
committer | mmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-11-27 04:25:32 +0000 |
commit | f9e78c9f5a4a049340bf7c9e6856cdf1275aaeee (patch) | |
tree | dc69a39eb4eeb180a5f560c64bc91ce58d7cb806 /gcc/config/elfos.h | |
parent | 54b3a5af68144ff8b2506c78d326cdfebd15e9c2 (diff) | |
download | gcc-f9e78c9f5a4a049340bf7c9e6856cdf1275aaeee.tar.gz |
* config/elfos.h (ASM_OUTPUT_SECTION_NAME): Use a hash table, not
a list, to keep track of the sections.
* tm.texi (ASM_OUTPUT_SECTION_NAME): Document the fact that the
parameter provided will always be a canonical string.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@37776 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/config/elfos.h')
-rw-r--r-- | gcc/config/elfos.h | 43 |
1 files changed, 26 insertions, 17 deletions
diff --git a/gcc/config/elfos.h b/gcc/config/elfos.h index 3a2f2925423..9925ff5cf33 100644 --- a/gcc/config/elfos.h +++ b/gcc/config/elfos.h @@ -421,20 +421,27 @@ dtors_section () \ #define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \ do \ { \ - static struct section_info \ + static htab_t htab; \ + \ + struct section_info \ { \ - struct section_info *next; \ - char *name; \ enum sect_enum {SECT_RW, SECT_RO, SECT_EXEC} type; \ - } *sections; \ + }; \ + \ struct section_info *s; \ const char *mode; \ - enum sect_enum type; \ - \ - for (s = sections; s; s = s->next) \ - if (!strcmp (NAME, s->name)) \ - break; \ - \ + enum sect_enum type; \ + PTR* slot; \ + \ + /* The names we put in the hashtable will always be the unique \ + versions gived to us by the stringtable, so we can just use \ + their addresses as the keys. */ \ + if (!htab) \ + htab = htab_create (31, \ + htab_hash_pointer, \ + htab_eq_pointer, \ + NULL); \ + \ if (DECL && TREE_CODE (DECL) == FUNCTION_DECL) \ type = SECT_EXEC, mode = "ax"; \ else if (DECL && DECL_READONLY_SECTION (DECL, RELOC)) \ @@ -442,21 +449,23 @@ dtors_section () \ else \ type = SECT_RW, mode = "aw"; \ \ - if (s == 0) \ - { \ + \ + /* See if we already have an entry for this section. */ \ + slot = htab_find_slot (htab, NAME, INSERT); \ + if (!*slot) \ + { \ s = (struct section_info *) xmalloc (sizeof (* s)); \ - s->name = xmalloc ((strlen (NAME) + 1) * sizeof (* NAME)); \ - strcpy (s->name, NAME); \ s->type = type; \ - s->next = sections; \ - sections = s; \ + *slot = s; \ fprintf (FILE, "\t.section\t%s,\"%s\",@progbits\n", \ NAME, mode); \ } \ else \ { \ + s = (struct section_info *) *slot; \ if (DECL && s->type != type) \ - error_with_decl (DECL, "%s causes a section type conflict");\ + error_with_decl (DECL, \ + "%s causes a section type conflict"); \ \ fprintf (FILE, "\t.section\t%s\n", NAME); \ } \ |