aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2019-09-06 12:23:41 +0930
committerAlan Modra <amodra@gmail.com>2019-09-06 12:55:37 +0930
commitf5c3a9e3055224d8ed8140d48c96465294839e95 (patch)
tree0e20f57b81079c94d9a11dcda841b6ddce7f348e /ld
parentb16c44debcf8a446e94e161e328169f5c8d5d811 (diff)
downloadgdb-f5c3a9e3055224d8ed8140d48c96465294839e95.zip
gdb-f5c3a9e3055224d8ed8140d48c96465294839e95.tar.gz
gdb-f5c3a9e3055224d8ed8140d48c96465294839e95.tar.bz2
beos.em qsort predicate tidy
lang_input_section_type** is better than lang_statement_union_type** here since that is in fact the type passed to the qsort predicate, and I think it's worth factoring out the common indirections. * emultempl/beos.em (sort_by_file_name): Use appropriate intermediary variables. (sort_by_section_name): Likewise.
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog6
-rw-r--r--ld/emultempl/beos.em53
2 files changed, 30 insertions, 29 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 13abd72..84a15d6 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,5 +1,11 @@
2019-09-06 Alan Modra <amodra@gmail.com>
+ * emultempl/beos.em (sort_by_file_name): Use appropriate
+ intermediary variables.
+ (sort_by_section_name): Likewise.
+
+2019-09-06 Alan Modra <amodra@gmail.com>
+
* emultempl/elf32.em (gld${EMULATION_NAME}_search_needed): Constify
variable.
* emultempl/pe.em (gld_${EMULATION_NAME}_after_open): Likewise.
diff --git a/ld/emultempl/beos.em b/ld/emultempl/beos.em
index bf75c54..3ec285b 100644
--- a/ld/emultempl/beos.em
+++ b/ld/emultempl/beos.em
@@ -393,17 +393,18 @@ gld_${EMULATION_NAME}_after_open (void)
static int
sort_by_file_name (const void *a, const void *b)
{
- const lang_statement_union_type *const *ra = a;
- const lang_statement_union_type *const *rb = b;
+ const lang_input_section_type *const *ra = a;
+ const lang_input_section_type *const *rb = b;
+ asection *sa = (*ra)->section;
+ asection *sb = (*rb)->section;
int i, a_sec, b_sec;
- i = filename_cmp ((*ra)->input_section.section->owner->my_archive->filename,
- (*rb)->input_section.section->owner->my_archive->filename);
+ i = filename_cmp (sa->owner->my_archive->filename,
+ sb->owner->my_archive->filename);
if (i != 0)
return i;
- i = filename_cmp ((*ra)->input_section.section->owner->filename,
- (*rb)->input_section.section->owner->filename);
+ i = filename_cmp (sa->owner->filename, sb->owner->filename);
if (i != 0)
return i;
/* the tail idata4/5 are the only ones without relocs to an
@@ -412,36 +413,29 @@ sort_by_file_name (const void *a, const void *b)
and HNT properly. if no reloc this one is import by ordinal
so we have to sort by section contents */
- if ((*ra)->input_section.section->reloc_count
- + (*rb)->input_section.section->reloc_count)
+ if (sa->reloc_count + sb->reloc_count != 0)
{
- i = ((*ra)->input_section.section->reloc_count
- > (*rb)->input_section.section->reloc_count) ? -1 : 0;
+ i = sa->reloc_count > sb->reloc_count ? -1 : 0;
if (i != 0)
return i;
- return ((*ra)->input_section.section->reloc_count
- > (*rb)->input_section.section->reloc_count) ? 0 : 1;
+ return sa->reloc_count > sb->reloc_count ? 0 : 1;
}
else
{
/* don't sort .idata$6 or .idata$7 FIXME dlltool eliminate .idata$7 */
- if ((strcmp ((*ra)->input_section.section->name, ".idata$6") == 0))
+ if ((strcmp (sa->name, ".idata$6") == 0))
return 0;
- if (!bfd_get_section_contents ((*ra)->input_section.section->owner,
- (*ra)->input_section.section, &a_sec,
- (file_ptr) 0,
- (bfd_size_type) sizeof(a_sec)))
+ if (!bfd_get_section_contents (sa->owner, sa, &a_sec, (file_ptr) 0,
+ (bfd_size_type) sizeof (a_sec)))
einfo (_("%F%P: %pB: can't read contents of section .idata: %E\n"),
- (*ra)->input_section.section->owner);
+ sa->owner);
- if (!bfd_get_section_contents ((*rb)->input_section.section->owner,
- (*rb)->input_section.section, &b_sec,
- (file_ptr) 0,
- (bfd_size_type) sizeof(b_sec)))
+ if (!bfd_get_section_contents (sb->owner, sb, &b_sec, (file_ptr) 0,
+ (bfd_size_type) sizeof (b_sec)))
einfo (_("%F%P: %pB: can't read contents of section .idata: %E\n"),
- (*rb)->input_section.section->owner);
+ sb->owner);
i = a_sec < b_sec ? -1 : 0;
if (i != 0)
@@ -454,18 +448,19 @@ sort_by_file_name (const void *a, const void *b)
static int
sort_by_section_name (const void *a, const void *b)
{
- const lang_statement_union_type *const *ra = a;
- const lang_statement_union_type *const *rb = b;
+ const lang_input_section_type *const *ra = a;
+ const lang_input_section_type *const *rb = b;
+ const char *sna = (*ra)->section->name;
+ const char *snb = (*rb)->section->name;
int i;
- i = strcmp ((*ra)->input_section.section->name,
- (*rb)->input_section.section->name);
+ i = strcmp (sna, snb);
/* This is a hack to make .stab and .stabstr last, so we don't have
to fix strip/objcopy for .reloc sections.
FIXME stripping images with a .rsrc section still needs to be fixed. */
if (i != 0)
{
- if ((CONST_STRNEQ ((*ra)->input_section.section->name, ".stab"))
- && (! CONST_STRNEQ ((*rb)->input_section.section->name, ".stab")))
+ if ((CONST_STRNEQ (sna, ".stab"))
+ && (!CONST_STRNEQ (snb, ".stab")))
return 1;
}
return i;