# HG changeset patch # User Michael Spacefalcon # Date 1396508408 0 # Node ID 5f4141ee175bfea1a8113f0078183e2d3e50c64a # Parent 2f23301d2f8653e728f3272c5d41cde3626ce7f4 tiobjd: retain the original symtab order for symbols at the same position diff -r 2f23301d2f86 -r 5f4141ee175b ticoff/intstruct.h --- a/ticoff/intstruct.h Thu Apr 03 06:50:07 2014 +0000 +++ b/ticoff/intstruct.h Thu Apr 03 07:00:08 2014 +0000 @@ -18,6 +18,7 @@ }; struct internal_syment { + unsigned number; char *name; unsigned value; int scnum; diff -r 2f23301d2f86 -r 5f4141ee175b ticoff/symtab.c --- a/ticoff/symtab.c Thu Apr 03 06:50:07 2014 +0000 +++ b/ticoff/symtab.c Thu Apr 03 07:00:08 2014 +0000 @@ -164,10 +164,16 @@ compare_for_sort(p1, p2) struct internal_syment **p1, **p2; { + /* sort by value first */ if ((*p1)->value < (*p2)->value) return(-1); if ((*p1)->value > (*p2)->value) return(1); + /* if same value, retain the original symtab order */ + if ((*p1)->number < (*p2)->number) + return(-1); + if ((*p1)->number > (*p2)->number) + return(1); else return(0); } diff -r 2f23301d2f86 -r 5f4141ee175b ticoff/tables.c --- a/ticoff/tables.c Thu Apr 03 06:50:07 2014 +0000 +++ b/ticoff/tables.c Thu Apr 03 07:00:08 2014 +0000 @@ -98,6 +98,7 @@ exit(1); } symtab[n] = in; + in->number = n; in->name = get_secorsym_name(symtab_raw[n].e_name); in->value = get_u32(symtab_raw[n].e_value); in->scnum = get_s16(symtab_raw[n].e_scnum);