Menu

#1857 mcs51 3.05 #6901: model huge broken

closed-fixed
linker (61)
5
2013-05-25
2011-10-07
zramaro
No

Hello,

The last night snapshot of SDCC is producing wrong code for model huge. The linker allocates all the code into CSEG (extended address 0x1 0x0 or 0x0 0x1).

I've attached the linker outputs of the same project: for the last night snapshot (3.05 #6901) and for a working version (3.04 #6707).

Regards,
Zafi.

Discussion

  • zramaro

    zramaro - 2011-10-07

    linker output file

     
  • George Oikonomou

    I can confirm this, plus some additional info.

    - This appears to have been introduced by rev 6849

    - I tested the following versions (all on linux):

    - Correct code: 6748, 6848
    - Incorrect code: 6849, 6850, 6859, 6868, 6959

    - --model-large --stack-auto appears to work

    - I observed this with the Contiki OS (So did the OP, judging by the attachment) - might take a while to provide an example that will reproduce it.

    - I compile with (BANKx changes per file):

    sdcc --codeseg BANK3 -DCONTIKI=1 -DCONTIKI_TARGET_SENSINODE=1 -DUIP_CONF_IPV6=1 --model-huge --stack-auto -DSDCC_CC2430 --std-c99 -DHAVE_SDCC_BANKING -DMODEL_N601 -DPROJECT_CONF_H -I. -I../../../platform/sensinode/. -I../../../platform/sensinode/dev -I../../../cpu/cc2430/. -I../../../cpu/cc2430/dev -I../../../core/dev -I../../../core/lib -I../../../core/net -I../../../core/net/mac -I../../../core/net/rime -I../../../core/net/rpl -I../../../core/sys -I../../../core/cfs -I../../../core/ctk -I../../../core/lib/ctk -I../../../core/loader -I../../../core/. -DCONTIKI_VERSION_STRING=\"Contiki-2.5-1517-gb9d0ae9\" -c ../../../cpu/cc2430/dev/slip-arch.c -o obj_sensinode/slip-arch.rel -Wp,-MMD,obj_sensinode/slip-arch.d,-MQ,obj_sensinode/slip-arch.rel

    - I link with:

    sdcc --model-huge --stack-auto -DSDCC_CC2430 --out-fmt-ihx --xram-loc 0xE000 --xram-size 0x1F00 --code-loc 0x00000 --code-size 0x20000 -Wl-bBANK1=0x018000 -Wl-bBANK2=0x028000 -Wl-bBANK3=0x038000 -Wl-r -o border-router.ihx obj_sensinode/contiki-sensinode-main.rel obj_sensinode/border-router.app.rel -llibsdcc.lib -lcontiki-sensinode.lib

    I've got the resulting map files from a bunch of versions if that would be of any assistance

     
  • George Oikonomou

    I've got some more info on this one.

    First of all, I was talking nonsense in the previous comment when I said that model-large works. It only does when building non-banked code

    This bug was caused by changing the default value of a_bytes to 2 (back from 4) in rev 6849 in sdas/linksrc/lkmain.c, link_main() line 576. It makes sense this only manifests itself with banking since that's when addresses are longer than 2 bytes, if I understand correctly

    I changed the default a_bytes to 3 and 4 with rev 6993 and the problem goes away with large as well as with huge. I then reset the default to 2 and I rebuilt the world with XH3 in the header of my rel files (incl. model-huge libraries) but that didn't quite work, the linker was flapping between 2 and 3 all the time from what I could see.

    Unless I'm missing something, mcs51 builds with banking are currently impossible with huge as well as with large.

    It's actually rather easy to reproduce

    foo.c

    #include <cc2430.h>
    SFR(PSBANK, 0x9F);

    #pragma codeseg BANK2
    void main() {
    }

    correct stuff:

    geo@lin-geo:~/workspace/test-proj$ sdcc -v
    SDCC : mcs51 3.0.4 #6848 (Oct 25 2011) (Linux)
    geo@lin-geo:~/workspace/test-proj$ sdcc --model-huge -Wl-r -Wl-bBANK2=0x28000 foo.c
    output extended linear address record 0x2 0x0
    output extended linear address record 0x0 0x2
    geo@lin-geo:~/workspace/test-proj$ egrep '^BANK2 ' foo.map
    BANK2 00028000 00000003 = 3. bytes (REL,CON,CODE)

    bad stuff

    geo@lin-geo:~/workspace/test-proj$ /home/geo/sdcc/bin/sdcc -v
    SDCC : mcs51 3.0.6 #6991 (Oct 26 2011) (Linux)
    geo@lin-geo:~/workspace/test-proj$ /home/geo/sdcc/bin/sdcc --model-huge -Wl-r -Wl-bBANK2=0x28000 foo.c
    geo@lin-geo:~/workspace/test-proj$ egrep '^BANK2 ' foo.map
    BANK2 8000 0003 = 3. bytes (REL,CON,CODE)

    With more banks and more files, results get a lot messier, as per the log in the OP

    Hope this helps

     
  • Maarten Brock

    Maarten Brock - 2011-10-29
    • milestone: --> fixed
    • assigned_to: nobody --> maartenbrock
    • status: open --> closed-fixed
     
  • Maarten Brock

    Maarten Brock - 2011-10-29

    Fixed in SDCC 3.0.6 #6994.

     

Log in to post a comment.