public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: "David Stubbs" <stubbs@IceraSemi.com>
To: "Alan Modra" <amodra@gmail.com>
Cc: <binutils@sourceware.org>
Subject: RE: VMA section overlap warnings for overlays
Date: Wed, 21 Apr 2010 14:44:00 -0000	[thread overview]
Message-ID: <4D60B0700D1DB54A8C0C6E9BE69163700E7815C7@EXCHANGEVS.IceraSemi.local> (raw)
In-Reply-To: <20100421082441.GG3510@bubble.grove.modra.org>

> > Am I doing something wrong or unusual in my linker script, or
> does it
> > look like there's a problem in the linker?
> 
> Your script is fine.  I'm looking at reverting Jan's patch.

On a related note, I've noticed that a slightly 'enhanced' version of
the linker script ends up with incorrect LMAs being used. Here's the
script:

---
UTPUT_FORMAT("elf32-i386")
OUTPUT_ARCH(i386)

ENTRY(_start)

PHDRS
{
  mem PT_LOAD;
  info PT_LOAD;
  imem PT_LOAD;
}

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

  .overlays 0x9000:
  {
    LONG (LOADADDR (.overlay1))
    LONG (LOADADDR (.overlay2))
    LONG (LOADADDR (.overlay3))
  } :info

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

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

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

The .overlays section reports the load addresses as:

---
Hex dump of section '.overlays':
  0x00009000          00001004 00001003 00001002 ............
---

Whereas the section headers report:

---
Idx Name          Size      VMA       LMA       File off  Algn
  1 .overlay1     00000001  00004000  00003001  00005000  2**0
  4 .overlay2     00000001  00004000  00003002  00005001  2**0
  5 .overlay3     00000001  00004000  00003003  00005002  2**0
---

So the LMAs in the .overlays section do not match the LMAs in the
section headers. And for completeness, the program headers looks like:

---
Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg
Align
  LOAD           0x001000 0x00001000 0x00001000 0x00001 0x00001 R E
0x1000
  LOAD           0x002000 0x00009000 0x00009000 0x0000c 0x0000c RW
0x1000
  LOAD           0x003000 0x00002000 0x00001001 0x02003 0x02003 R E
0x1000

 Section to Segment mapping:
  Segment Sections...
   00     .text 
   01     .overlays 
   02     .overlay1 .imem .overlay2 .overlay3
---

I think it's the contents of the .overlays section that is actually
incorrect in this case. 

I don't think reverting that patch alone fixes it though. In fact, from
a very quick test I get this error:

---
/home/stubbs/local_disc/work/gnu_live_sources/binutils/build/ld/ld-new:
test.exe: section `.overlay1' can't be allocated in segment 2
LOAD: .imem .overlay1 .overlay2 .overlay3
---

Which definitely doesn't look correct to me. There must be some other
associated change that I've not yet found...

I was planning on taking another look into this, but would obviously
appreciate any help you can provide!

Thanks again,
Dave.

  reply	other threads:[~2010-04-21 14:44 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-16 13:29 David Stubbs
2010-04-21  8:25 ` Alan Modra
2010-04-21 14:44   ` David Stubbs [this message]
2010-04-22  1:11     ` Alan Modra
2010-04-22  1:53       ` Alan Modra
2010-04-22 12:39         ` David Stubbs
2010-04-24  2:18           ` Alan Modra
2010-05-07 16:14             ` David Stubbs
2010-05-08 11:49               ` Alan Modra
2010-05-12 13:19                 ` David Stubbs
2010-05-13  3:37                   ` Alan Modra
2010-07-15  8:11             ` Andreas Schwab
2010-07-15 13:10               ` Alan Modra
2010-07-15 13:46                 ` Andreas Schwab
2010-07-15 13:53                   ` H.J. Lu
2010-07-15 14:12                     ` Andreas Schwab
2010-07-15 14:17                       ` H.J. Lu
2010-07-15 14:18                     ` Alan Modra
2010-07-15 14:26                       ` H.J. Lu
2010-07-15 14:36                         ` Andreas Schwab
2010-07-15 19:09                           ` H.J. Lu
2010-07-16  7:39                             ` Andreas Schwab
2010-07-16 10:04                               ` Alan Modra
2010-07-19 12:43                                 ` Andreas Schwab
2010-07-20  5:45                                   ` Alan Modra
2010-07-20 14:11                                     ` Alan Modra
2011-02-24 23:49                                       ` H.J. Lu
2011-02-25  7:49                                         ` Alan Modra
2011-02-25 10:17                                           ` Andreas Schwab
2011-02-25 12:30                                           ` H.J. Lu
2011-02-25 15:55                                           ` H.J. Lu
2011-02-25 16:23                                             ` Andreas Schwab
2011-02-25 16:34                                               ` H.J. Lu
2010-08-28  1:02         ` H.J. Lu
2010-08-28 11:00           ` Alan Modra
2010-08-28 13:39             ` Alan Modra
2010-08-28 17:25               ` H.J. Lu
2010-08-30  4:46                 ` Alan Modra
2010-08-30  5:11                   ` H.J. Lu
2010-08-30  6:30                     ` Alan Modra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4D60B0700D1DB54A8C0C6E9BE69163700E7815C7@EXCHANGEVS.IceraSemi.local \
    --to=stubbs@icerasemi.com \
    --cc=amodra@gmail.com \
    --cc=binutils@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).