<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Data Segment Split Into Two Segments in MPC5xxx</title>
    <link>https://community.nxp.com/t5/MPC5xxx/Data-Segment-Split-Into-Two-Segments/m-p/1536213#M22152</link>
    <description>&lt;P&gt;&lt;STRONG&gt;Dear all,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I'm posting my question here because I think I&amp;nbsp; have a linker issue.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I had a 32 bit global variable that has been extended to 64 bits, the program now crashes after this changes for some ecu applications and DO NOT crush for other ECUs using the same source files and the same linker file.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;the only change that I made is that extended 32 bit global variable.&lt;/P&gt;&lt;P&gt;unsigned long long var = 0;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;here is a part of my linker&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I'm using MPC5644A MCU.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;MEMORY&lt;BR /&gt;{&lt;BR /&gt;/* Internal Flash RCW */&lt;BR /&gt;/* MPC5634 1.5M Internal Flash, but subtract one 128K block for use by BAM. */&lt;BR /&gt;flash_rcw : org = 0x00010000, len = 0x10&lt;BR /&gt;int_flash : org = 0x00010010, len = 0x06fff0&lt;BR /&gt;flash_cal : org = 0x00080000, len = 0x4000&lt;/P&gt;&lt;P&gt;/* MPC5566 128K Internal SRAM&amp;nbsp; &amp;nbsp; _BOOTLOADER_n*/&lt;BR /&gt;/* Börjar fysiskt vid 0x40000000 men första 4000 används för kalibrerdata */&lt;BR /&gt;/* int_sram : org = 0x40000000, len = 0x017800*/&lt;BR /&gt;int_sram : org = 0x40004010, len = 0x0135F0&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/* MPC5566 4K of internal cache used for stack. */&lt;BR /&gt;/* Stack Address Parameters */&lt;BR /&gt;__STACK_SIZE = 0x200;&lt;BR /&gt;__SP_INIT = 0x40017800;&lt;BR /&gt;__SP_END = __SP_INIT - __STACK_SIZE;&lt;/P&gt;&lt;P&gt;and this is a part of my sections&amp;nbsp;&lt;/P&gt;&lt;P&gt;NEXT_LOAD_ADDR = . ;&lt;BR /&gt;__DATA_ROMX = . ;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;.backupram : AT (NEXT_LOAD_ADDR)&lt;BR /&gt;{&lt;BR /&gt;__BACKUPRAMSTART = . ;&lt;BR /&gt;*(.backupram)&lt;BR /&gt;} &amp;gt; int_sram&lt;BR /&gt;__BACKUPRAMEND = . ;&lt;BR /&gt;NEXT_LOAD_ADDR = NEXT_LOAD_ADDR + SIZEOF(.backupram );&lt;/P&gt;&lt;P&gt;.adapdata : AT (NEXT_LOAD_ADDR)&lt;BR /&gt;{&lt;BR /&gt;__ADAPSTART = . ;&lt;BR /&gt;*(.adapdata)&lt;BR /&gt;__ADAPEND = . ;&lt;BR /&gt;} &amp;gt; int_sram&lt;BR /&gt;NEXT_LOAD_ADDR = NEXT_LOAD_ADDR + SIZEOF(.adapdata );&lt;/P&gt;&lt;P&gt;.PPC.EMB.sdata2 : AT (NEXT_LOAD_ADDR)&lt;BR /&gt;{&lt;BR /&gt;_SDA2_BASE_ = .;&lt;BR /&gt;__SDATA2_START__ = .;&lt;BR /&gt;*(.PPC.EMB.sdata2)&lt;BR /&gt;} &amp;gt; int_sram&lt;BR /&gt;NEXT_LOAD_ADDR = NEXT_LOAD_ADDR + SIZEOF(.PPC.EMB.sdata2);&lt;/P&gt;&lt;P&gt;.sdata2 : AT (NEXT_LOAD_ADDR)&lt;BR /&gt;{&lt;BR /&gt;*(.sdata2)&lt;BR /&gt;} &amp;gt; int_sram&lt;BR /&gt;NEXT_LOAD_ADDR = NEXT_LOAD_ADDR + SIZEOF(.sdata2);&lt;/P&gt;&lt;P&gt;.PPC.EMB.sbss2 : AT (NEXT_LOAD_ADDR)&lt;BR /&gt;{&lt;BR /&gt;*(.PPC.EMB.sbss2)&lt;BR /&gt;} &amp;gt; int_sram&lt;BR /&gt;NEXT_LOAD_ADDR = NEXT_LOAD_ADDR + SIZEOF(.PPC.EMB.sbss2);&lt;/P&gt;&lt;P&gt;.sbss2 : AT (NEXT_LOAD_ADDR)&lt;BR /&gt;{&lt;BR /&gt;*(.sbss2)&lt;BR /&gt;__SBSS2_END__ = .;&lt;BR /&gt;} &amp;gt; int_sram&lt;BR /&gt;NEXT_LOAD_ADDR = NEXT_LOAD_ADDR + SIZEOF(.sbss2);&lt;/P&gt;&lt;P&gt;.data : AT (NEXT_LOAD_ADDR)&lt;BR /&gt;{&lt;BR /&gt;__DATASTART = . ;&lt;BR /&gt;*(.data)&lt;BR /&gt;*(.data.*)&lt;BR /&gt;*(.gnu.linkonce.d*)&lt;BR /&gt;CONSTRUCTORS&lt;BR /&gt;} &amp;gt; int_sram&lt;BR /&gt;NEXT_LOAD_ADDR = NEXT_LOAD_ADDR + SIZEOF(.data);&lt;/P&gt;&lt;P&gt;I found out that this change affects the segments LOAD in my elfdump.txt file. I'm trying to getting familiar with the program headers and memory mapping. and I discovered that the program headers are now 6 instead of 5.&lt;/P&gt;&lt;P&gt;before my change I had these LOADs:&amp;nbsp;&lt;/P&gt;&lt;P&gt;Program Headers:&lt;BR /&gt;Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align&lt;BR /&gt;LOAD 0x010000 0x00010000 0x00010000 0x34920 0x34920 R E 0x10000&lt;BR /&gt;LOAD 0x054010 0x40004010 &lt;STRONG&gt;0x00044920 0x0144f 0x0144f&lt;/STRONG&gt; RW 0x10000&lt;BR /&gt;LOAD 0x055460 0x40005460 0x00045d6f 0x0000c 0x0000c RW 0x10000&lt;BR /&gt;LOAD 0x060000 0x00080000 0x00080000 0x000b0 0x000b0 R 0x10000&lt;BR /&gt;LOAD 0x065470 0x40005470 0x40005470 0x00000 0x04c7c RW 0x10000&lt;/P&gt;&lt;P&gt;Section to Segment mapping:&lt;BR /&gt;Segment Sections...&lt;BR /&gt;00 .rcw .init .FlashProgram .FlashErase .FlashDriver .text .flash_data .rodata .isrvectbl .xcptn&lt;BR /&gt;&lt;STRONG&gt;01 .backupram .adapdata .data&lt;/STRONG&gt;&lt;BR /&gt;02 .ctors&lt;BR /&gt;03 calconst&lt;BR /&gt;04 .bss&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;Then after that 64 bit variable change I have these segments and these LOADs:&lt;/P&gt;&lt;P&gt;Program Headers:&lt;BR /&gt;Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align&lt;BR /&gt;LOAD 0x010000 0x00010000 0x00010000 0x34920 0x34920 R E 0x10000&lt;BR /&gt;LOAD 0x054010 0x40004010 &lt;STRONG&gt;0x00044920 0x0003c 0x0003c&lt;/STRONG&gt; RW 0x10000&lt;BR /&gt;LOAD 0x054050 0x40004050 &lt;STRONG&gt;0x0004495c 0x0141b 0x0141b&lt;/STRONG&gt; RW 0x10000&lt;BR /&gt;LOAD 0x05546c 0x4000546c 0x00045d77 0x0000c 0x0000c RW 0x10000&lt;BR /&gt;LOAD 0x060000 0x00080000 0x00080000 0x000b0 0x000b0 R 0x10000&lt;BR /&gt;LOAD 0x065478 0x40005478 0x40005478 0x00000 0x04c7c RW 0x10000&lt;/P&gt;&lt;P&gt;Section to Segment mapping:&lt;BR /&gt;Segment Sections...&lt;BR /&gt;00 .rcw .init .FlashProgram .FlashErase .FlashDriver .text .flash_data .rodata .isrvectbl .xcptn&lt;BR /&gt;01 .backupram .adapdata&lt;BR /&gt;&lt;STRONG&gt;02 .data&lt;/STRONG&gt;&lt;BR /&gt;03 .ctors&lt;BR /&gt;04 calconst&lt;BR /&gt;05 .bss&lt;/P&gt;&lt;P&gt;As you can see, the file size of the second load should has been increased by 8, should be 0x01456 and not 0x0003C.and the data must be in the second segment. if&amp;nbsp; I'm not wrong.&lt;/P&gt;&lt;P&gt;I&amp;nbsp;know that uninitialized global variable go to .bss segment, so I tried to uninitialize that variable (just for testing) and it worked fine.&lt;/P&gt;&lt;P&gt;my question:&lt;/P&gt;&lt;P&gt;why the program headers have been increased, and why the data segment split into two segments?&lt;/P&gt;&lt;P&gt;please feel free to correct me if I'm wrong.&lt;/P&gt;&lt;P&gt;any help is appreciated,&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Islem,&lt;/P&gt;</description>
    <pubDate>Wed, 12 Oct 2022 12:53:43 GMT</pubDate>
    <dc:creator>ISLEMTRIKII</dc:creator>
    <dc:date>2022-10-12T12:53:43Z</dc:date>
    <item>
      <title>Data Segment Split Into Two Segments</title>
      <link>https://community.nxp.com/t5/MPC5xxx/Data-Segment-Split-Into-Two-Segments/m-p/1536213#M22152</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Dear all,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I'm posting my question here because I think I&amp;nbsp; have a linker issue.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I had a 32 bit global variable that has been extended to 64 bits, the program now crashes after this changes for some ecu applications and DO NOT crush for other ECUs using the same source files and the same linker file.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;the only change that I made is that extended 32 bit global variable.&lt;/P&gt;&lt;P&gt;unsigned long long var = 0;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;here is a part of my linker&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I'm using MPC5644A MCU.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;MEMORY&lt;BR /&gt;{&lt;BR /&gt;/* Internal Flash RCW */&lt;BR /&gt;/* MPC5634 1.5M Internal Flash, but subtract one 128K block for use by BAM. */&lt;BR /&gt;flash_rcw : org = 0x00010000, len = 0x10&lt;BR /&gt;int_flash : org = 0x00010010, len = 0x06fff0&lt;BR /&gt;flash_cal : org = 0x00080000, len = 0x4000&lt;/P&gt;&lt;P&gt;/* MPC5566 128K Internal SRAM&amp;nbsp; &amp;nbsp; _BOOTLOADER_n*/&lt;BR /&gt;/* Börjar fysiskt vid 0x40000000 men första 4000 används för kalibrerdata */&lt;BR /&gt;/* int_sram : org = 0x40000000, len = 0x017800*/&lt;BR /&gt;int_sram : org = 0x40004010, len = 0x0135F0&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/* MPC5566 4K of internal cache used for stack. */&lt;BR /&gt;/* Stack Address Parameters */&lt;BR /&gt;__STACK_SIZE = 0x200;&lt;BR /&gt;__SP_INIT = 0x40017800;&lt;BR /&gt;__SP_END = __SP_INIT - __STACK_SIZE;&lt;/P&gt;&lt;P&gt;and this is a part of my sections&amp;nbsp;&lt;/P&gt;&lt;P&gt;NEXT_LOAD_ADDR = . ;&lt;BR /&gt;__DATA_ROMX = . ;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;.backupram : AT (NEXT_LOAD_ADDR)&lt;BR /&gt;{&lt;BR /&gt;__BACKUPRAMSTART = . ;&lt;BR /&gt;*(.backupram)&lt;BR /&gt;} &amp;gt; int_sram&lt;BR /&gt;__BACKUPRAMEND = . ;&lt;BR /&gt;NEXT_LOAD_ADDR = NEXT_LOAD_ADDR + SIZEOF(.backupram );&lt;/P&gt;&lt;P&gt;.adapdata : AT (NEXT_LOAD_ADDR)&lt;BR /&gt;{&lt;BR /&gt;__ADAPSTART = . ;&lt;BR /&gt;*(.adapdata)&lt;BR /&gt;__ADAPEND = . ;&lt;BR /&gt;} &amp;gt; int_sram&lt;BR /&gt;NEXT_LOAD_ADDR = NEXT_LOAD_ADDR + SIZEOF(.adapdata );&lt;/P&gt;&lt;P&gt;.PPC.EMB.sdata2 : AT (NEXT_LOAD_ADDR)&lt;BR /&gt;{&lt;BR /&gt;_SDA2_BASE_ = .;&lt;BR /&gt;__SDATA2_START__ = .;&lt;BR /&gt;*(.PPC.EMB.sdata2)&lt;BR /&gt;} &amp;gt; int_sram&lt;BR /&gt;NEXT_LOAD_ADDR = NEXT_LOAD_ADDR + SIZEOF(.PPC.EMB.sdata2);&lt;/P&gt;&lt;P&gt;.sdata2 : AT (NEXT_LOAD_ADDR)&lt;BR /&gt;{&lt;BR /&gt;*(.sdata2)&lt;BR /&gt;} &amp;gt; int_sram&lt;BR /&gt;NEXT_LOAD_ADDR = NEXT_LOAD_ADDR + SIZEOF(.sdata2);&lt;/P&gt;&lt;P&gt;.PPC.EMB.sbss2 : AT (NEXT_LOAD_ADDR)&lt;BR /&gt;{&lt;BR /&gt;*(.PPC.EMB.sbss2)&lt;BR /&gt;} &amp;gt; int_sram&lt;BR /&gt;NEXT_LOAD_ADDR = NEXT_LOAD_ADDR + SIZEOF(.PPC.EMB.sbss2);&lt;/P&gt;&lt;P&gt;.sbss2 : AT (NEXT_LOAD_ADDR)&lt;BR /&gt;{&lt;BR /&gt;*(.sbss2)&lt;BR /&gt;__SBSS2_END__ = .;&lt;BR /&gt;} &amp;gt; int_sram&lt;BR /&gt;NEXT_LOAD_ADDR = NEXT_LOAD_ADDR + SIZEOF(.sbss2);&lt;/P&gt;&lt;P&gt;.data : AT (NEXT_LOAD_ADDR)&lt;BR /&gt;{&lt;BR /&gt;__DATASTART = . ;&lt;BR /&gt;*(.data)&lt;BR /&gt;*(.data.*)&lt;BR /&gt;*(.gnu.linkonce.d*)&lt;BR /&gt;CONSTRUCTORS&lt;BR /&gt;} &amp;gt; int_sram&lt;BR /&gt;NEXT_LOAD_ADDR = NEXT_LOAD_ADDR + SIZEOF(.data);&lt;/P&gt;&lt;P&gt;I found out that this change affects the segments LOAD in my elfdump.txt file. I'm trying to getting familiar with the program headers and memory mapping. and I discovered that the program headers are now 6 instead of 5.&lt;/P&gt;&lt;P&gt;before my change I had these LOADs:&amp;nbsp;&lt;/P&gt;&lt;P&gt;Program Headers:&lt;BR /&gt;Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align&lt;BR /&gt;LOAD 0x010000 0x00010000 0x00010000 0x34920 0x34920 R E 0x10000&lt;BR /&gt;LOAD 0x054010 0x40004010 &lt;STRONG&gt;0x00044920 0x0144f 0x0144f&lt;/STRONG&gt; RW 0x10000&lt;BR /&gt;LOAD 0x055460 0x40005460 0x00045d6f 0x0000c 0x0000c RW 0x10000&lt;BR /&gt;LOAD 0x060000 0x00080000 0x00080000 0x000b0 0x000b0 R 0x10000&lt;BR /&gt;LOAD 0x065470 0x40005470 0x40005470 0x00000 0x04c7c RW 0x10000&lt;/P&gt;&lt;P&gt;Section to Segment mapping:&lt;BR /&gt;Segment Sections...&lt;BR /&gt;00 .rcw .init .FlashProgram .FlashErase .FlashDriver .text .flash_data .rodata .isrvectbl .xcptn&lt;BR /&gt;&lt;STRONG&gt;01 .backupram .adapdata .data&lt;/STRONG&gt;&lt;BR /&gt;02 .ctors&lt;BR /&gt;03 calconst&lt;BR /&gt;04 .bss&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;Then after that 64 bit variable change I have these segments and these LOADs:&lt;/P&gt;&lt;P&gt;Program Headers:&lt;BR /&gt;Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align&lt;BR /&gt;LOAD 0x010000 0x00010000 0x00010000 0x34920 0x34920 R E 0x10000&lt;BR /&gt;LOAD 0x054010 0x40004010 &lt;STRONG&gt;0x00044920 0x0003c 0x0003c&lt;/STRONG&gt; RW 0x10000&lt;BR /&gt;LOAD 0x054050 0x40004050 &lt;STRONG&gt;0x0004495c 0x0141b 0x0141b&lt;/STRONG&gt; RW 0x10000&lt;BR /&gt;LOAD 0x05546c 0x4000546c 0x00045d77 0x0000c 0x0000c RW 0x10000&lt;BR /&gt;LOAD 0x060000 0x00080000 0x00080000 0x000b0 0x000b0 R 0x10000&lt;BR /&gt;LOAD 0x065478 0x40005478 0x40005478 0x00000 0x04c7c RW 0x10000&lt;/P&gt;&lt;P&gt;Section to Segment mapping:&lt;BR /&gt;Segment Sections...&lt;BR /&gt;00 .rcw .init .FlashProgram .FlashErase .FlashDriver .text .flash_data .rodata .isrvectbl .xcptn&lt;BR /&gt;01 .backupram .adapdata&lt;BR /&gt;&lt;STRONG&gt;02 .data&lt;/STRONG&gt;&lt;BR /&gt;03 .ctors&lt;BR /&gt;04 calconst&lt;BR /&gt;05 .bss&lt;/P&gt;&lt;P&gt;As you can see, the file size of the second load should has been increased by 8, should be 0x01456 and not 0x0003C.and the data must be in the second segment. if&amp;nbsp; I'm not wrong.&lt;/P&gt;&lt;P&gt;I&amp;nbsp;know that uninitialized global variable go to .bss segment, so I tried to uninitialize that variable (just for testing) and it worked fine.&lt;/P&gt;&lt;P&gt;my question:&lt;/P&gt;&lt;P&gt;why the program headers have been increased, and why the data segment split into two segments?&lt;/P&gt;&lt;P&gt;please feel free to correct me if I'm wrong.&lt;/P&gt;&lt;P&gt;any help is appreciated,&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Islem,&lt;/P&gt;</description>
      <pubDate>Wed, 12 Oct 2022 12:53:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MPC5xxx/Data-Segment-Split-Into-Two-Segments/m-p/1536213#M22152</guid>
      <dc:creator>ISLEMTRIKII</dc:creator>
      <dc:date>2022-10-12T12:53:43Z</dc:date>
    </item>
    <item>
      <title>Re: Data Segment Split Into Two Segments</title>
      <link>https://community.nxp.com/t5/MPC5xxx/Data-Segment-Split-Into-Two-Segments/m-p/1537212#M22159</link>
      <description>&lt;P&gt;&lt;EM&gt;Updates&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Initialized global/static variables values get allocated in .data segment it turned out that I have an alignment problem, in the beginning, the data section was 4 byte aligned, starting from the address&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;0x4000404c&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;:&lt;/P&gt;&lt;P&gt;[20] .data PROGBITS 4000404c 05404c 001413 00 WA 0 0&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;4&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;and then when I changed that variable,the alignment has became 8.&lt;/P&gt;&lt;P&gt;[20] .data PROGBITS&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;40004050&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;054050 00141b 00 WA 0 0&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;8&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Then the .data segment address (0x4000404c) has been shifted by 4 bytes, because of the alignment(&lt;STRONG&gt;0x40004050&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;mod 8 = 0 )&lt;/P&gt;&lt;P&gt;to be honest, I'm not an expert in memory alignment so I may be saying something wrong.&lt;/P&gt;&lt;P&gt;any help would be very appreciated!&lt;/P&gt;</description>
      <pubDate>Thu, 13 Oct 2022 15:05:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MPC5xxx/Data-Segment-Split-Into-Two-Segments/m-p/1537212#M22159</guid>
      <dc:creator>ISLEMTRIKII</dc:creator>
      <dc:date>2022-10-13T15:05:00Z</dc:date>
    </item>
    <item>
      <title>Re: Data Segment Split Into Two Segments</title>
      <link>https://community.nxp.com/t5/MPC5xxx/Data-Segment-Split-Into-Two-Segments/m-p/1540531#M22188</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;It seems that the split could be caused by placing 64bit variable into .data instead of small data/custom section.&lt;/P&gt;
&lt;P&gt;Could you post how you exactly declare the variable before and after?&lt;/P&gt;
&lt;P&gt;e.g.&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;unsigned int __attribute__ ((section(".backupram"))) var = 0x12341234;
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'd bet on alignment issues too... if RAM/VirtAddr address of .data section is not 8 Bytes aligned - this may lead to alignment exception when accessing the variable.&lt;/P&gt;
&lt;P&gt;Note:&lt;/P&gt;
&lt;P&gt;.bss/sbss sections does not require loading so they are typically defined as:&lt;/P&gt;
&lt;P&gt;.bss (NOLOAD):&lt;/P&gt;
&lt;P&gt;In order to better understand the issue the map fil would help here.&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Stan&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2022 22:50:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MPC5xxx/Data-Segment-Split-Into-Two-Segments/m-p/1540531#M22188</guid>
      <dc:creator>stanish</dc:creator>
      <dc:date>2022-10-19T22:50:13Z</dc:date>
    </item>
    <item>
      <title>Re: Data Segment Split Into Two Segments</title>
      <link>https://community.nxp.com/t5/MPC5xxx/Data-Segment-Split-Into-Two-Segments/m-p/1540961#M22191</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;First of all, thank you for your response.&lt;/P&gt;&lt;P&gt;I will write some updates as well and please correct me if I´m saying something wrong.&lt;/P&gt;&lt;P&gt;the variable before was a 32 bit variable.&lt;/P&gt;&lt;P&gt;unsigned int Var1 = 0;&lt;/P&gt;&lt;P&gt;void function (unsigned int var2 )&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;Var1 |= var2;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;and then I extended it :&lt;/P&gt;&lt;P&gt;unsigned long long Var1 = 0x0ULL;&lt;/P&gt;&lt;P&gt;void function (unsigned long long&amp;nbsp;var2 )&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;Var1 |= var2;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Alternatively, &lt;/SPAN&gt;&lt;STRONG&gt;the host can read/write the SPRAM by 8-, 16-, or 32-bit accesses in aligned addresses&lt;/STRONG&gt;&lt;SPAN&gt;.&amp;nbsp;(section 24.5.2.3&amp;nbsp;Parameter access, reference&amp;nbsp;manual MPC5644ARM).&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;While the compiler automatically sets the type alignment to the largest alignment that can ever be used for any data type on the target machine for which you are compiling, which is our extended variable (8 bytes) boundary, that's why during the compilation, 4 padding bytes were required to align the start of the data segment to perform that 8 bytes alignment. (this is my understanding).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;My conclusion:&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The (initialized ) global data variables are almost by definition in the data section, since the alignment was 4 bytes in the data section, and the VA is 4 bytes aligned, on the other hand, the host can read any 32 bits variable, and everything worked fine. Please find attached a screenshot:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="32 section header.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/197464i2B12EB0C5F5C1784/image-size/medium?v=v2&amp;amp;px=400" role="button" title="32 section header.png" alt="32 section header.png" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;32 section header.png&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; so the alignment was 4 boundaries.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="32 program header.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/197466i2A9143C3AA99E055/image-size/medium?v=v2&amp;amp;px=400" role="button" title="32 program header.png" alt="32 program header.png" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;32 program header.png&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN&gt;You can see that the small data sections are gathered together in the program header so single-instruction offsets can access them all.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;***************************************Then we extended that variable************************&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="header section 64 not fixed.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/197469iED2A3E9DC607537B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="header section 64 not fixed.png" alt="header section 64 not fixed.png" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;header section 64 not fixed.png&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN&gt;When we extended that global variable, that small data segment split into two, and I found that the VA of data section changed. a 4 bytes padding has been performed by the compiler to ensure the new alignment&amp;nbsp;(8 bytes boundaries).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="header section 64 not fixed.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/197473i6F14D4D5F82771E4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="header section 64 not fixed.png" alt="header section 64 not fixed.png" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;header section 64 not fixed.png&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt; T&lt;SPAN&gt;he compiler automatically sets the type alignment to the largest it can ever use for any data type.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;that's why that small data segment split into two:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="64 not fixed.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/197471i21D702FD9372B0BA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="64 not fixed.png" alt="64 not fixed.png" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;64 not fixed.png&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;and then , I tried to force that section to be 4 bytes aligned, to ensure that the access to that variable would be fine and no exception will occur, exactly like you said.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;.data &lt;STRONG&gt;ALIGN (4)&lt;/STRONG&gt;: AT (NEXT_LOAD_ADDR)&lt;BR /&gt;{&lt;BR /&gt;__DATASTART = . ;&lt;BR /&gt;*(.data)&lt;BR /&gt;*(.data.*)&lt;BR /&gt;*(.gnu.linkonce.d*)&lt;BR /&gt;CONSTRUCTORS&lt;BR /&gt;} &amp;gt; int_sram&lt;BR /&gt;NEXT_LOAD_ADDR = NEXT_LOAD_ADDR + SIZEOF(.data);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;and&amp;nbsp; the bug has been fixed :&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="section header fixed.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/197477i6F01B3DC51F101DC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="section header fixed.png" alt="section header fixed.png" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;section header fixed.png&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="fixed.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/197476i2E6DDAC3F6A405DC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="fixed.png" alt="fixed.png" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;fixed.png&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;  &lt;SPAN&gt;The size of the data section has also been increased by 4 bytes, 1413 - 4 (32 bits global variable) + 8 (64 bits global variable) = &lt;/SPAN&gt;&lt;STRONG&gt;1417 bytes&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;please correct me if I'm wrong, I have wrote everything to make sure we are on the same page and I'm not doing something wrong.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Thank you!&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2022 08:05:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MPC5xxx/Data-Segment-Split-Into-Two-Segments/m-p/1540961#M22191</guid>
      <dc:creator>ISLEMTRIKII</dc:creator>
      <dc:date>2022-10-20T08:05:08Z</dc:date>
    </item>
    <item>
      <title>Re: Data Segment Split Into Two Segments</title>
      <link>https://community.nxp.com/t5/MPC5xxx/Data-Segment-Split-Into-Two-Segments/m-p/1541075#M22193</link>
      <description>&lt;P&gt;I need also to add that this issue doesn't occur (by chance) when the data section address is divisible by 8 (I mean by 4 and 8 )&amp;nbsp;&lt;LI-EMOJI id="lia_smiling-face-with-sunglasses" title=":smiling_face_with_sunglasses:"&gt;&lt;/LI-EMOJI&gt; using that 64 bit global variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;Islem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2022 09:56:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MPC5xxx/Data-Segment-Split-Into-Two-Segments/m-p/1541075#M22193</guid>
      <dc:creator>ISLEMTRIKII</dc:creator>
      <dc:date>2022-10-20T09:56:07Z</dc:date>
    </item>
  </channel>
</rss>

