This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Minor elflink.c tweak
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: binutils at sources dot redhat dot com
- Date: Tue, 16 Mar 2004 20:58:33 +1030
- Subject: Minor elflink.c tweak
Flushing a couple of little tweaks I've had in my local tree for
some time.
* 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.
Index: bfd/elflink.c
===================================================================
RCS file: /cvs/src/src/bfd/elflink.c,v
retrieving revision 1.54
diff -u -p -r1.54 elflink.c
--- bfd/elflink.c 3 Mar 2004 21:31:10 -0000 1.54
+++ bfd/elflink.c 16 Mar 2004 05:17:49 -0000
@@ -1880,10 +1880,6 @@ elf_link_read_relocs_from_section (bfd *
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 *
}
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. */
Index: bfd/elf32-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-ppc.c,v
retrieving revision 1.111
diff -u -p -r1.111 elf32-ppc.c
--- bfd/elf32-ppc.c 20 Feb 2004 17:36:36 -0000 1.111
+++ bfd/elf32-ppc.c 16 Mar 2004 05:17:47 -0000
@@ -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)
--
Alan Modra
IBM OzLabs - Linux Technology Centre