This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
bfd/elf.c: more wrap/overlap/overflow weirdness
- From: DJ Delorie <dj at redhat dot com>
- To: binutils at sourceware dot org
- Date: Fri, 20 Aug 2010 15:45:45 -0400
- Subject: bfd/elf.c: more wrap/overlap/overflow weirdness
If .data wraps around 0xffffffff, the next section appended to it
triggers the "p_end < p_start" test, but the LMA does *not* change,
making the warning message useless. There's also no warning for the
wrapped section.
This patch checks for the two cases separately - a warning if a
section's load data wraps, and an extra test to see if the LMA
actually changes.
Does it even make sense to warn about section wrapping? On most small
MCUs, wrapping is OK, the mcu just keeps going at address zero; and if
you use a MEMORY directive, you already get the "memory region full"
message.
Index: elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.515
diff -p -U3 -r1.515 elf.c
--- elf.c 18 Aug 2010 12:24:05 -0000 1.515
+++ elf.c 20 Aug 2010 19:38:36 -0000
@@ -4467,14 +4467,23 @@ assign_file_positions_for_load_sections
bfd_vma p_start = p->p_paddr;
bfd_vma p_end = p_start + p->p_memsz;
bfd_vma s_start = sec->lma;
+ bfd_vma s_end = sec->lma + sec->size;
bfd_vma adjust = s_start - p_end;
+ if (s_end < s_start)
+ {
+ (*_bfd_error_handler)
+ (_("%B: warning: section %A lma wraps from %#lx to %#lx"), abfd, sec,
+ (unsigned long) s_start, (unsigned long) s_end);
+ }
+
if (s_start < p_end
|| p_end < p_start)
{
- (*_bfd_error_handler)
- (_("%B: section %A lma %#lx adjusted to %#lx"), abfd, sec,
- (unsigned long) s_start, (unsigned long) p_end);
+ if (sec->lma != p_end)
+ (*_bfd_error_handler)
+ (_("%B: section %A lma %#lx adjusted to %#lx"), abfd, sec,
+ (unsigned long) s_start, (unsigned long) p_end);
adjust = 0;
sec->lma = p_end;
}
.text
.space 0x3558
.data
.space 0x08e3
.bss
.space 0x4000
.section ".rodata", "a"
.space 0x48dc
OUTPUT_ARCH(rx)
SECTIONS
{
.text 0xFFFF8000 : AT (0xFFFF8000)
{
*(.text*)
*(P*)
}
.rodata :
{
*(.rodata*)
*(C*)
_mdata = .;
}
.data 0x00001001 : AT (_mdata)
{
*(.data*)
*(D*)
}
.bss :
{
*(.bss*)
*(COMMON)
*(B*)
}
}