GDB problem with 'section' attribute var

fanlex wrote on Monday, December 08, 2008:


I need, for a simple application, in which I want to run a portion of code out of RAM at startup, to use a ram segment which is not yet used at that time.

For that purpose, I give a variable which will be used later in the firmware as heap (FreeRTOS with lwip) the ‘section’ attribute :
__attribute__ ((section (".ramheap"))) char ramheap[size];

However, as soon as size is arround 64, GDB does not work properly any more.
‘No source available for "start() "’
(start is the first instruction of boot.s, the entry point in assembler module, and startup breakpoint)
If I set size to 4, it works !
If I set the startup breakpoint at ‘main’, it works too.
However, if I add a program section that overlays on ramheap section (‘ram >flash’ in link script) , GDB does not show the source lines of that code, while it does if the program section is located at an address other than ramheap or bss (can be after bss or between ramheap and bss) (this is a second problem).

In another larger application, I’ve go the message
Dwarf Error: wrong version in compilation unit header (is 0, should be 2) [in module xxxx.elf]
and sometimes, with only an 8 byte variable with the attribute ‘section’ is enough to make GDB crash.

GDB version 6.8.50.
GCC 4.2.2. (option -gdwarf-2)
Eclipse 3.4

I can send a zip file with all the sources if necessary… it just a simple demo program, easy to reproduce…

thanks in advance for any tip.

rtel wrote on Monday, December 08, 2008:

I don’t think I followed all that, but it sounds like this is not directly related in any case, more a linker script issue.

Is it possible that you don’t have the RAM free for this section?  Maybe the heap is sized to take up the entire RAM?  Just a guess.


fanlex wrote on Monday, December 08, 2008:

Hi richard,

no it’s not a FreeRTOS related problem, but I was wondering whether a FreeRTOS user had encountered the same problem, since my problems are within my FreeRTOS + lwip application.

Even if FreeRTOS or lwip takes up all the ram, if I assign a ‘section’ attribute to that ram segment, the linker places it near the bss segment (as described in the linker script), and normaly all is working well.

But depending on that segment size, there are different behaviors, either GDB crashes, or it cannot set the initial breakpoint on ‘start’, the assembler entry point.

I think that something is wrong between GCC and GDB. for instance, when I declare a ram segment with the ‘section’ attribute and a size larger than 577 bytes, the readelf command with -wi argument gives the following messages :

readelf: Warning: Only version 2 and 3 DWARF debug information is currently supported.
readelf: Warning: Debug info is corrupted, length is invalid (section is 4302 bytes)

with size from 1 to 577 it seems to be OK.
and sometimes when a small program segment is declared with a section attribute too , these warnings do not appear…
I’m wondering what is wrong in the .elf  file ? And I don’t want to get inside.