This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

VMA section overlap warnings for overlays


Hi,

I have an issue with overlays that seems to have come about as a result
of this patch (http://sourceware.org/ml/binutils/2008-05/msg00235.html):

---
2008-05-28  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* elf.c (assign_file_positions_for_load_sections): Adjust
pre-section
	gaps based on VMA and P_VADDR instead of LMA and P_PADDR
addresses.
---

Consider the following simplified code:

---
brsbs01 0>cat over.S
        .section SEC_NAME,"ax",@progbits
        nop
        
brsbs01 0>cat start.s
        .section        .text,"ax",@progbits
        .globl  _start
        .type   _start, @function
_start:
        nop

        .section        .imem,"ax",@progbits
        nop

brsbs01 0>cat ldscript.x 
OUTPUT_FORMAT("elf32-i386")
OUTPUT_ARCH(i386)

ENTRY(_start)

PHDRS
{
  mem PT_LOAD;
  imem PT_LOAD;
}

SECTIONS
{
  .text 0x1000:
  {
    *(.text)
  } :mem

  .imem 0x2000 : AT (LOADADDR (.text) + SIZEOF (.text))
  {
    *(.imem)
  } :imem

  .overlay1 ADDR (.imem) + SIZEOF (.imem) 
    : AT (LOADADDR (.imem) + SIZEOF (.imem))
  {
    *(.overlay.1)
  } :imem
       
  .overlay2 ADDR (.imem) + SIZEOF (.imem) 
    : AT (LOADADDR (.overlay1) + SIZEOF (.overlay1))
  {
    *(.overlay.2)
  } :imem

  .overlay3 ADDR (.imem) + SIZEOF (.imem) 
    : AT (LOADADDR (.overlay2) + SIZEOF (.overlay2))
  {
    *(.overlay.3)
  } :imem
}
---

Built with:

---
gcc over.S -DSEC_NAME=".overlay.1" -c -o over1.o
gcc over.S -DSEC_NAME=".overlay.2" -c -o over2.o
gcc over.S -DSEC_NAME=".overlay.3" -c -o over3.o
gcc start.s -c -o start.o
ld over1.o over2.o over3.o start.o -T ldscript.x -o test.exe 
---

Using an old version of GNU ld (2.17) I don't get any linker warnings,
and the executable looks as I'd expect.

When using the latest code from CVS, I get the following warnings when
linking:

---
brsbs01 0>ld-new over1.o over2.o over3.o start.o -T ldscript.x -o
test.exe
ld-new: test.exe: section .overlay2 vma 0x2001 overlaps previous
sections
ld-new: test.exe: section .overlay3 vma 0x2001 overlaps previous
sections
---

As it happens, the executable actually looks correct in this case, but
the warnings can't be a good thing. Also, I have a larger case where
we're getting these warnings and our overlays aren't working (whereas
they used to with an older linker) - I just haven't managed to reproduce
this problem in a smaller test yet...

Am I doing something wrong or unusual in my linker script, or does it
look like there's a problem in the linker?

Thanks for any advice,
Dave.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]