mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-11-27 20:14:06 +08:00
Replace sh_size/sh_entsize with NUM_SHDR_ENTRIES
This commit is contained in:
parent
60edd2d3f1
commit
d9bc7a4499
@ -1,3 +1,19 @@
|
||||
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.
|
||||
|
@ -296,7 +296,7 @@ The target vector starts with a set of constants.
|
||||
@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
|
||||
|
@ -27,6 +27,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
#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
|
||||
|
@ -1449,7 +1449,7 @@ bfd_section_from_shdr (abfd, shindex)
|
||||
}
|
||||
*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;
|
||||
|
@ -501,7 +501,7 @@ elf_i386_check_relocs (abfd, info, sec, relocs)
|
||||
|
||||
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"),
|
||||
|
@ -3071,7 +3071,7 @@ _bfd_mips_elf_fake_sections (abfd, hdr, sec)
|
||||
|
||||
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;
|
||||
@ -6822,8 +6822,7 @@ _bfd_mips_elf_relocate_section (output_bfd, info, input_bfd, input_section,
|
||||
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))
|
||||
{
|
||||
@ -7592,7 +7591,7 @@ _bfd_mips_elf_check_relocs (abfd, info, sec, relocs)
|
||||
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,
|
||||
@ -7707,7 +7706,7 @@ _bfd_mips_elf_check_relocs (abfd, info, sec, relocs)
|
||||
|
||||
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);
|
||||
|
@ -2831,7 +2831,7 @@ elf64_alpha_can_merge_gots (a, b)
|
||||
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;
|
||||
@ -2903,7 +2903,7 @@ elf64_alpha_merge_gots (a, b)
|
||||
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;
|
||||
|
@ -396,7 +396,7 @@ sparc64_elf_slurp_reloc_table (abfd, asect, symbols, dynamic)
|
||||
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;
|
||||
}
|
||||
|
||||
@ -996,8 +996,7 @@ sparc64_elf_check_relocs (abfd, info, sec, relocs)
|
||||
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;
|
||||
@ -1903,8 +1902,7 @@ sparc64_elf_relocate_section (output_bfd, info, input_bfd, input_section,
|
||||
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;
|
||||
|
@ -1373,11 +1373,9 @@ elf_slurp_reloc_table (abfd, asect, symbols, dynamic)
|
||||
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
|
||||
@ -1394,7 +1392,7 @@ elf_slurp_reloc_table (abfd, asect, symbols, dynamic)
|
||||
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;
|
||||
}
|
||||
|
@ -2465,7 +2465,7 @@ elf_link_read_relocs_from_section (abfd, shdr, external_relocs,
|
||||
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)));
|
||||
@ -2495,7 +2495,7 @@ elf_link_read_relocs_from_section (abfd, shdr, external_relocs,
|
||||
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)
|
||||
{
|
||||
@ -2575,7 +2575,7 @@ NAME(_bfd_elf,link_read_relocs) (abfd, o, external_relocs, internal_relocs,
|
||||
(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;
|
||||
|
||||
@ -4413,11 +4413,9 @@ elf_bfd_final_link (abfd, info)
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -5442,7 +5440,7 @@ elf_link_output_relocs (output_bfd, input_section, input_rel_hdr,
|
||||
|
||||
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;
|
||||
@ -5477,7 +5475,7 @@ elf_link_output_relocs (output_bfd, input_section, input_rel_hdr,
|
||||
|
||||
/* 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
|
||||
@ -5939,8 +5937,7 @@ elf_link_input_bfd (finfo, input_bfd)
|
||||
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,
|
||||
|
Loading…
Reference in New Issue
Block a user