malloc always returns null

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

 



Hi,

I'm attempting to configure the gcc 4.0.3 tool chain to compile c++ source on an ARM 9 (ARM926-ejs) target. At this point, everything seems to be working except malloc: It always returns the null pointer.

I'm wondering if I've correctly configured my .ld script indicate the location and size of the heap. It was put together with a bit of guesswork & patching together examples for other targets, since it's not clear to me what symbols malloc() relies upon for locating the heap (is this documented somewhere?).

Below are the command lines i'm using for compile/assemble/link & the ld script. Do they look substantially complete?

Thanks,

-ted



Command lines:
================================================================

gcc.exe -c -gdwarf-2 -MD -O0 -mapcs-frame -trigraphs -mcpu=arm926ej-s -w -Wall -fsigned-char -xc++ -mlittle-endian -marm -mthumb-interwork -mtune=arm926ej-s -mlong-calls -o .\objects\mySourceFile.o mySourceFile.cpp as.exe -mcpu=arm9e -gdwarf2 -EL -mthumb-interwork .\objects\startup.o .\source\startup.s ld.exe -T.\Settings\my_ld_script.ld --cref -t -static -lstdc++ -lm -lc -lgcc -nostartfiles -Map=my_program.map -o .\objects\my_program.elf


ld script:
================================================================

MEMORY
{
  INTRAM(rwx) : ORIGIN = 0x00000004, LENGTH = 0x1FFFC /* this isn't used */
SDRAM(rwx) : ORIGIN = 0x80000000, LENGTH = 0x00800000 /* this is the memory i'm using */
}

SECTIONS
{
  .text :
  {
    __code_start__ = .;

    objects\startup.o (.text)         /* Startup code */
    objects\*.o       (.text)

    . = ALIGN(4);
    __code_end__ = .;

    *(.gnu.linkonce.t.*)
  	*(.glue_7)
  	*(.glue_7t)
  	*(.gcc_except_table)
  	*(.gnu.linkonce.r.*)

  } >SDRAM

  . = ALIGN(4);

  /* .rodata section which is used for read-only data (constants) */
  .rodata . :
  {
    *(.rodata)
  } >SDRAM

	.ctors :
	{
		PROVIDE(__ctors_start__ = .);
		KEEP(*(SORT(.ctors.*)))
		KEEP(*(.ctors))
		PROVIDE(__ctors_end__ = .);
	} >SDRAM

	.dtors :
	{
		PROVIDE(__dtors_start__ = .);
		KEEP(*(SORT(.dtors.*)))
		KEEP(*(.dtors))
		PROVIDE(__dtors_end__ = .);
	} >SDRAM

  _etext = . ;
  PROVIDE (etext = .);

  .data :
  {
    /* used for initialized data */
    __data_start__ = . ;
    PROVIDE (__data_start__ = .) ;
    *(.data)
   	*(.data.*)
	  *(.gnu.linkonce.d*)

    SORT(CONSTRUCTORS)
    __data_end__ = . ;
    PROVIDE (__data_end__ = .) ;
  } >SDRAM
  . = ALIGN(4);

  _edata = . ;
  PROVIDE (edata = .);

  .bss :
  {
    /* used for uninitialized data */

    __bss_start = . ;
    __bss_start__ = . ;
    *(.bss)
    *(.gnu.linkonce.b*)
    . = ALIGN(4);
    __bss_end__ = . ;

  } >SDRAM

  .bss2 :
  {
    /* used for uninitialized data */

    __bss2_start = . ;
    __bss2_start__ = . ;
    *(COMMON)
    . = ALIGN(4);
    __bss2_end__ = . ;

  } >SDRAM

  .stack ALIGN(256) :
  {
    . += 0x00100000;
    PROVIDE (_stack = .);
  } > SDRAM

  .heap :
  {
   PROVIDE (end = .);PROVIDE (__end__ = .);PROVIDE (_end = .);
   *(.heap)
   PROVIDE (heap_limit = . );
  } >SDRAM

  .comment       0 : { *(.comment) }
  /* DWARF debug sections.
     Symbols in the DWARF debugging sections are relative to the beginning
     of the section so we begin them at 0.  */
  /* DWARF 1 */
  .debug          0 : { *(.debug) }
  .line           0 : { *(.line) }
  /* GNU DWARF 1 extensions */
  .debug_srcinfo  0 : { *(.debug_srcinfo) }
  .debug_sfnames  0 : { *(.debug_sfnames) }
  /* DWARF 1.1 and DWARF 2 */
  .debug_aranges  0 : { *(.debug_aranges) }
  .debug_pubnames 0 : { *(.debug_pubnames) }
  /* DWARF 2 */
  .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }
  .debug_abbrev   0 : { *(.debug_abbrev) }
  .debug_line     0 : { *(.debug_line) }
  .debug_frame    0 : { *(.debug_frame) }
  .debug_str      0 : { *(.debug_str) }
  .debug_loc      0 : { *(.debug_loc) }
  .debug_macinfo  0 : { *(.debug_macinfo) }
}

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux