+2001-05-23 Nick Clifton <nickc@cambridge.redhat.com>
+
+ * elf-bfd.h (NUM_SHDR_ENTRIES): New macro: compute the number
+ of entries in a structured section.
+ * elf.c: Use new macro.
+ * elf32-i386.c: Use new macro.
+ * elf32-mips.c: Use new macro.
+ * elf64-alpha.c: Use new macro.
+ * elf64-sparc.c: Use new macro.
+ * elfcode.h: Use new macro.
+ * elflink.h: Use new macro.
+
+2001-05-23 Nick Clifton <nickc@cambridge.redhat.com>
+
+ * bfdint.texi: Replace -oformat with --oformat.
+
2001-05-21 Andreas Jaeger <aj@suse.de>
* dwarf2.c (decode_line_info): Fix error message.
@item name
The name of the target vector. This is an arbitrary string. This is
how the target vector is named in command line options for tools which
-use BFD, such as the @samp{-oformat} linker option.
+use BFD, such as the @samp{--oformat} linker option.
@item flavour
A general description of the type of target. The following flavours are
#include "elf/external.h"
#include "bfdlink.h"
+/* The number of entries in a section is its size divided by the size
+ of a single entry. This is normally only applicaable to reloc and
+ symbol table sections. */
+#define NUM_SHDR_ENTRIES(shdr) ((shdr)->sh_size / (shdr)->sh_entsize)
+
/* If size isn't specified as 64 or 32, NAME macro should fail. */
#ifndef NAME
#if ARCH_SIZE==64
}
*hdr2 = *hdr;
elf_elfsections (abfd)[shindex] = hdr2;
- target_sect->reloc_count += hdr->sh_size / hdr->sh_entsize;
+ target_sect->reloc_count += NUM_SHDR_ENTRIES (hdr);
target_sect->flags |= SEC_RELOC;
target_sect->relocation = NULL;
target_sect->rel_filepos = hdr->sh_offset;
r_symndx = ELF32_R_SYM (rel->r_info);
- if (r_symndx >= symtab_hdr->sh_size / symtab_hdr->sh_entsize)
+ if (r_symndx >= NUM_SHDR_ENTRIES (symtab_hdr))
{
if (abfd->my_archive)
(*_bfd_error_handler) (_("%s(%s): bad symbol index: %d"),
boolean
_bfd_mips_elf_section_from_bfd_section (abfd, hdr, sec, retval)
- bfd *abfd;
+ bfd *abfd ATTRIBUTE_UNUSED;
Elf_Internal_Shdr *hdr ATTRIBUTE_UNUSED;
asection *sec;
int *retval;
REL_HDR is read before its REL_HDR2. */
rel_hdr = &elf_section_data (input_section)->rel_hdr;
if ((size_t) (rel - relocs)
- >= (rel_hdr->sh_size / rel_hdr->sh_entsize
- * bed->s->int_rels_per_ext_rel))
+ >= (NUM_SHDR_ENTRIES (rel_hdr) * bed->s->int_rels_per_ext_rel))
rel_hdr = elf_section_data (input_section)->rel_hdr2;
if (rel_hdr->sh_entsize == MIPS_ELF_REL_SIZE (input_bfd))
{
asection **n;
if (elf_bad_symtab (abfd))
- symcount = symtab_hdr->sh_size / symtab_hdr->sh_entsize;
+ symcount = NUM_SHDR_ENTRIES (symtab_hdr);
else
symcount = symtab_hdr->sh_info;
n = (asection **) bfd_zalloc (abfd,
if (r_symndx < extsymoff)
h = NULL;
- else if (r_symndx >= extsymoff + (symtab_hdr->sh_size / symtab_hdr->sh_entsize))
+ else if (r_symndx >= extsymoff + NUM_SHDR_ENTRIES (symtab_hdr))
{
(*_bfd_error_handler)
(_("Malformed reloc detected for section %s"), name);
Elf_Internal_Shdr *symtab_hdr = &elf_tdata (bsub)->symtab_hdr;
int i, n;
- n = symtab_hdr->sh_size / symtab_hdr->sh_entsize - symtab_hdr->sh_info;
+ n = NUM_SHDR_ENTRIES (symtab_hdr) - symtab_hdr->sh_info;
for (i = 0; i < n; ++i)
{
struct alpha_elf_got_entry *ae, *be;
hashes = alpha_elf_sym_hashes (bsub);
symtab_hdr = &elf_tdata (bsub)->symtab_hdr;
- n = symtab_hdr->sh_size / symtab_hdr->sh_entsize - symtab_hdr->sh_info;
+ n = NUM_SHDR_ENTRIES (symtab_hdr) - symtab_hdr->sh_info;
for (i = 0; i < n; ++i)
{
struct alpha_elf_got_entry *ae, *be, **pbe, **start;
return true;
rel_hdr = &d->this_hdr;
- asect->reloc_count = rel_hdr->sh_size / rel_hdr->sh_entsize;
+ asect->reloc_count = NUM_SHDR_ENTRIES (rel_hdr);
rel_hdr2 = NULL;
}
srelgot = NULL;
sreloc = NULL;
- rel_end = relocs + elf_section_data (sec)->rel_hdr.sh_size
- / elf_section_data (sec)->rel_hdr.sh_entsize;
+ rel_end = relocs + NUM_SHDR_ENTRIES (& elf_section_data (sec)->rel_hdr);
for (rel = relocs; rel < rel_end; rel++)
{
unsigned long r_symndx;
sgot = splt = sreloc = NULL;
rel = relocs;
- relend = relocs + elf_section_data (input_section)->rel_hdr.sh_size
- / elf_section_data (input_section)->rel_hdr.sh_entsize;
+ relend = relocs + NUM_SHDR_ENTIRES (& elf_section_data (input_section)->rel_hdr);
for (; rel < relend; rel++)
{
int r_type;
return true;
rel_hdr = &d->rel_hdr;
- reloc_count = rel_hdr->sh_size / rel_hdr->sh_entsize;
+ reloc_count = NUM_SHDR_ENTRIES (rel_hdr);
rel_hdr2 = d->rel_hdr2;
- reloc_count2 = (rel_hdr2
- ? (rel_hdr2->sh_size / rel_hdr2->sh_entsize)
- : 0);
+ reloc_count2 = (rel_hdr2 ? NUM_SHDR_ENTRIES (rel_hdr2) : 0);
BFD_ASSERT (asect->reloc_count == reloc_count + reloc_count2);
BFD_ASSERT (asect->rel_filepos == rel_hdr->sh_offset
return true;
rel_hdr = &d->this_hdr;
- reloc_count = rel_hdr->sh_size / rel_hdr->sh_entsize;
+ reloc_count = NUM_SHDR_ENTRIES (rel_hdr);
rel_hdr2 = NULL;
reloc_count2 = 0;
}
Elf_Internal_Rel *irel;
erel = (Elf_External_Rel *) external_relocs;
- erelend = erel + shdr->sh_size / shdr->sh_entsize;
+ erelend = erel + NUM_SHDR_ENTRIES (shdr);
irela = internal_relocs;
irel = bfd_alloc (abfd, (bed->s->int_rels_per_ext_rel
* sizeof (Elf_Internal_Rel)));
BFD_ASSERT (shdr->sh_entsize == sizeof (Elf_External_Rela));
erela = (Elf_External_Rela *) external_relocs;
- erelaend = erela + shdr->sh_size / shdr->sh_entsize;
+ erelaend = erela + NUM_SHDR_ENTRIES (shdr);
irela = internal_relocs;
for (; erela < erelaend; erela++, irela += bed->s->int_rels_per_ext_rel)
{
(abfd,
elf_section_data (o)->rel_hdr2,
((bfd_byte *) external_relocs) + rel_hdr->sh_size,
- internal_relocs + (rel_hdr->sh_size / rel_hdr->sh_entsize
+ internal_relocs + (NUM_SHDR_ENTRIES (rel_hdr)
* bed->s->int_rels_per_ext_rel)))
goto error_return;
rel_count2 = &esdo->rel_count;
}
- *rel_count += (esdi->rel_hdr.sh_size
- / esdi->rel_hdr.sh_entsize);
+ *rel_count += NUM_SHDR_ENTRIES (& esdi->rel_hdr);
if (esdi->rel_hdr2)
- *rel_count2 += (esdi->rel_hdr2->sh_size
- / esdi->rel_hdr2->sh_entsize);
+ *rel_count2 += NUM_SHDR_ENTRIES (esdi->rel_hdr2);
}
}
bed = get_elf_backend_data (output_bfd);
irela = internal_relocs;
- irelaend = irela + input_rel_hdr->sh_size / input_rel_hdr->sh_entsize;
+ irelaend = irela + NUM_SHDR_ENTRIES (input_rel_hdr);
if (input_rel_hdr->sh_entsize == sizeof (Elf_External_Rel))
{
Elf_External_Rel *erel;
/* Bump the counter, so that we know where to add the next set of
relocations. */
- *rel_countp += input_rel_hdr->sh_size / input_rel_hdr->sh_entsize;
+ *rel_countp += NUM_SHDR_ENTRIES (input_rel_hdr);
}
/* Link an input file into the linker output file. This function
elf_link_output_relocs (output_bfd, o,
input_rel_hdr,
internal_relocs);
- internal_relocs
- += input_rel_hdr->sh_size / input_rel_hdr->sh_entsize;
+ internal_relocs += NUM_SHDR_ENTRIES (input_rel_hdr);
input_rel_hdr = elf_section_data (o)->rel_hdr2;
if (input_rel_hdr)
elf_link_output_relocs (output_bfd, o,