aboutsummaryrefslogtreecommitdiff
path: root/ld/ldlang.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2008-05-31 16:35:56 +0000
committerNick Clifton <nickc@redhat.com>2008-05-31 16:35:56 +0000
commitde7dd2bdee702cd4a187c09427bd42b7eee239ec (patch)
tree40d84aa2c577867c71021aeb9f0ddc5bc74c6614 /ld/ldlang.c
parentc7eb6be45e424188fd6f1035ca747f4295f2588c (diff)
downloadgdb-de7dd2bdee702cd4a187c09427bd42b7eee239ec.zip
gdb-de7dd2bdee702cd4a187c09427bd42b7eee239ec.tar.gz
gdb-de7dd2bdee702cd4a187c09427bd42b7eee239ec.tar.bz2
PR ld/6430
* testsuite/ld-elfcomm/elfcomm.exp (test_sort_common): Test the ascending/descending argument to the --sort-common command line option. * testsuite/ld-elfcomm/sort-common.s: New file. * ld.h (enum sort_order): New. * ldlang.c (lang_check: Fix comment. (lang_common): Sort commons in ascending or descending order. (lang_one_common): Likewise. * lexsup.c (ld_options): Have --sort-common take an option argument. (parse_args): Handle argument to --sort-common. * ld.texinfo (--sort-common): Document new optional argument. * NEWS: Mention new feature.
Diffstat (limited to 'ld/ldlang.c')
-rw-r--r--ld/ldlang.c38
1 files changed, 32 insertions, 6 deletions
diff --git a/ld/ldlang.c b/ld/ldlang.c
index d3018b2..c8aac29 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -20,6 +20,8 @@
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
MA 02110-1301, USA. */
+#include <limits.h>
+
#include "sysdep.h"
#include "bfd.h"
#include "libiberty.h"
@@ -2699,6 +2701,13 @@ closest_target_match (const bfd_target *target, void *data)
if (target->flavour != original->flavour)
return 0;
+ /* Ignore generic big and little endian elf vectors. */
+ if ( strcmp (target->name, "elf32-big") == 0
+ || strcmp (target->name, "elf64-big") == 0
+ || strcmp (target->name, "elf32-little") == 0
+ || strcmp (target->name, "elf64-little") == 0)
+ return 0;
+
/* If we have not found a potential winner yet, then record this one. */
if (winner == NULL)
{
@@ -5419,7 +5428,7 @@ lang_check (void)
/* Look through all the global common symbols and attach them to the
correct section. The -sort-common command line switch may be used
- to roughly sort the entries by size. */
+ to roughly sort the entries by alignment. */
static void
lang_common (void)
@@ -5434,10 +5443,24 @@ lang_common (void)
bfd_link_hash_traverse (link_info.hash, lang_one_common, NULL);
else
{
- int power;
+ unsigned int power;
- for (power = 4; power >= 0; power--)
- bfd_link_hash_traverse (link_info.hash, lang_one_common, &power);
+ if (config.sort_common == sort_descending)
+ {
+ for (power = 4; power > 0; power--)
+ bfd_link_hash_traverse (link_info.hash, lang_one_common, &power);
+
+ power = 0;
+ bfd_link_hash_traverse (link_info.hash, lang_one_common, &power);
+ }
+ else
+ {
+ for (power = 0; power <= 4; power++)
+ bfd_link_hash_traverse (link_info.hash, lang_one_common, &power);
+
+ power = UINT_MAX;
+ bfd_link_hash_traverse (link_info.hash, lang_one_common, &power);
+ }
}
}
@@ -5456,8 +5479,11 @@ lang_one_common (struct bfd_link_hash_entry *h, void *info)
size = h->u.c.size;
power_of_two = h->u.c.p->alignment_power;
- if (config.sort_common
- && power_of_two < (unsigned int) *(int *) info)
+ if (config.sort_common == sort_descending
+ && power_of_two < *(unsigned int *) info)
+ return TRUE;
+ else if (config.sort_common == sort_ascending
+ && power_of_two > *(unsigned int *) info)
return TRUE;
section = h->u.c.p->section;