This is the mail archive of the binutils@sourceware.cygnus.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: sorting dynamic relocation entries.


   Date: Sun, 12 Mar 2000 20:33:14 -0700
   From: Koundinya K <knk@dde.dk>

       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);

reldyn->contents is not an array of pointers to Elf32_External_Rel
reldyn->structure.  It is an array of Elf32_External_Rel structures.
However, this only affects the cast, so it shouldn't matter.

   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;

Here, though, it does matter.  qsort is going to pass a pointer to an
Elf32_External_Rel.  It is not going to pass a pointer to a pointer to
an Elf32_External_Rel.

     bfd_vma rel1_rinfo = (unsigned long) rel1[1];
     bfd_vma rel2_rinfo = (unsigned long) rel2[1];

That's just odd.  I don't know what this code is supposed to do.

   I tested and found that right symbol indices were being returned in the
   comparison function.

Step through the comparison function and look at the values that it
using.  Do those values occur in the dynamic relocation table?  Or is
it just using garbage values?

Ian

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]