diff options
author | Aldy Hernandez <aldyh@redhat.com> | 2015-06-09 09:43:07 +0000 |
---|---|---|
committer | Aldy Hernandez <aldyh@gcc.gnu.org> | 2015-06-09 09:43:07 +0000 |
commit | 9aa5f7ec0c0c4045d2a346c4aa90f36642fbb7af (patch) | |
tree | 5ef9d90973a87299d38d438beb670bc25797e7c3 | |
parent | 8602ca0a2d8e709edc530d283be75af9963b0489 (diff) | |
download | gcc-9aa5f7ec0c0c4045d2a346c4aa90f36642fbb7af.zip gcc-9aa5f7ec0c0c4045d2a346c4aa90f36642fbb7af.tar.gz gcc-9aa5f7ec0c0c4045d2a346c4aa90f36642fbb7af.tar.bz2 |
varasm.c (output_object_block_htab): Remove.
* varasm.c (output_object_block_htab): Remove.
(output_object_block_compare): New.
(output_object_blocks): Sort named object_blocks before outputting
them.
From-SVN: r224274
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/varasm.c | 47 |
2 files changed, 47 insertions, 7 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c4897ca..7adf74a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2015-06-09 Aldy Hernandez <aldyh@redhat.com> + + * varasm.c (output_object_block_htab): Remove. + (output_object_block_compare): New. + (output_object_blocks): Sort named object_blocks before outputting + them. + 2015-06-09 Richard Biener <rguenther@suse.de> PR tree-optimization/66419 diff --git a/gcc/varasm.c b/gcc/varasm.c index 95cb539..b2ad795 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -7413,14 +7413,31 @@ output_object_block (struct object_block *block) } } -/* A htab_traverse callback used to call output_object_block for - each member of object_block_htab. */ +/* A callback for qsort to compare object_blocks. */ -int -output_object_block_htab (object_block **slot, void *) +static int +output_object_block_compare (const void *x, const void *y) { - output_object_block (*slot); - return 1; + object_block *p1 = *(object_block * const*)x; + object_block *p2 = *(object_block * const*)y; + + if (p1->sect->common.flags & SECTION_NAMED + && !(p2->sect->common.flags & SECTION_NAMED)) + return 1; + + if (!(p1->sect->common.flags & SECTION_NAMED) + && p2->sect->common.flags & SECTION_NAMED) + return -1; + + if (p1->sect->common.flags & SECTION_NAMED + && p2->sect->common.flags & SECTION_NAMED) + return strcmp (p1->sect->named.name, p2->sect->named.name); + + unsigned f1 = p1->sect->common.flags; + unsigned f2 = p2->sect->common.flags; + if (f1 == f2) + return 0; + return f1 < f2 ? -1 : 1; } /* Output the definitions of all object_blocks. */ @@ -7428,7 +7445,23 @@ output_object_block_htab (object_block **slot, void *) void output_object_blocks (void) { - object_block_htab->traverse<void *, output_object_block_htab> (NULL); + vec<object_block *, va_heap> v; + v.create (object_block_htab->elements ()); + object_block *obj; + hash_table<object_block_hasher>::iterator hi; + + FOR_EACH_HASH_TABLE_ELEMENT (*object_block_htab, obj, object_block *, hi) + v.quick_push (obj); + + /* Sort them in order to output them in a deterministic manner, + otherwise we may get .rodata sections in different orders with + and without -g. */ + v.qsort (output_object_block_compare); + unsigned i; + FOR_EACH_VEC_ELT (v, i, obj) + output_object_block (obj); + + v.release (); } /* This function provides a possible implementation of the |