aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2019-10-14 13:53:40 +1030
committerAlan Modra <amodra@gmail.com>2019-10-14 16:47:13 +1030
commit47f6ff2f9e679cd1f7af6fecbba5f62daf3bee95 (patch)
tree7081cd5447bc4af5a12bfd3a404f363b5481bf72 /bfd
parent8025b0554c5a2e2fe56b769fd556fe13268b4879 (diff)
downloadgdb-47f6ff2f9e679cd1f7af6fecbba5f62daf3bee95.zip
gdb-47f6ff2f9e679cd1f7af6fecbba5f62daf3bee95.tar.gz
gdb-47f6ff2f9e679cd1f7af6fecbba5f62daf3bee95.tar.bz2
qsort: syms.c stab sorting
* syms.c (struct indexentry): Add idx field. (cmpindexentry): Final sort on idx. (_bfd_stab_section_find_nearest_line): Set idx.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog6
-rw-r--r--bfd/syms.c10
2 files changed, 13 insertions, 3 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 3593fa8..a1eaef9 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,11 @@
2019-10-14 Alan Modra <amodra@gmail.com>
+ * syms.c (struct indexentry): Add idx field.
+ (cmpindexentry): Final sort on idx.
+ (_bfd_stab_section_find_nearest_line): Set idx.
+
+2019-10-14 Alan Modra <amodra@gmail.com>
+
* dwarf2.c (struct lookup_funcinfo): Add idx field.
(compare_lookup_funcinfos): Perform final sort on idx.
(build_lookup_funcinfo_table): Set idx.
diff --git a/bfd/syms.c b/bfd/syms.c
index 9a2754e..146f674 100644
--- a/bfd/syms.c
+++ b/bfd/syms.c
@@ -884,6 +884,7 @@ struct indexentry
char *directory_name;
char *file_name;
char *function_name;
+ int idx;
};
/* Compare two indexentry structures. This is called via qsort. */
@@ -896,10 +897,9 @@ cmpindexentry (const void *a, const void *b)
if (contestantA->val < contestantB->val)
return -1;
- else if (contestantA->val > contestantB->val)
+ if (contestantA->val > contestantB->val)
return 1;
- else
- return 0;
+ return contestantA->idx - contestantB->idx;
}
/* A pointer to this structure is stored in *pinfo. */
@@ -1198,6 +1198,7 @@ _bfd_stab_section_find_nearest_line (bfd *abfd,
info->indextable[i].directory_name = directory_name;
info->indextable[i].file_name = file_name;
info->indextable[i].function_name = NULL;
+ info->indextable[i].idx = i;
++i;
}
@@ -1257,6 +1258,7 @@ _bfd_stab_section_find_nearest_line (bfd *abfd,
info->indextable[i].directory_name = directory_name;
info->indextable[i].file_name = file_name;
info->indextable[i].function_name = function_name;
+ info->indextable[i].idx = i;
++i;
break;
}
@@ -1270,6 +1272,7 @@ _bfd_stab_section_find_nearest_line (bfd *abfd,
info->indextable[i].directory_name = directory_name;
info->indextable[i].file_name = file_name;
info->indextable[i].function_name = NULL;
+ info->indextable[i].idx = i;
++i;
}
@@ -1279,6 +1282,7 @@ _bfd_stab_section_find_nearest_line (bfd *abfd,
info->indextable[i].directory_name = NULL;
info->indextable[i].file_name = NULL;
info->indextable[i].function_name = NULL;
+ info->indextable[i].idx = i;
++i;
info->indextablesize = i;