From: Alan Modra Date: Tue, 16 Mar 2004 10:29:12 +0000 (+0000) Subject: * elflink.c (elf_link_read_relocs_from_section): Don't use X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=51992aec7a025a2cb45ee604eaf0fdf7211ea75c;p=binutils-gdb.git * elflink.c (elf_link_read_relocs_from_section): Don't use NUM_SHDR_ENTRIES in end of reloc calc. Move NULL shdr check.. (_bfd_elf_link_read_relocs): ..to here. * elf32-ppc.c (ppc_elf_relax_section): Formatting. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 95135726df0..ea5189c9195 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,10 @@ +2004-03-16 Alan Modra + + * elflink.c (elf_link_read_relocs_from_section): Don't use + NUM_SHDR_ENTRIES in end of reloc calc. Move NULL shdr check.. + (_bfd_elf_link_read_relocs): ..to here. + * elf32-ppc.c (ppc_elf_relax_section): Formatting. + 2004-03-16 Alan Modra * configure.in (HOST_64BIT_TYPE, HOST_U_64BIT_TYPE): Don't override diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c index 8bd7115bf90..813d1491742 100644 --- a/bfd/elf32-ppc.c +++ b/bfd/elf32-ppc.c @@ -1816,10 +1816,7 @@ ppc_elf_relax_section (bfd *abfd, symaddr = tsec->output_section->vma + tsec->output_offset + toff; roff = irel->r_offset; - - reladdr = (isec->output_section->vma - + isec->output_offset - + roff); + reladdr = isec->output_section->vma + isec->output_offset + roff; /* If the branch is in range, no need to do anything. */ if (symaddr - reladdr + max_branch_offset < 2 * max_branch_offset) diff --git a/bfd/elflink.c b/bfd/elflink.c index 50513648db6..7d63383be02 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -1880,10 +1880,6 @@ elf_link_read_relocs_from_section (bfd *abfd, Elf_Internal_Shdr *symtab_hdr; size_t nsyms; - /* If there aren't any relocations, that's OK. */ - if (!shdr) - return TRUE; - /* Position ourselves at the start of the section. */ if (bfd_seek (abfd, shdr->sh_offset, SEEK_SET) != 0) return FALSE; @@ -1909,7 +1905,7 @@ elf_link_read_relocs_from_section (bfd *abfd, } erela = external_relocs; - erelaend = erela + NUM_SHDR_ENTRIES (shdr) * shdr->sh_entsize; + erelaend = erela + shdr->sh_size; irela = internal_relocs; while (erela < erelaend) { @@ -1995,12 +1991,13 @@ _bfd_elf_link_read_relocs (bfd *abfd, external_relocs, internal_relocs)) goto error_return; - if (!elf_link_read_relocs_from_section - (abfd, o, - elf_section_data (o)->rel_hdr2, - ((bfd_byte *) external_relocs) + rel_hdr->sh_size, - internal_relocs + (NUM_SHDR_ENTRIES (rel_hdr) - * bed->s->int_rels_per_ext_rel))) + if (elf_section_data (o)->rel_hdr2 + && (!elf_link_read_relocs_from_section + (abfd, o, + elf_section_data (o)->rel_hdr2, + ((bfd_byte *) external_relocs) + rel_hdr->sh_size, + internal_relocs + (NUM_SHDR_ENTRIES (rel_hdr) + * bed->s->int_rels_per_ext_rel)))) goto error_return; /* Cache the results for next time, if we can. */