bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug ld/18452] ld allows overlapping sections


From: cristiangavril_olar at yahoo dot com
Subject: [Bug ld/18452] ld allows overlapping sections
Date: Tue, 29 Mar 2016 01:34:27 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=18452

--- Comment #10 from Cristian Gavril Olar <cristiangavril_olar at yahoo dot 
com> ---
(In reply to Cristian Gavril Olar from comment #9)
> I think these suggestions would be OK if the case would be that it is a
> general flag that is required to be detected, as per the very first patch
> submitted, but thinking more about things, I do not think that is true. The
> same application can have valid overlays and invalid ones, I cannot see any
> way around this other than allowing the user to specifically mark which ones
> are valid.

But that being said, if there would be a way to use the existing ld script
commands to infer somehow an intentional overlap of noload sections that can
clearly show intention and could not happen by mistake in any way, it would
also be my preference to reuse existing syntax/options completely it is just
that I keep thinking about this and I cannot see any way with just the existing
options and syntax.

As far as I've noticed:
- OVERLAY creates SEC_LOAD sections rather than just allocated (and it has too,
in order to perform the function it needs with creation of the extra symbols)
- NOLOAD sections will not increment the LMA: and that is just, because
otherwise it would start eating up load memory in potentially ROM code
(undesirable), so one cannot force increments on NOLOAD sections. I'm
mentioning this particular point because I was initially considering that a
possibility of handling this would be to use the current syntax and specify
something of this sort:
  /*Make sure on the data side of CMNlibs NOLOAD is used but addresses for data
sections are virtual*/
  .some.bss 0x1C000000 (NOLOAD) : AT (0xE0000000) { 
        *(S.bss*)
        *(.__BSS__sect*)
  }
  .other.bss 0x1C000000 (NOLOAD) : AT ( LOADADDR (.some.bss) + SIZEOF
(.some.bss) ) {      
        *(.other.S.bss*)
        *(.other.__BSS__sect*)
  }

In my initial opinion I thought this would be a good way to use the current
syntax to express intention of overlaps, and then just do LMA checks. But the
load address would not increment in this fashion. Initially I did not realize
why but reading this ticket and the links in it I realized it makes sense for
this to not work because NOLOAD sections cannot increment the LMA address, or
else, as the note in https://sourceware.org/ml/binutils/2009-05/msg00330.html
says: "Clearly we don't want an image of the bss section in ROM, and the .bss
section does not cause the advancement of the allocation point (the LMA)."

So it makes sense that LMA does not increase. But I think, at the same time,
this shows why with classic commands this problem of intentional vs accidental
use cannot be resolved without creating some sort of reinterpretation of the
commands which I think is not desirable.

But like I said: if it would help anyone, I'd be interested in trying to
provide patches/suggestions for a resolution to this problem of: detecting
accidental overlaps but allowing intentional ones with classic commands if
there is any way of doing that.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]