This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
[patch] Replace the use of FILE_ALIGN in gc routines
- To: binutils at sourceware dot cygnus dot com
- Subject: [patch] Replace the use of FILE_ALIGN in gc routines
- From: Catherine Moore <clm at redhat dot com>
- Date: Fri, 08 Jun 2001 13:22:02 -0700
- Cc: clm at redhat dot com
I have a port which needs to override some of the defaults from
elf_size_info. Several of the linker gc routines use the macro
FILE_ALIGN instead of the corresponding elf backend entry.
This patch corrects this shortcut. Okay to install?
Thanks,
Catherine
2001-06-08 Catherine Moore <clm@redhat.com>
* elflink.h (elf_gc_propagate_vtable_entries): Replace FILE_ALIGN
with the file_align entry from elf_backend_data.
(elf_gc_smash_unused_vtentry_relocs): Likewise.
(elf_gc_record_vtentry): Likewise.
Index: elflink.h
===================================================================
RCS file: /cvs/src/src/bfd/elflink.h,v
retrieving revision 1.93
diff -p -r1.93 elflink.h
*** elflink.h 2001/05/28 11:57:54 1.93
--- elflink.h 2001/06/08 20:10:06
*************** elf_gc_propagate_vtable_entries_used (h,
*** 6739,6751 ****
size_t n;
boolean *cu, *pu;
/* Or the parent's entries into ours. */
cu = h->vtable_entries_used;
cu[-1] = true;
pu = h->vtable_parent->vtable_entries_used;
if (pu != NULL)
{
! n = h->vtable_parent->vtable_entries_size / FILE_ALIGN;
while (--n != 0)
{
if (*pu) *cu = true;
--- 6739,6755 ----
size_t n;
boolean *cu, *pu;
+ asection *sec = h->root.u.def.section;
+ struct elf_backend_data *bed = get_elf_backend_data (sec->owner);
+ int file_align = bed->s->file_align;
+
/* Or the parent's entries into ours. */
cu = h->vtable_entries_used;
cu[-1] = true;
pu = h->vtable_parent->vtable_entries_used;
if (pu != NULL)
{
! n = h->vtable_parent->vtable_entries_size / file_align;
while (--n != 0)
{
if (*pu) *cu = true;
*************** elf_gc_smash_unused_vtentry_relocs (h, o
*** 6766,6771 ****
--- 6770,6776 ----
bfd_vma hstart, hend;
Elf_Internal_Rela *relstart, *relend, *rel;
struct elf_backend_data *bed;
+ int file_align;
/* Take care of both those symbols that do not describe vtables as
well as those that are not loaded. */
*************** elf_gc_smash_unused_vtentry_relocs (h, o
*** 6784,6789 ****
--- 6789,6796 ----
if (!relstart)
return *(boolean *)okp = false;
bed = get_elf_backend_data (sec->owner);
+ file_align = bed->s->file_align;
+
relend = relstart + sec->reloc_count * bed->s->int_rels_per_ext_rel;
for (rel = relstart; rel < relend; ++rel)
*************** elf_gc_smash_unused_vtentry_relocs (h, o
*** 6793,6799 ****
if (h->vtable_entries_used
&& (rel->r_offset - hstart) < h->vtable_entries_size)
{
! bfd_vma entry = (rel->r_offset - hstart) / FILE_ALIGN;
if (h->vtable_entries_used[entry])
continue;
}
--- 6800,6806 ----
if (h->vtable_entries_used
&& (rel->r_offset - hstart) < h->vtable_entries_size)
{
! bfd_vma entry = (rel->r_offset - hstart) / file_align;
if (h->vtable_entries_used[entry])
continue;
}
*************** elf_gc_record_vtentry (abfd, sec, h, add
*** 6927,6932 ****
--- 6934,6942 ----
struct elf_link_hash_entry *h;
bfd_vma addend;
{
+ struct elf_backend_data *bed = get_elf_backend_data (abfd);
+ int file_align = bed->s->file_align;
+
if (addend >= h->vtable_entries_size)
{
size_t size, bytes;
*************** elf_gc_record_vtentry (abfd, sec, h, add
*** 6949,6955 ****
/* Allocate one extra entry for use as a "done" flag for the
consolidation pass. */
! bytes = (size / FILE_ALIGN + 1) * sizeof (boolean);
if (ptr)
{
--- 6959,6965 ----
/* Allocate one extra entry for use as a "done" flag for the
consolidation pass. */
! bytes = (size / file_align + 1) * sizeof (boolean);
if (ptr)
{
*************** elf_gc_record_vtentry (abfd, sec, h, add
*** 6959,6965 ****
{
size_t oldbytes;
! oldbytes = (h->vtable_entries_size/FILE_ALIGN + 1) * sizeof (boolean);
memset (((char *)ptr) + oldbytes, 0, bytes - oldbytes);
}
}
--- 6969,6975 ----
{
size_t oldbytes;
! oldbytes = (h->vtable_entries_size/file_align + 1) * sizeof (boolean);
memset (((char *)ptr) + oldbytes, 0, bytes - oldbytes);
}
}
*************** elf_gc_record_vtentry (abfd, sec, h, add
*** 6974,6980 ****
h->vtable_entries_size = size;
}
! h->vtable_entries_used[addend / FILE_ALIGN] = true;
return true;
}
--- 6984,6990 ----
h->vtable_entries_size = size;
}
! h->vtable_entries_used[addend / file_align] = true;
return true;
}