Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
15 years ago

problem with code size"need help"

hello,

I have a problem with code size..

I am running an application to view a 24bit color picture on a 480x272 touch screen, I used a 8 Mbyte SDRAM on DE1 board cycloneII and a scatter gather DMA, the only memory in my system is the SDRAM.

so the reset vector is at 0x00 and the exception vector is at 0x20(and i tried others like 0x2000)

the problem is that when I include a small picture size like 100x50 pixels every thing is ok, but when I try to include a larger size like 200x100 or full picture 480x272 this message appears:

mallocr.c:2150: warning: unable to reach (null) (at 0x0023814c) from the global pointer (at 0x0022addc) because the offset (54128) is out of the allowed range, -32678 to 32767.

collect2: ld returned 1 exit status

make: *** error 1

what is the problem?

I have a 8 MByte sdram and the size 480x272 only needs 0.5MByte???

can you help me please??

15 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    That is the version of the Altera tools, not gcc :-)

    You might have gcc3 or gcc4.

    Both the gcc3 and gcc4 I've built from the sources on Altera's ftp site correctly put the array into .data.

    I don't think any of my patches affect it (one puts MORE stuff into .sdata).

    It is worth running objdump -h to see how big .data and .sdata are.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    That is the version of the Altera tools, not gcc :-)

    You might have gcc3 or gcc4.

    Both the gcc3 and gcc4 I've built from the sources on Altera's ftp site correctly put the array into .data.

    I don't think any of my patches affect it (one puts MORE stuff into .sdata).

    It is worth running objdump -h to see how big .data and .sdata are.

    --- Quote End ---

    really I donot run the application from the command shell..I am using the nios2 build tool for eclipse..so i donot understand all you are talking about, execuse me.. but the gcc version i think gcc4..

    can I send you the sopcinfo file and the main.c??
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I don't ever run the IDE!

    The IDE will have left the .o file lurking somewhere (probably polluting the directory with your sources).

    It also installs a copy of objdump somewhere.

    Everything is actually a lot easier to understand if you don't use an IDE - IDEs try to do everything for you by 'magic' and leave you without any of the knowlege required to find out what has really happened when things go wrong.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    I don't ever run the IDE!

    The IDE will have left the .o file lurking somewhere (probably polluting the directory with your sources).

    It also installs a copy of objdump somewhere.

    Everything is actually a lot easier to understand if you don't use an IDE - IDEs try to do everything for you by 'magic' and leave you without any of the knowlege required to find out what has really happened when things go wrong.

    --- Quote End ---

    thank you ..

    but from where should I begin?

    and how can I fix this problem??
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    hello,mallocr.c:2150: warning: unable to reach (null) (at 0x0023814c) from the global pointer (at 0x0022addc) because the offset (54128) is out of the allowed range, -32678 to 32767.

    --- Quote End ---

    This (lamentably obscure) error message indicates overflow of the .sdata segment. By default (see -G n -- but use with extreme caution!) globals of size 8 bytes or less are assigned to .sdata, which is limited to 64KB (32KB in Nios2 toolchains before ACDS 14.1 iirc). The purpose of this is to allow these globals to be accessed via fast, compact 16-bit offsets from the GP register. Globals may also be assigned to .sdata using the gcc __attribute__ mechanism, which can result in faster or more compact code if used judiciously. The simplest (if not necessarily best) way to deal with .sdata overflow as above is to use the -mno-gpopt switch (available in Nios2 gcc 3.x toolchains and also in gcc 4.x starting with ACDS 14.1). This will eliminate the 64KB limit at the cost of generating slower less dense code which uses 32-bit offsets throughout to access these globals. Some might argue that using fewer globals is a better solution. :-)