• AVR Freaks

Hot![SOLVED] C18 v3.47, assert error during link?

Page: 12 > Showing page 1 of 2
Author
waltje
New Member
  • Total Posts : 10
  • Reward points : 0
  • Joined: 2020/05/04 14:21:07
  • Location: 0
  • Status: offline
2020/05/10 14:21:53 (permalink)
0

[SOLVED] C18 v3.47, assert error during link?

Hi all,
 
First post here, although I have been watching for years :P
 
Compiling some code, which runs fine.
Then, at the link stage, the linker bombs out:
Assertion failed: !isLoaded (file, secName), file ../src/MemTarg.cpp, line 904

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
make: *** [gldemo.cof] Error 1

 
Obviously, this isnt good... ;-)
 
@Jason: any clues on this?
 
UPDATE: fortunately, wasn't caused by the actual code being compiled, but rather a stupid
              bug in the linker.  @JasonK: will create a ticket for it, but my hopes arent high..
post edited by waltje - 2020/05/12 13:37:28
#1

27 Replies Related Threads

    ric
    Super Member
    • Total Posts : 28009
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: C18 v3.47, assert error during link? 2020/05/11 06:56:04 (permalink)
    0
    Do you really have to use the long discontinued C18 compiler?
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #2
    dan1138
    Super Member
    • Total Posts : 3731
    • Reward points : 0
    • Joined: 2007/02/21 23:04:16
    • Location: 0
    • Status: offline
    Re: C18 v3.47, assert error during link? 2020/05/11 08:49:56 (permalink)
    +3 (3)
    I am amazed that the Original Poster can get C18 to compile a C++ source file that only asserts an error at link time.
    #3
    waltje
    New Member
    • Total Posts : 10
    • Reward points : 0
    • Joined: 2020/05/04 14:21:07
    • Location: 0
    • Status: offline
    Re: C18 v3.47, assert error during link? 2020/05/11 10:24:02 (permalink)
    0
    ric
    Do you really have to use the long discontinued C18 compiler?
     


    Yes.  XC8 gives me way more headaches.
     
    I did some more testing, and this crash happens when the linker tries to add
    in a specific function in one of my libraries, one that uses stdarg args (it is a
    printf-variant.)
     
    To be continued...
     
    Fred
    #4
    ric
    Super Member
    • Total Posts : 28009
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: C18 v3.47, assert error during link? 2020/05/11 13:21:01 (permalink)
    0
    If you're trying to get it to compile CPP files, I'm not surprised you're having problems with XC8.
    I'm just surprised that you're not having the same problems with C18.
     
    Edit: Struck out spurious comment. Later posts make clear that's referring to part of the linker, not the OP's source.
    post edited by ric - 2020/05/11 21:38:32

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #5
    waltje
    New Member
    • Total Posts : 10
    • Reward points : 0
    • Joined: 2020/05/04 14:21:07
    • Location: 0
    • Status: offline
    Re: C18 v3.47, assert error during link? 2020/05/11 13:40:47 (permalink)
    +1 (1)
    dan1138
    I am amazed that the Original Poster can get C18 to compile a C++ source file that only asserts an error at link time.


    Ah, now I see the confusion.
     
    The .cpp file mentioned in my OP is a source file from MPLINK, not from my code :P
     
    So, while linking my code, mplink boms out on an assert that failed, on line 904 in that .cpp file.
     
    @ric: see above.  That file is part of the linker, not my code.
     
    Fred
    #6
    ric
    Super Member
    • Total Posts : 28009
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: C18 v3.47, assert error during link? 2020/05/11 13:49:58 (permalink)
    0
    ok, fair point.
    It's still a bit late to get help with C18 linker problems.
    What problems did you have with XC8? Possibly just code that depended upon non standard behaviour of C18.

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #7
    waltje
    New Member
    • Total Posts : 10
    • Reward points : 0
    • Joined: 2020/05/04 14:21:07
    • Location: 0
    • Status: offline
    Re: C18 v3.47, assert error during link? 2020/05/11 13:56:59 (permalink)
    0
    ric
    ok, fair point.
    It's still a bit late to get help with C18 linker problems.
    What problems did you have with XC8? Possibly just code that depended upon non standard behaviour of C18.


    C18 is not too non-standard (for an embedded compiler.)  XC8 starts off with abusing 'const' to mean
    'in rom', which breaks just about all of my existing codebase.  It ONLY does compiled stacks, which rules
    out re-entrace.  The claim (on Microchip's website) that the C18 suite (and MPLAB non-X) only work
    on 32bit host platforms is of course rediculous.
     
    I modifiied my C18 setup to a) fix the preprocessor (# and ## bugs, several additions), a new compiler
    driver that actually spits out invalid arguments, and I cleaned up the runtime to build clean in all 4 modes. I
    was planning on importing runtime stuff from XC8 as a next step, but right now, I am just stumped by
    this bug....
     
    --Fred
    #8
    ric
    Super Member
    • Total Posts : 28009
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: C18 v3.47, assert error during link? 2020/05/11 14:06:23 (permalink)
    +1 (1)
    waltje
     XC8 starts off with abusing 'const' to mean
    'in rom', which breaks just about all of my existing codebase.

    I think it does it pretty well, but that comes back to how you've used it.

    It ONLY does compiled stacks

    Not according to the user guide. You CAN set a software stack.
    You'd only want to do that on devices with plenty of RAM.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #9
    Antipodean
    Super Member
    • Total Posts : 1876
    • Reward points : 0
    • Joined: 2008/12/09 10:19:08
    • Location: Didcot, United Kingdom
    • Status: offline
    Re: C18 v3.47, assert error during link? 2020/05/11 18:58:20 (permalink)
    +1 (1)
    ric
    waltje
     XC8 starts off with abusing 'const' to mean
    'in rom', which breaks just about all of my existing codebase.

    I think it does it pretty well, but that comes back to how you've used it.

    It ONLY does compiled stacks

    Not according to the user guide. You CAN set a software stack.
    You'd only want to do that on devices with plenty of RAM.

     
    One also wonders where else or how else the 'const' is being used.
    Would be interested to see how the OP is attempting to use (misuse?) it.

    Do not use my alias in your message body when replying, your message will disappear ...

    Alan
    #10
    dan1138
    Super Member
    • Total Posts : 3731
    • Reward points : 0
    • Joined: 2007/02/21 23:04:16
    • Location: 0
    • Status: offline
    Re: C18 v3.47, assert error during link? 2020/05/11 20:14:50 (permalink)
    +2 (2)
    Ant-i-podean
    One also wonders where else or how else the 'const' is being used.
    Would be interested to see how the OP is attempting to use (misuse?) it.

    C18 uses a non-standard language extension to bind a pointer to either the RAM or ROM storage class.
     
    The C18 memory model sees RAM and ROM as mutually exclusive address spaces. C18 does not implement a "generic" pointers that can reference the entire address space. This is a fundamental reason that C18 cannot be an ISO compliant C compiler.

    XC8 uses a model for the address space that encompasses both RAM and ROM but there is a runtime penalty that makes the code XC8 generates less efficient. 
    #11
    ric
    Super Member
    • Total Posts : 28009
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: C18 v3.47, assert error during link? 2020/05/11 20:18:31 (permalink)
    0
    dan1138
    XC8 uses a model for the address space that encompasses both RAM and ROM but there is a runtime penalty that makes the code XC8 generates less efficient. 

    According to the user guide, that is only if you do actually use it for both (or do it in such a way that it can't detect what you are doing).
    If in fact the pointers are only ever used for ROM or for RAM, it generates the optimal code to do just that.

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #12
    dan1138
    Super Member
    • Total Posts : 3731
    • Reward points : 0
    • Joined: 2007/02/21 23:04:16
    • Location: 0
    • Status: offline
    Re: C18 v3.47, assert error during link? 2020/05/11 20:32:20 (permalink)
    0
    ric
    If in fact the pointers are only ever used for ROM or for RAM, it generates the optimal code to do just that.

    Yes, agreed that XC8 deals with pointera better than C18 that just blows a gasket when a (void *) is cast to the wrong type.
    #13
    jtemples
    عُضْوٌ جَدِيد
    • Total Posts : 11936
    • Reward points : 0
    • Joined: 2004/02/13 12:31:19
    • Location: Southern California
    • Status: offline
    Re: C18 v3.47, assert error during link? 2020/05/11 21:21:16 (permalink)
    +1 (1)
    Ant1podean
    One also wonders where else or how else the 'const' is being used.
    Would be interested to see how the OP is attempting to use (misuse?) it.

     
    I'm interested as  well...
    #14
    waltje
    New Member
    • Total Posts : 10
    • Reward points : 0
    • Joined: 2020/05/04 14:21:07
    • Location: 0
    • Status: offline
    Re: C18 v3.47, assert error during link? 2020/05/12 10:10:09 (permalink)
    +1 (1)
    "Generic" pointers basically waste space and cycles.  If we have a device with 256K flash and, say, 4K SRAM,
    we need 24bit pointers just because of the Flash space, even if we are dealing with SRAM data.
     
    This is why C18 uses different pointer sizes, as these two spaces ARE separate critters.
     
    #15
    waltje
    New Member
    • Total Posts : 10
    • Reward points : 0
    • Joined: 2020/05/04 14:21:07
    • Location: 0
    • Status: offline
    Re: C18 v3.47, assert error during link? 2020/05/12 10:12:40 (permalink)
    0
    I just typed a long response to the 'where does OP abuse const' question, and I dont see it now.
     
    Basically, 'const' is a behavior-modifying keyword (telling the compiler a variable cannot be changed), and
    'rom' aka 'flash' are storage-class modifying keywords, which tell the compiler WHERE the variable is to be placed (declaration) or found (dereferencing).
    #16
    NKurzman
    A Guy on the Net
    • Total Posts : 18858
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: C18 v3.47, assert error during link? 2020/05/12 10:20:54 (permalink)
    0
    waltje
    "Generic" pointers basically waste space and cycles.  If we have a device with 256K flash and, say, 4K SRAM,
    we need 24bit pointers just because of the Flash space, even if we are dealing with SRAM data.
     
    This is why C18 uses different pointer sizes, as these two spaces ARE separate critters.
     

    And XC has "OCG".  It analyzes how a pointer is used in the program and uses the minimum size of pointer required to correctly execute the code.  It may even change the size of the pointer during execution, if it sees that it will optimize the code.  causing the unwary to post that they found a bug.
     
    A note about using const instead of ROM.  XC8 is Not the Only compiler to use that common trick.
    #17
    jtemples
    عُضْوٌ جَدِيد
    • Total Posts : 11936
    • Reward points : 0
    • Joined: 2004/02/13 12:31:19
    • Location: Southern California
    • Status: offline
    Re: C18 v3.47, assert error during link? 2020/05/12 10:23:15 (permalink)
    +1 (1)
    'const' is a behavior-modifying keyword (telling the compiler a variable cannot be changed)

     
    "const" means "read-only" not "can't be changed".  Those are two very different things.
    #18
    jtemples
    عُضْوٌ جَدِيد
    • Total Posts : 11936
    • Reward points : 0
    • Joined: 2004/02/13 12:31:19
    • Location: Southern California
    • Status: offline
    Re: C18 v3.47, assert error during link? 2020/05/12 10:30:58 (permalink)
    0
    XC8 starts off with abusing 'const' to mean 'in rom', which breaks just about all of my existing codebase.

     
    I'm still curious as to what kind of code breaks when const means "in ROM".
    #19
    crosland
    Super Member
    • Total Posts : 2017
    • Reward points : 0
    • Joined: 2005/05/10 10:55:05
    • Location: Warks, UK
    • Status: offline
    Re: C18 v3.47, assert error during link? 2020/05/12 12:57:38 (permalink)
    0
    jtemples
    'const' is a behavior-modifying keyword (telling the compiler a variable cannot be changed)

     
    "const" means "read-only" not "can't be changed".  Those are two very different things.


    jtemples
    XC8 starts off with abusing 'const' to mean 'in rom', which breaks just about all of my existing codebase.

     
    I'm still curious as to what kind of code breaks when const means "in ROM".



    Read-only certainly does not mean "in ROM".
    #20
    Page: 12 > Showing page 1 of 2
    Jump to:
    © 2020 APG vNext Commercial Version 4.5