Hot!XC16 compiler not grouping all the code for each section together

Author
engineering@skutchelectronics.com
New Member
  • Total Posts : 15
  • Reward points : 0
  • Joined: 2010/07/02 09:26:32
  • Location: 0
  • Status: offline
2018/02/09 12:22:03 (permalink)
0

XC16 compiler not grouping all the code for each section together

I'm starting to cross over my established code from MPLab 8.92 to MPLab X 4.10.  I work entirely in assembly and one project uses the dsPIC33FJ256GP710A.  It appears that the XC16 compiler is letting the .text segments be linked in wherever it wants when they should all be grouped together; i.e. all the .text segments in one contiguous block and all the FlashMem segments in one contiguous block (not mixing FlashMem, .text, .text, FlashMem, etc.).  The FlashMem section below is an upper memory area that holds a Flashing code segment used when in field reprogramming with an update file and all those segments have defined origins and I don't want the .text segments being mixed in with them.  I tried defining both small then large program memory models with the same allocations.  On 8.92 everything compiles nice with the following program memory listing:
Program Memory  [Origin = 0x200, Length = 0x2aa00]

section                    address   length (PC units)   length (bytes) (dec)
-------                    -------   -----------------   --------------------
.text                        0x200              0xe56a         0x1581f  (88095)
.EEData                    0x23800               0x800           0xc00  (3072)
FlashMem                  0x26360               0x616           0x921  (2337)
FlashMem                  0x26980               0x69c           0x9ea  (2538)
FlashMem                  0x27020               0x852           0xc7b  (3195)
FlashMem                  0x27880               0xa0e           0xf15  (3861)
FlashMem                  0x28290               0xc34          0x124e  (4686)
FlashMem                  0x28ed0               0x200           0x300  (768)
FlashMem                  0x290e0                0xd8           0x144  (324)
FlashMem                  0x291c0                0x34            0x4e  (78)
FlashMem                  0x29200                0x7e            0xbd  (189)
FlashMem                  0x29280               0x254           0x37e  (894)
FlashMem                  0x294e0               0x416           0x621  (1569)
FlashMem                  0x29900               0xf00          0x1680  (5760)
FlashMem                  0x2a800                0x7e            0xbd  (189)

                     Total program memory used (bytes):        0x1cb33  (117555) 44%
 
Whereas on X I get:
Program Memory  [Origin = 0x200, Length = 0x2aa00]

section                    address   length (PC units)   length (bytes) (dec)
-------                    -------   -----------------   --------------------
.text                        0x200                0x9c            0xea  (234)
.dinit                       0x29c              0x2df2          0x44eb  (17643)
.text                       0x308e              0x2304          0x3486  (13446)
.text                       0x5392              0x1130          0x19c8  (6600)
.CharSet                    0x64c2               0xf00          0x1680  (5760)
.text                       0x73c2              0x406c          0x60a2  (24738)
.text                       0xb42e               0x338           0x4d4  (1236)
.text                       0xb766               0x46a           0x69f  (1695)
.text                       0xbbd0               0x31c           0x4aa  (1194)
.text                       0xbeec               0x1e0           0x2d0  (720)
.text                       0xc0cc               0x1e4           0x2d6  (726)
.EEData                    0x23800               0x800           0xc00  (3072)
.text                      0x24000              0x12ba          0x1c17  (7191)
.text                      0x252ba               0x26e           0x3a5  (933)
FlashMem                   0x255b0               0x616           0x921  (2337)
.text                      0x25bc6               0x262           0x393  (915)
.text                      0x25e28                0xba           0x117  (279)
FlashMem                   0x25efa               0x69c           0x9ea  (2538)
.text                      0x26596               0x1b8           0x294  (660)
FlashMem                   0x267c6               0x852           0xc7b  (3195)
.text                      0x27018               0x120           0x1b0  (432)
FlashMem                   0x27140               0xa0e           0xf15  (3861)
.text                      0x27b4e               0x1d4           0x2be  (702)
FlashMem                   0x27d5c               0xc34          0x124e  (4686)
.text                      0x28990               0x108           0x18c  (396)
.text                      0x28a98                0x5e            0x8d  (141)
FlashMem                   0x28b0c               0x200           0x300  (768)
.text                      0x28d0c               0x28a           0x3cf  (975)
.text                      0x28f96                0x4e            0x75  (117)
.text                      0x28fe4                 0x2             0x3  (3)
FlashMem                   0x28fe6                0xd8           0x144  (324)
FlashMem                   0x290de                0x34            0x4e  (78)
FlashMem                   0x29146                0x7e            0xbd  (189)
FlashMem                   0x291f0               0x254           0x37e  (894)
FlashMem                   0x294a0               0x416           0x621  (1569)
.text                      0x298b6                0x3e            0x5d  (93)
FlashMem                   0x29900               0xf00          0x1680  (5760)
FlashMem                   0x2a800                0x7e            0xbd  (189)
.text                      0x2a87e               0x34e           0x4f5  (1269)

                 Total program memory used (bytes):        0x1cb36  (117558) 44%
 
How can I stop it from putting the .text segments in the high memory?
#1

10 Replies Related Threads

    du00000001
    Just Some Member
    • Total Posts : 1577
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: XC16 compiler not grouping all the code for each section together 2018/02/09 12:43:11 (permalink)
    +1 (1)
    I work entirely in assembly ...

    It appears that the XC16 compiler is letting ...

    Now what ? Assembler? Compiler? Linker? Which version(s)? Don't try to keep us guessing!
     
    A coarse scan shows the following:
    • EEData is where it ever was - unaltered.
    • .text might be the same size as well.
    • Currently there seems to be no Flash occupied between 0x10000 and 0x23000. Sure it is declared?

    Most times the bug is in front of the keyboard.
    #2
    aschen0866
    Super Member
    • Total Posts : 4235
    • Reward points : 0
    • Joined: 2006/01/08 22:18:32
    • Location: San Diego
    • Status: offline
    Re: XC16 compiler not grouping all the code for each section together 2018/02/09 13:19:02 (permalink)
    +2 (2)
    engineering@skutchelectronics.com
    ...  It appears that the XC16 compiler is letting the .text segments be linked in wherever it wants when they should all be grouped together...

    That's normal. By default, the best allocator handles the .text section. If you want to disable that, add .text input section to the output section command:

    /*
    ** Note that input sections *(.text) are not mapped here.
    ** The best-fit allocator locates them, so that .text
    ** may flow around PSV sections as needed.
    */
    .text :
    {
    *(.init);
    *(.user_init);
    KEEP (*(.handle));
    KEEP (*(.isr*));
    *(.libc) *(.libm) *(.libdsp); /* keep together in this order */
    *(.lib*);
    *(.text); /* Add this line here to disable the best-fit allocator */
    } >program

    #3
    NKurzman
    A Guy on the Net
    • Total Posts : 15512
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: offline
    Re: XC16 compiler not grouping all the code for each section together 2018/02/09 14:18:27 (permalink)
    +1 (1)
    The issue is not MPLab X. either you changed versions of XC16, your linker script was not included or changed, or your command line is different.
    #4
    engineering@skutchelectronics.com
    New Member
    • Total Posts : 15
    • Reward points : 0
    • Joined: 2010/07/02 09:26:32
    • Location: 0
    • Status: offline
    Re: XC16 compiler not grouping all the code for each section together 2018/02/09 14:29:08 (permalink)
    0
    I just installed X yesterday, so it is the latest of everything, xc16-gcc 1.33.
    .text is 0x200-0xe76b
    EEData is a simulated EEPROM in program memory, 0x23800-0x23fff
    FlashMem is an upper code segment used to flash the lower .text section, in 0x26360-0x2a87d normally
    .text and FlashMem need to be separated like that because field updating is a 2 step process, first it flashes the FlashMem section with any new changed code, then reboots and flashes the lower section using the new FlashMem code to do so.  There are several key areas in FlashMem that cannot move and neither FlashMem nor .text can interfere with EEData.  It all works fine as long as XC16 doesn't try to put the .text segments wherever it wants :(
     
    #5
    engineering@skutchelectronics.com
    New Member
    • Total Posts : 15
    • Reward points : 0
    • Joined: 2010/07/02 09:26:32
    • Location: 0
    • Status: offline
    Re: XC16 compiler not grouping all the code for each section together 2018/02/09 14:31:37 (permalink)
    0
    This is the first time I'm using XC16, before I was using MPLab 8.92 and MPASM toolchain to handle it all.  I checked the options between the two, and best I can tell they are the same, but there must be something different in a configuration file.  Are you referring to the gld file for the changes you mentioned?
     
     
    #6
    NKurzman
    A Guy on the Net
    • Total Posts : 15512
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: offline
    Re: XC16 compiler not grouping all the code for each section together 2018/02/09 14:48:37 (permalink)
    +1 (1)
    Before you were probably using C30.  Yes the .GLD file must be included in the project or use external linker script must be selected.
    #7
    engineering@skutchelectronics.com
    New Member
    • Total Posts : 15
    • Reward points : 0
    • Joined: 2010/07/02 09:26:32
    • Location: 0
    • Status: offline
    Re: XC16 compiler not grouping all the code for each section together 2018/02/09 14:51:05 (permalink)
    0
    Found it, thanks for the clue.  Years ago when I first wrote it, I had modified the gld files and stored them in the project folder.  With XC16 those file were throwing errors when I built the project so I dumped them and it compiled, but with that issue.  After I copied the new gld files to the project folder and modified them it's compiling perfectly.  Again, thanks for your help :)
     
     
    #8
    engineering@skutchelectronics.com
    New Member
    • Total Posts : 15
    • Reward points : 0
    • Joined: 2010/07/02 09:26:32
    • Location: 0
    • Status: offline
    Re: XC16 compiler not grouping all the code for each section together 2018/02/09 15:10:02 (permalink)
    0
    Fixed the issue, see other response stream.
     
    #9
    Gort2015
    Klaatu Barada Nikto
    • Total Posts : 1910
    • Reward points : 0
    • Joined: 2015/04/30 10:49:57
    • Location: 0
    • Status: offline
    Re: XC16 compiler not grouping all the code for each section together 2018/02/09 15:23:05 (permalink)
    +1 (1)
    .text is either c code you have in there as well or asm code with no section names.
    The sections or separate files are put into program memory in the order that they were first called or pulled in.  These are all from libraries except .text which is just test code in main.
     
    section                    address   length (PC units)   length (bytes) (dec)
    -------                    -------   -----------------   --------------------
    .text                        0x200              0x1a64          0x2796  (10134)
    .const                      0x1c64               0x5b0           0x888  (2184)
    .text                       0x2214               0xc50          0x1278  (4728)
    lcd7920code                 0x2e64               0x59e           0x86d  (2157)
    .dinit                      0x3402               0x1d6           0x2c1  (705)
    wificode                    0x35d8               0x1b8           0x294  (660)
    REN_code                    0x3790               0x18a           0x24f  (591)
    lcd7920code                 0x391a               0x3dc           0x5ca  (1482)
    eeprom_code                 0x3cf6               0x11e           0x1ad  (429)
    wificode                    0x3e14               0x10c           0x192  (402)
    eeprom_code                 0x3f20                0xea           0x15f  (351)
    REN_Code                    0x400a                0xda           0x147  (327)
    eeprom_code                 0x40e4                0xc6           0x129  (297)
    lcd7920code                 0x41aa                0xbe           0x11d  (285)
    wificode                    0x4268                0xb8           0x114  (276)
    .text                       0x4320               0x162           0x213  (531)
    lcd7920code                 0x4482                0xae           0x105  (261)
    eeprom_code                 0x4530                0xa6            0xf9  (249)
    .text                       0x45d6                0xa6            0xf9  (249)
    DS3231RTC                   0x467c                0x9c            0xea  (234)
    utilitycode                 0x4718                0x9a            0xe7  (231)
    .text                       0x47b2                0x82            0xc3  (195)
    osccode                     0x4834                0x80            0xc0  (192)
    memcode                     0x48b4                0x80            0xc0  (192)
    DS3231RTC                   0x4934                0x7c            0xba  (186)
    spicode                     0x49b0                0x7c            0xba  (186)
    wificode                    0x4a2c                0x7c            0xba  (186)
    utilitycode                 0x4aa8                0x74            0xae  (174)
    lcd7920code                 0x4b1c                0x70            0xa8  (168)
    wificode                    0x4b8c                0x6e            0xa5  (165)
    DS3231RTC                   0x4bfa                0x68            0x9c  (156)
    eeprom_code                 0x4c62                0x68            0x9c  (156)
    lcd7920code                 0x4cca                0x64            0x96  (150)
    wificode                    0x4d2e                0x5c            0x8a  (138)
    .text                       0x4d8a                0x5a            0x87  (135)
    wificode                    0x4de4                0xae           0x105  (261)
    lcd7920code                 0x4e92                0x56            0x81  (129)
    wificode                    0x4ee8                0x54            0x7e  (126)
    lcd7920code                 0x4f3c                0x54            0x7e  (126)
    wificode                    0x4f90                0x52            0x7b  (123)
    objectcode3                 0x4fe2                0x52            0x7b  (123)
    lcd7920code                 0x5034                0x4c            0x72  (114)
    i2c_code                    0x5080                0x48            0x6c  (108)
    eeprom_code                 0x50c8                0x48            0x6c  (108)
    objectcode3                 0x5110                0x48            0x6c  (108)
    eeprom_code                 0x5158                0x8a            0xcf  (207)
    lcd7920code                 0x51e2                0x44            0x66  (102)
    wificode                    0x5226                0x42            0x63  (99)
    lcd7920code                 0x5268                0x82            0xc3  (195)
    eeprom_code                 0x52ea                0x7c            0xba  (186)
    objectcode3                 0x5366                0x3e            0x5d  (93)
    wificode                    0x53a4                0x3c            0x5a  (90)
    lcd7920code                 0x53e0                0x78            0xb4  (180)
    wificode                    0x5458                0x3a            0x57  (87)
    lcd7920code                 0x5492                0x3a            0x57  (87)
    objectcode3                 0x54cc                0x3a            0x57  (87)
    memcode                     0x5506                0x3a            0x57  (87)
    lcd7920code                 0x5540                0xa6            0xf9  (249)
    memcode                     0x55e6                0x36            0x51  (81)
    lcd7920code                 0x561c                0x5a            0x87  (135)
    objectcode3                 0x5676                0x2c            0x42  (66)
    memcode                     0x56a2                0x2c            0x42  (66)
    i2c_code                    0x56ce                0x2a            0x3f  (63)
    DS3231RTC                   0x56f8                0x28            0x3c  (60)
    REN_code                    0x5720                0x26            0x39  (57)
    objectcode3                 0x5746                0x24            0x36  (54)
    lcd7920code                 0x576a                0x22            0x33  (51)
    wificode                    0x578c                0x20            0x30  (48)
    lcd7920code                 0x57ac                0x40            0x60  (96)
    DS3231RTC                   0x57ec                0x3c            0x5a  (90)
    objectcode3                 0x5828                0x3c            0x5a  (90)
    i2c_code                    0x5864                0x36            0x51  (81)
    lcd7920code                 0x589a                0x1a            0x27  (39)
    i2c_code                    0x58b4                0x18            0x24  (36)
    DS3231RTC                   0x58cc                0x16            0x21  (33)
    objectcode3                 0x58e2                0x58            0x84  (132)
    i2c_code                    0x593a                0x26            0x39  (57)
    lcd7920code                 0x5960                0x12            0x1b  (27)
    objectcode3                 0x5972                0x12            0x1b  (27)
    i2c_code                    0x5984                0x10            0x18  (24)
    objectcode3                 0x5994                0x40            0x60  (96)
    lcd7920code                 0x59d4                 0xe            0x15  (21)
    i2c_code                    0x59e2                0x1c            0x2a  (42)
    DS3231RTC                   0x59fe                 0xc            0x12  (18)
    i2c_code                    0x5a0a                 0xa             0xf  (15)
    wificode                    0x5a14                 0x8             0xc  (12)
    objectcode3                 0x5a1c                0x10            0x18  (24)


    MPLab X playing up, bug in your code? Nevermind, Star Trek:Discovery will be with us soon.
    https://www.youtube.com/watch?v=Iu1qa8N2ID0
    + ST:Continues, "What Ships are Made for", Q's back.
    #10
    NKurzman
    A Guy on the Net
    • Total Posts : 15512
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: offline
    Re: XC16 compiler not grouping all the code for each section together 2018/02/09 16:26:34 (permalink)
    0
    engineering@skutchelectronics.com
    Fixed the issue, see other response stream.
     


    What other response stream? did you cross post with no link here?
    #11
    Jump to:
    © 2018 APG vNext Commercial Version 4.5