This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

maybe, a BUG of ARM Linker version 4.0 Build 697

Note: This was originally posted on 12th August 2010 at http://forums.arm.com

Here is the piece of code in a C source file.

#pragma arm section rwdata ="cellular_ram"
u8 gv_CFI[256]={0};/* MAN ID DID1,DID2,DID3*/
u16 gv_DIDR;
u16 gv_RCR;
u16 gv_BCRInit;
u16 gv_BCR;
#pragma arm section rwdata

then, in scatter file, somethin like this:
    ER_PRE_INIT_DATA  0xA01FF000  (0x00001000)
   {
      init.ptl(cellular_ram,+FIRST)
      drv_gpio.*(+RW,+ZI)
   }

I want to put gv_CFI and the ohter 4 u16 var together in a fix place.

But, after link finished. I check the MAP file.
I found this:

[color="#FF0000"]   gv_CFI                                   0xa802fe58   Data         128  init.ptl(.bss)  [/color]

    gv_DIDR                                  0xa01ff000   Data           2  init.ptl(cellular_ram)
    gv_RCR                                   0xa01ff002   Data           2  init.ptl(cellular_ram)
    gv_BCRInit                               0xa01ff004   Data           2  init.ptl(cellular_ram)
    gv_BCR                                   0xa01ff006   Data           2  init.ptl(cellular_ram)

the gv_CFI  is placed wrong.....

How can I deal with this ? Why the linker split it from the other four? They are all .bss. why??

Who can help me?

I'm downloading the latest build of RVCT. I hope it will resolve my problem. ...

After upgrade to RVCT v4.0 Build 821, the same problem.

Then, I tried like this:

u8 gv_CFI[256]={0xFF};

It's done.

Thanks for the help of scott.
  • Note: This was originally posted on 12th August 2010 at http://forums.arm.com

    The compiler has placed gv_CFI in ZI (.bss) and the '#pragma arm section rwdata=...' does not affect it (because it's ZI not RW).  The other four have been placed in RW (because they are small) and are affected by the #pragma.  You'll probably find it easier to use __attribute__((section("..."))) instead of '#pragma arm section ...' for controlling data sections; see the manual [url="http://infocenter.arm.com/help/topic/com.arm.doc.dui0491a/Caccache.html"]infocenter.arm.com/.../url].

    Searching the infocenter.arm.com Knowledgebase Articles also turns up [url="http://infocenter.arm.com/help/topic/com.arm.doc.faqs/ka3947.html"]infocenter.arm.com/.../url]


    Thanks for your help. Build 821 has the same prb.
  • Note: This was originally posted on 12th August 2010 at http://forums.arm.com

    #pragma arm section rwdata ="cellular_ram"
    u8 gv_CFI[256]={0};/* MAN ID DID1,DID2,DID3*/
    u16 gv_DIDR;
    ...
    #pragma arm section rwdata


    [...]
    I want to put gv_CFI and the ohter 4 u16 var together in a fix place.

    But, after link finished. I check the MAP file.
    I found this:

    [color="#FF0000"]    gv_CFI                                   0xa802fe58   Data         128  init.ptl(.bss)  [/color]

        gv_DIDR                                  0xa01ff000   Data           2  init.ptl(cellular_ram)
        ...

    the gv_CFI  is placed wrong.....

    How can I deal with this ? Why the linker split it from the other four? They are all .bss. why??


    The compiler has placed gv_CFI in ZI (.bss) and the '#pragma arm section rwdata=...' does not affect it (because it's ZI not RW).  The other four have been placed in RW (because they are small) and are affected by the #pragma.  You'll probably find it easier to use __attribute__((section("..."))) instead of '#pragma arm section ...' for controlling data sections; see the manual [url="http://infocenter.arm.com/help/topic/com.arm.doc.dui0491a/Caccache.html"]http://infocenter.arm.com/help/topic/com.a...a/Caccache.html[/url].

    Searching the infocenter.arm.com Knowledgebase Articles also turns up [url="http://infocenter.arm.com/help/topic/com.arm.doc.faqs/ka3947.html"]http://infocenter.arm.com/help/topic/com.a...aqs/ka3947.html[/url]
  • Note: This was originally posted on 12th August 2010 at http://forums.arm.com

    Build 821 has the same prb.


    As Scott says, this isn't a problem. It's correct behavior.

    The first item is zero-initialized the others are not, so the compiler / linker are free to split them up across different section types.

    Indeed, as they are unrelated data items, there is really no guarantee about their relative placement in memory. The compiler would be perfectly correct to place them in totally different sections in different areas of memory (although no sane compiler would).

    I want to put gv_CFI and the ohter 4 u16 var together in a fix place.


    Then make them fields of a single structure, then the compiler is not allowed to split them up ...