This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[patch] bfd/elf.c: fix section overlap warning again
- From: DJ Delorie <dj at redhat dot com>
- To: binutils at sourceware dot org
- Date: Thu, 8 Jul 2010 20:18:51 -0400
- Subject: [patch] bfd/elf.c: fix section overlap warning again
Yet another attempt to get this logic right, it seems. The "new"
logic didn't handle the case where the previous section overflowed the
address space. This adds a check specifically for that case. Since
this is the third time someone's tried to get this right, I'll wait
until someone reviews it before committing it :-)
* elf.c (assign_file_positions_for_load_sections): Check for
sections which overflow the address space.
Index: elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.511
diff -p -U3 -r1.511 elf.c
--- elf.c 18 May 2010 03:31:05 -0000 1.511
+++ elf.c 9 Jul 2010 00:10:36 -0000
@@ -4457,9 +4457,16 @@ assign_file_positions_for_load_sections
&& ((this_hdr->sh_flags & SHF_TLS) == 0
|| p->p_type == PT_TLS))))
{
- bfd_vma adjust = sec->lma - (p->p_paddr + p->p_memsz);
-
- if (sec->lma < p->p_paddr + p->p_memsz)
+ /* This is the end VMA for the previous segment. */
+ bfd_vma p_end = p->p_paddr + p->p_memsz;
+ /* This is the gap between segments. */
+ bfd_vma adjust = sec->lma - p_end;
+
+ /* The first comparison checks for the usual case. The
+ second checks for segments which overflow the address
+ space. */
+ if (sec->lma < p->p_paddr + p->p_memsz
+ || (p_end < p->p_paddr && p->p_paddr < sec->lma))
{
(*_bfd_error_handler)
(_("%B: section %A lma 0x%lx overlaps previous sections"),