#1417 multiple definition of char cons w. --model-large

closed-fixed
5
2013-05-25
2008-01-05
No

Hi All.
I'm trying to compile my port of TinyOS using SDCC*, but I'm running into some problems. One problem is the following: one program runs fine with the default memory mode (small i presume), but fails with the following error when switching to large:

...
?ASxxxx-Error-<mp> in line 4627 of build/cc2430em/app.asm
<m> multiple definitions error
<p> phase error: label location changing between passes 2
and 3
?ASxxxx-Error-<m> in line 4630 of build/cc2430em/app.asm
<m> multiple definitions error
removing build/cc2430em/app.rel
...

In the example above it turns out to be a char constant that ends up being multiply defined in the asm output.

I've reproduced the problem int the attached .c file.

* Interested parties can take a look here:
http://www.tinyos8051wg.net

Discussion

  • Martin Leopold

    Martin Leopold - 2008-01-05
     
  • Robert Larice

    Robert Larice - 2008-03-04

    Logged In: YES
    user_id=1840151
    Originator: NO

    the submitted piece of c can be reduced to a one-liner

    ---->8----
    char *c = (char *) "Booting";
    ----<8----

    compilation with (-mmcs51)
    sdcc -c --model-large

    results in a piece of *.asm with a double definition:

    ---------
    .area CONST (CODE)
    __str_0:
    .ascii "Booting"
    .db 0x00
    __str_0:
    .ascii "Booting"
    .db 0x00
    ---------

    the problem is bound to large-model and to the (char*) cast.

    Robert Larice

     
  • Robert Larice

    Robert Larice - 2008-03-05

    Logged In: YES
    user_id=1840151
    Originator: NO

    for debugging a first suitable breakpoint might be: (gdb slang)

    break SDCCglue.c:263

    and a helper would be (gdb slang)

    define print_statsg
    print *(symbol*)statsg->syms->item
    print *(symbol*)statsg->syms->next->item
    print *(symbol*)statsg->syms->next->next->item
    end

    ---%%---

    the above mentioned break is "-1->" in :

    /* create a new "XINIT (CODE)" symbol, that will be emitted later
    in the static seg */
    ...
    -1-> resolveIvalSym(newSym->ival, newSym->type);
    ...
    if (!SPEC_ABSA (sym->etype))
    {
    ...
    -2-> printIval (sym, sym->type, sym->ival, &tmpBuf);
    ...

    after execution of the -1- funcall, print_statsg displays:
    {name = "_str_0" ... }
    Cannot access memory at address 0x0
    after execution of the -2- funcall, print_statsg displays:
    {name = "_str_0" ... }
    {name = "_str_0" ... }
    Cannot access memory at address 0x0

    and somwhere later the thing is then emited twice to the
    assembler output.

    for completness the backtrace at "-1" is:

    #0 emitRegularMap (map=0x8155780, addPublics=1, arFlag=1) at SDCCglue.c:263
    #1 0x080c9ebb in emitMaps () at SDCCglue.c:1326
    #2 0x080caaaa in glue () at SDCCglue.c:1582
    #3 0x080577d1 in main (argc=4, argv=0xbfa75a74, envp=0xbfa75a88) at SDCCmain.c:2405

    Robert Larice

     
  • Borut Ražem

    Borut Ražem - 2008-03-08

    Logged In: YES
    user_id=568035
    Originator: NO

    This bug seems to be a side effect of fixing bug #770484: "sizeof() on struct containing an array is wrong" (see http://sourceforge.net/tracker/index.php?func=detail&aid=770484&group_id=599&atid=100599\), which seems not to be fixed: sizeof(sd) is still 1 instead 7.
    The change was done in file SDCCglue.c svn revision #3333 by Maarten.

    Maarten, can you please re-verify if #770484 is really fixed? If it is not fixed it wold be probably better to revert the change so that bug #1864582 wouldn't appear any more. Probably a regression test should be added too...

    Borut

     
  • Maarten Brock

    Maarten Brock - 2008-03-08

    Logged In: YES
    user_id=888171
    Originator: NO

    As already stated in bug #770484 sizeof(sd) is supposed to give 1 according to the C99 standard. There is also a regression test for it in structflexarray.c.

    To solve this bug I think we need something like noInit for no initializers, similar to noAlloc for no allocation.

     
  • Borut Ražem

    Borut Ražem - 2008-03-08
    • milestone: --> fixed
    • assigned_to: nobody --> borutr
    • status: open --> closed-fixed
     
  • Borut Ražem

    Borut Ražem - 2008-03-08

    Logged In: YES
    user_id=568035
    Originator: NO

    Maarten, thank you for the explanation. I red the bug report superficially, so a thought that the sizeof(sd) has to be 7. An thank you for the hint for noInit. I don't generally like such type of global variables (they can be very dangerous too), but in this case it helped to solve the bug.

    Fixed in svn revision #5079.

    Borut

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks