* [PATCH] Fix -z combreloc
@ 2001-08-24 4:26 Jakub Jelinek
0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2001-08-24 4:26 UTC (permalink / raw)
To: binutils
Hi!
I've just commited the following patch before more people start using -z
combreloc.
RELATIVE records counted in DT_REL{,A}COUNT should be sorted first, not last
(that makes much more sense), ie. ld.so can count that relocs from
DT_REL{,A} up to DT_REL{,A} + (DT_REL{,A}COUNT - 1) * DT_REL{,A}ENT
inclusive are RELATIVE relocs.
I was confused by seeing Solaris 8 /usr/lib/libc.so.1 with DT_RELACOUNT set
and RELATIVE records sorted last, but it seems /usr/lib/sparcv9/libc.so.1
got it already right and for newly created libraries using Sun ld with -z
combreloc RELATIVE records come first even on sparc32.
If you disagree, I can back this patch out, but I wanted to avoid too many
libs with bad DT_REL*COUNT hanging out there.
2001-08-24 Jakub Jelinek <jakub@redhat.com>
* elflink.h (elf_link_sort_cmp1): Sort RELATIVE relocs first, not
last.
(elf_link_sort_relocs): Adjust accordingly.
--- bfd/elflink.h.jj Thu Aug 23 17:30:38 2001
+++ bfd/elflink.h Fri Aug 24 13:01:20 2001
@@ -4300,9 +4300,9 @@ elf_link_sort_cmp1 (A, B)
relativeb = b->type == reloc_class_relative;
if (relativea < relativeb)
- return -1;
- if (relativea > relativeb)
return 1;
+ if (relativea > relativeb)
+ return -1;
if (ELF_R_SYM (a->u.rel.r_info) < ELF_R_SYM (b->u.rel.r_info))
return -1;
if (ELF_R_SYM (a->u.rel.r_info) > ELF_R_SYM (b->u.rel.r_info))
@@ -4429,14 +4429,15 @@ elf_link_sort_relocs (abfd, info, psec)
}
qsort (rela, count, sizeof (*rela), elf_link_sort_cmp1);
- for (i = 0, j = 0; i < count && rela[i].type != reloc_class_relative; i++)
+ for (ret = 0; ret < count && rela[ret].type == reloc_class_relative; ret++)
+ ;
+ for (i = ret, j = ret; i < count; i++)
{
if (ELF_R_SYM (rela[i].u.rel.r_info) != ELF_R_SYM (rela[j].u.rel.r_info))
j = i;
rela[i].offset = rela[j].u.rel.r_offset;
}
- ret = count - i;
- qsort (rela, i, sizeof (*rela), elf_link_sort_cmp2);
+ qsort (rela + ret, count - ret, sizeof (*rela), elf_link_sort_cmp2);
for (o = dynobj->sections; o != NULL; o = o->next)
if ((o->flags & (SEC_HAS_CONTENTS|SEC_LINKER_CREATED))
Jakub
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2001-08-24 4:26 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-08-24 4:26 [PATCH] Fix -z combreloc Jakub Jelinek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).