This is the mail archive of the
binutils@sourceware.cygnus.com
mailing list for the binutils project.
Re: sorting dynamic relocation entries.
- To: Ian Lance Taylor <ian at zembu dot com>
- Subject: Re: sorting dynamic relocation entries.
- From: Koundinya K <knk at dde dot dk>
- Date: Sun, 12 Mar 2000 20:33:14 -0700
- CC: binutils at sourceware dot cygnus dot com
- Organization: DDE
- References: <38C81979.1638CFB7@dde.dk> <20000310063024.6958.qmail@daffy.airs.com> <38CAD49C.6475912C@dde.dk> <20000311180056.1085.qmail@daffy.airs.com>
Hi,
I am doing this. What could possibly be wrong ??, when I expect it to work.
This is the call to qsort().
qsort((Elf32_External_Rel **)reldyn->contents,
reldyn->reloc_count, sizeof(Elf32_External_Rel),
sort_dynamic_relocations);
and here is the comparison function.
/* Sort the dynamic relocations based on the symbol index. This is called
via qsort() */
static int
sort_dynamic_relocations (arg1, arg2)
const void *arg1;
const void *arg2;
{
const Elf32_External_Rel **rel1 = (const Elf32_External_Rel**) arg1;
const Elf32_External_Rel **rel2 = (const Elf32_External_Rel**) arg2;
bfd_vma rel1_rinfo = (unsigned long) rel1[1];
bfd_vma rel2_rinfo = (unsigned long) rel2[1];
if (ELF32_R_SYM(rel1_rinfo) < ELF32_R_SYM(rel2_rinfo))
return -1;
else if (ELF32_R_SYM(rel1_rinfo) > ELF32_R_SYM(rel2_rinfo))
return 1;
else
return 0;
}
I tested and found that right symbol indices were being returned in the
comparison function. But still the dynamic relocations are not sorted ?. Where
could things be wrong ??. Is there is any generic elf code that is trying to
sort based on offset or something after _final_link() returns ?? Or is there
anything else that I am still failing to do ??
Please suggest.
Thanks a lot.
koundinya