https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51628

W.H. Ding <dingcurie at icloud dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dingcurie at icloud dot com

--- Comment #47 from W.H. Ding <dingcurie at icloud dot com> ---
Hi, everyone

I wonder if this issue has to do with the bug-like problem I encountered when
accessing an unaligned stand-alone global variable (rather than a member of a
packed struct). A test case is as follows:

char g_c = 'x';
int g_d __attribute__((aligned(1))) = 13;

int main(void)
{
    g_c = 'z';
    //================
    g_d = 33;                // Crash on, in my case, ARM Cortex-M0
    //================
    return 0;
}

Due to the presence of g_c, g_d is at an odd address, as the map file
indicates:

 .data.g_c      0x20000020        0x1 ./src/test.o
                0x20000020                g_c
 .data.g_d      0x20000021        0x4 ./src/test.o
                0x20000021                g_d

The generated assembly, however, accesses g_d as if it were properly aligned:

   8:../src/test.c ****     //================
   9:../src/test.c ****     g_d = 33;
  52                            .loc 1 9 0
  53 000a 044B                  ldr     r3, .L2+4
  54 000c 2122                  movs    r2, #33
  55 000e 1A60                  str     r2, [r3]
  10:../src/test.c ****     //================

BTW: I'm using GNU ARM Embedded Toolchain 7-2017-q4-major and on Windows 7.

Any ideas?

Reply via email to