Compiler creates wrong additional bit shift operation.

Bug #1613280 reported by Dennis Pahl
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
GNU Arm Embedded Toolchain
Invalid
Undecided
Dennis Pahl

Bug Description

Hi,

I have a problem with the Compilers GCC 5.4_2016q2 and 5.2_2015q4.

In my system there exists a memory which has the size of a multiple of 2. The memory is aligned to a matching memory address. Right after the last address of the memory, the same memory is mapped in the address space again. So each variable in the memory can be accesses by adding the size of the memory to the address of the variable. This is used by the function below to detect the memory size.

The function writes a special pattern into a global variable. Afterwards a loop starts which checks if the address of the global variable plus the memory size contains the same pattern as the global variable. As long as the content isn't the same, the variable "memory size" is increased by 2 (left shift by 1).

Problem: The compiler creates binary code which performs an additional left shift by 2 for the content of variable "memory size".

So instead of performing:
  while (*(&u32ExternRamSizeDetectionVariable_g + u32MemSize_g) != u32ExternRamSizeDetectionVariable_g)

The generated program performs:
  while (*(&u32ExternRamSizeDetectionVariable_g + (u32MemSize_g<<2)) != u32ExternRamSizeDetectionVariable_g) //see list file line 80

Am I doing something wrong or am I missing something?

Dennis Pahl

----------------

Source Code:

#define OS_HW_MEM_ADDRESS_NULL 0x00000000
#define OS_HW_MEM_SIZE_64MB 0x04000000

typedef unsigned int INT32U;

static INT32U u32ExternRamSizeDetectionVariable_g;
static INT32U u32MemSize_g;
static INT32U u32MemEndAddress_g;

void vFindMemSize(void)
{

  u32MemSize_g = OS_HW_MEM_SIZE_64MB;

  //--------------------------------------------------------------
  // write test pattern
  //--------------------------------------------------------------
  u32ExternRamSizeDetectionVariable_g = 0x1234ABCD;

  //--------------------------------------------------------------
  // Double the memory size as long as the test pattern cannot be found.
  //--------------------------------------------------------------

  while (*(&u32ExternRamSizeDetectionVariable_g + u32MemSize_g) != u32ExternRamSizeDetectionVariable_g)
  {
    //set the memory size to the next multiple of 2
    u32MemSize_g = u32MemSize_g << 1;
  }

  u32MemEndAddress_g = OS_HW_MEM_ADDRESS_NULL + u32MemSize_g;
}

main()
{
  vFindMemSize();
}

------------------

The resulting list file:
   1 .cpu cortex-a9
   2 .fpu softvfp
   3 .eabi_attribute 20, 1
   4 .eabi_attribute 21, 1
   5 .eabi_attribute 23, 3
   6 .eabi_attribute 24, 1
   7 .eabi_attribute 25, 1
   8 .eabi_attribute 26, 1
   9 .eabi_attribute 30, 6
  10 .eabi_attribute 34, 1
  11 .eabi_attribute 18, 4
  12 .arm
  13 .syntax divided
  14 .file "main.c"
  15 .text
  16 .Ltext0:
  17 .cfi_sections .debug_frame
  18 .section .bss.u32ExternRamSizeDetectionVariable_g,"aw",%nobits
  19 .align 2
  22 u32ExternRamSizeDetectionVariable_g:
  23 0000 00000000 .space 4
  24 .section .bss.u32MemSize_g,"aw",%nobits
  25 .align 2
  28 u32MemSize_g:
  29 0000 00000000 .space 4
  30 .section .bss.u32MemEndAddress_g,"aw",%nobits
  31 .align 2
  34 u32MemEndAddress_g:
  35 0000 00000000 .space 4
  36 .section .text.vFindMemSize,"ax",%progbits
  37 .align 2
  38 .global vFindMemSize
  40 vFindMemSize:
  41 .LFB0:
  42 .file 1 "../main.c"
   1:../main.c **** /*
   2:../main.c **** * Copyright 2008 Pilz GmbH & Co KG.
   3:../main.c **** * All Rights Reserved.
   4:../main.c **** * PILZ PROPRIETARY/CONFIDENTIAL.
   5:../main.c **** *
   6:../main.c **** * $HeadURL: $
   7:../main.c **** * $Author: $
   8:../main.c **** * $Date: $
   9:../main.c **** * $Revision: $
  10:../main.c **** */
  11:../main.c ****
  12:../main.c **** #define OS_HW_MEM_ADDRESS_NULL 0x00000000
  13:../main.c **** #define OS_HW_MEM_SIZE_64MB 0x04000000
  14:../main.c ****
  15:../main.c **** typedef unsigned int INT32U;
  16:../main.c ****
  17:../main.c **** static INT32U u32ExternRamSizeDetectionVariable_g;
  18:../main.c **** static INT32U u32MemSize_g;
  19:../main.c **** static INT32U u32MemEndAddress_g;
  20:../main.c ****
  21:../main.c **** void vFindMemSize(void)
  22:../main.c **** {
  43 .loc 1 22 0
  44 .cfi_startproc
  45 @ args = 0, pretend = 0, frame = 0
  46 @ frame_needed = 1, uses_anonymous_args = 0
  47 @ link register save eliminated.
  48 0000 04B02DE5 str fp, [sp, #-4]!
  49 .cfi_def_cfa_offset 4
  50 .cfi_offset 11, -4
  51 0004 00B08DE2 add fp, sp, #0
  52 .cfi_def_cfa_register 11
  23:../main.c ****
  24:../main.c **** u32MemSize_g = OS_HW_MEM_SIZE_64MB;
  53 .loc 1 24 0
  54 0008 003000E3 movw r3, #:lower16:u32MemSize_g
  55 000c 003040E3 movt r3, #:upper16:u32MemSize_g
  56 0010 0123A0E3 mov r2, #67108864
  57 0014 002083E5 str r2, [r3]
  25:../main.c ****
  26:../main.c **** //--------------------------------------------------------------
  27:../main.c **** // write test pattern
  28:../main.c **** //--------------------------------------------------------------
  29:../main.c **** u32ExternRamSizeDetectionVariable_g = 0x1234ABCD;
  58 .loc 1 29 0
  59 0018 002000E3 movw r2, #:lower16:u32ExternRamSizeDetectionVariable_g
  60 001c 002040E3 movt r2, #:upper16:u32ExternRamSizeDetectionVariable_g
  61 0020 CD3B0AE3 movw r3, #43981
  62 0024 343241E3 movt r3, 4660
  63 0028 003082E5 str r3, [r2]
  30:../main.c ****
  31:../main.c **** //--------------------------------------------------------------
  32:../main.c **** // Double the memory size as long as the test pattern cannot be found.
  33:../main.c **** //--------------------------------------------------------------
  34:../main.c ****
  35:../main.c **** while (*(&u32ExternRamSizeDetectionVariable_g + u32MemSize_g) != u32ExternRamSizeDetectionVariabl
  64 .loc 1 35 0
  65 002c 060000EA b .L2
  66 .L3:
  36:../main.c **** {
  37:../main.c **** //set the memory size to the next multiple of 2
  38:../main.c **** u32MemSize_g = u32MemSize_g << 1;
  67 .loc 1 38 0
  68 0030 003000E3 movw r3, #:lower16:u32MemSize_g
  69 0034 003040E3 movt r3, #:upper16:u32MemSize_g
  70 0038 003093E5 ldr r3, [r3]
  71 003c 8320A0E1 mov r2, r3, asl #1
  72 0040 003000E3 movw r3, #:lower16:u32MemSize_g
  73 0044 003040E3 movt r3, #:upper16:u32MemSize_g
  74 0048 002083E5 str r2, [r3]
  75 .L2:
  35:../main.c **** {
  76 .loc 1 35 0
  77 004c 003000E3 movw r3, #:lower16:u32MemSize_g
  78 0050 003040E3 movt r3, #:upper16:u32MemSize_g
  79 0054 003093E5 ldr r3, [r3]
  80 0058 0321A0E1 mov r2, r3, asl #2
  81 005c 003000E3 movw r3, #:lower16:u32ExternRamSizeDetectionVariable_g
  82 0060 003040E3 movt r3, #:upper16:u32ExternRamSizeDetectionVariable_g
  83 0064 033082E0 add r3, r2, r3
  84 0068 002093E5 ldr r2, [r3]
  85 006c 003000E3 movw r3, #:lower16:u32ExternRamSizeDetectionVariable_g
  86 0070 003040E3 movt r3, #:upper16:u32ExternRamSizeDetectionVariable_g
  87 0074 003093E5 ldr r3, [r3]
  88 0078 030052E1 cmp r2, r3
  89 007c EBFFFF1A bne .L3
  39:../main.c **** }
  40:../main.c ****
  41:../main.c **** u32MemEndAddress_g = OS_HW_MEM_ADDRESS_NULL + u32MemSize_g;
  90 .loc 1 41 0
  91 0080 003000E3 movw r3, #:lower16:u32MemSize_g
  92 0084 003040E3 movt r3, #:upper16:u32MemSize_g
  93 0088 002093E5 ldr r2, [r3]
  94 008c 003000E3 movw r3, #:lower16:u32MemEndAddress_g
  95 0090 003040E3 movt r3, #:upper16:u32MemEndAddress_g
  96 0094 002083E5 str r2, [r3]
  42:../main.c **** }
  97 .loc 1 42 0
  98 0098 0000A0E1 mov r0, r0 @ nop
  99 009c 00D04BE2 sub sp, fp, #0
 100 .cfi_def_cfa_register 13
 101 @ sp needed
 102 00a0 04B09DE4 ldr fp, [sp], #4
 103 .cfi_restore 11
 104 .cfi_def_cfa_offset 0
 105 00a4 1EFF2FE1 bx lr
 106 .cfi_endproc
 107 .LFE0:
 109 .section .text.main,"ax",%progbits
 110 .align 2
 111 .global main
 113 main:
 114 .LFB1:
  43:../main.c ****
  44:../main.c **** main()
  45:../main.c **** {
 115 .loc 1 45 0
 116 .cfi_startproc
 117 @ args = 0, pretend = 0, frame = 0
 118 @ frame_needed = 1, uses_anonymous_args = 0
 119 0000 00482DE9 stmfd sp!, {fp, lr}
 120 .cfi_def_cfa_offset 8
 121 .cfi_offset 11, -8
 122 .cfi_offset 14, -4
 123 0004 04B08DE2 add fp, sp, #4
 124 .cfi_def_cfa 11, 4
  46:../main.c **** vFindMemSize();
 125 .loc 1 46 0
 126 0008 FEFFFFEB bl vFindMemSize
 127 000c 0030A0E3 mov r3, #0
  47:../main.c **** }
 128 .loc 1 47 0
 129 0010 0300A0E1 mov r0, r3
 130 0014 0088BDE8 ldmfd sp!, {fp, pc}
 131 .cfi_endproc
 132 .LFE1:
 134 .text
 135 .Letext0:
DEFINED SYMBOLS
                            *ABS*:00000000 main.c
  R:\TEMP\ccC3boEG.s:19 .bss.u32ExternRamSizeDetectionVariable_g:00000000 $d
  R:\TEMP\ccC3boEG.s:22 .bss.u32ExternRamSizeDetectionVariable_g:00000000 u32ExternRamSizeDetectionVariable_g
  R:\TEMP\ccC3boEG.s:25 .bss.u32MemSize_g:00000000 $d
  R:\TEMP\ccC3boEG.s:28 .bss.u32MemSize_g:00000000 u32MemSize_g
  R:\TEMP\ccC3boEG.s:31 .bss.u32MemEndAddress_g:00000000 $d
  R:\TEMP\ccC3boEG.s:34 .bss.u32MemEndAddress_g:00000000 u32MemEndAddress_g
  R:\TEMP\ccC3boEG.s:37 .text.vFindMemSize:00000000 $a
  R:\TEMP\ccC3boEG.s:40 .text.vFindMemSize:00000000 vFindMemSize
  R:\TEMP\ccC3boEG.s:110 .text.main:00000000 $a
  R:\TEMP\ccC3boEG.s:113 .text.main:00000000 main
                     .debug_frame:00000010 $d
                           .group:00000000 wm4.0.021b0358114c12e9fa080483d4019add

NO UNDEFINED SYMBOLS

------

- release version GCC 5.4_2016q2
- binary package
- x86 Windows 10

------

14:54:13 **** Build of configuration Debug for project BitShiftError ****
make all
Building file: ../main.c
Invoking: Cross ARM C Compiler
arm-none-eabi-gcc -mcpu=cortex-a9 -march=armv7-a -O0 -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -g3 -std=gnu11 -Wa,-adhlns="main.o.lst" -v --specs=nosys.specs -MMD -MP -MF"main.d" -MT"main.o" -c -o "main.o" "../main.c"
Using built-in specs.
Reading specs from c:/compiler/gnu_tools_arm_embedded/5.4_2016q2/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/lib/nosys.specs
rename spec link_gcc_c_sequence to nosys_link_gcc_c_sequence
COLLECT_GCC=arm-none-eabi-gcc
Target: arm-none-eabi
Configured with: /home/build/work/GCC-5-0-build/src/gcc/configure --build=i686-linux-gnu --host=i686-w64-mingw32 --target=arm-none-eabi --prefix=/home/build/work/GCC-5-0-build/install-mingw --libexecdir=/home/build/work/GCC-5-0-build/install-mingw/lib --infodir=/home/build/work/GCC-5-0-build/install-mingw/share/doc/gcc-arm-none-eabi/info --mandir=/home/build/work/GCC-5-0-build/install-mingw/share/doc/gcc-arm-none-eabi/man --htmldir=/home/build/work/GCC-5-0-build/install-mingw/share/doc/gcc-arm-none-eabi/html --pdfdir=/home/build/work/GCC-5-0-build/install-mingw/share/doc/gcc-arm-none-eabi/pdf --enable-languages=c,c++ --disable-decimal-float --disable-libffi --disable-libgomp --disable-libmudflap --disable-libquadmath --disable-libssp --disable-libstdcxx-pch --disable-nls --disable-shared --disable-threads --disable-tls --with-gnu-as --with-gnu-ld --with-headers=yes --with-newlib --with-python-dir=share/gcc-arm-none-eabi --with-sysroot=/home/build/work/GCC-5-0-build/install-mingw/arm-none-eabi --with-libiconv-prefix=/home/build/work/GCC-5-0-build/build-mingw/host-libs/usr --with-gmp=/home/build/work/GCC-5-0-build/build-mingw/host-libs/usr --with-mpfr=/home/build/work/GCC-5-0-build/build-mingw/host-libs/usr --with-mpc=/home/build/work/GCC-5-0-build/build-mingw/host-libs/usr --with-isl=/home/build/work/GCC-5-0-build/build-mingw/host-libs/usr --with-cloog=/home/build/work/GCC-5-0-build/build-mingw/host-libs/usr --with-libelf=/home/build/work/GCC-5-0-build/build-mingw/host-libs/usr --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --with-pkgversion='GNU Tools for ARM Embedded Processors' --with-multilib-list=armv6-m,armv7-m,armv7e-m,armv7-r,armv8-m.base,armv8-m.main
Thread model: single
gcc version 5.4.1 20160609 (release) [ARM/embedded-5-branch revision 237715] (GNU Tools for ARM Embedded Processors)
COLLECT_GCC_OPTIONS='-mcpu=cortex-a9' '-march=armv7-a' '-O0' '-fmessage-length=0' '-fsigned-char' '-ffunction-sections' '-fdata-sections' '-g3' '-std=gnu11' '-v' '-specs=nosys.specs' '-MMD' '-MP' '-MF' 'main.d' '-MT' 'main.o' '-c' '-o' 'main.o'
 c:/compiler/gnu_tools_arm_embedded/5.4_2016q2/bin/../lib/gcc/arm-none-eabi/5.4.1/cc1.exe -quiet -v -imultilib armv7-ar/thumb -iprefix c:\compiler\gnu_tools_arm_embedded\5.4_2016q2\bin\../lib/gcc/arm-none-eabi/5.4.1/ -isysroot c:\compiler\gnu_tools_arm_embedded\5.4_2016q2\bin\../arm-none-eabi -MMD main.d -MF main.d -MP -MT main.o -dD -D__USES_INITFINI__ ../main.c -quiet -dumpbase main.c -mcpu=cortex-a9 -march=armv7-a -auxbase-strip main.o -g3 -O0 -std=gnu11 -version -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -o R:\TEMP\ccpVLh9h.s
GNU C11 (GNU Tools for ARM Embedded Processors) version 5.4.1 20160609 (release) [ARM/embedded-5-branch revision 237715] (arm-none-eabi)
 compiled by GNU C version 4.7.4, GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring duplicate directory "c:/compiler/gnu_tools_arm_embedded/5.4_2016q2/lib/gcc/../../lib/gcc/arm-none-eabi/5.4.1/include"
ignoring nonexistent directory "c:\compiler\gnu_tools_arm_embedded\5.4_2016q2\bin\../arm-none-eabi/home/build/work/GCC-5-0-build/install-mingw/lib/gcc/arm-none-eabi/5.4.1/../../../../include"
ignoring duplicate directory "c:/compiler/gnu_tools_arm_embedded/5.4_2016q2/lib/gcc/../../lib/gcc/arm-none-eabi/5.4.1/include-fixed"
ignoring duplicate directory "c:/compiler/gnu_tools_arm_embedded/5.4_2016q2/lib/gcc/../../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/include"
ignoring nonexistent directory "c:\compiler\gnu_tools_arm_embedded\5.4_2016q2\bin\../arm-none-eabi/usr/include"
#include "..." search starts here:
#include <...> search starts here:
 c:\compiler\gnu_tools_arm_embedded\5.4_2016q2\bin\../lib/gcc/arm-none-eabi/5.4.1/include
 c:\compiler\gnu_tools_arm_embedded\5.4_2016q2\bin\../lib/gcc/arm-none-eabi/5.4.1/include-fixed
 c:\compiler\gnu_tools_arm_embedded\5.4_2016q2\bin\../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/include
End of search list.
GNU C11 (GNU Tools for ARM Embedded Processors) version 5.4.1 20160609 (release) [ARM/embedded-5-branch revision 237715] (arm-none-eabi)
 compiled by GNU C version 4.7.4, GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 7f99c11e705642eec0b1caee8fad3a95
../main.c:44:1: warning: return type defaults to 'int' [-Wimplicit-int]
 main()
 ^
COLLECT_GCC_OPTIONS='-mcpu=cortex-a9' '-march=armv7-a' '-O0' '-fmessage-length=0' '-fsigned-char' '-ffunction-sections' '-fdata-sections' '-g3' '-std=gnu11' '-v' '-specs=nosys.specs' '-MMD' '-MP' '-MF' 'main.d' '-MT' 'main.o' '-c' '-o' 'main.o'
 c:/compiler/gnu_tools_arm_embedded/5.4_2016q2/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/as.exe -v -march=armv7-a -mcpu=cortex-a9 -meabi=5 -adhlns=main.o.lst -o main.o R:\TEMP\ccpVLh9h.s
GNU assembler version 2.26.0 (arm-none-eabi) using BFD version (GNU Tools for ARM Embedded Processors) 2.26.0.20160616
COMPILER_PATH=c:/compiler/gnu_tools_arm_embedded/5.4_2016q2/bin/../lib/gcc/arm-none-eabi/5.4.1/;c:/compiler/gnu_tools_arm_embedded/5.4_2016q2/bin/../lib/gcc/;c:/compiler/gnu_tools_arm_embedded/5.4_2016q2/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/
LIBRARY_PATH=c:/compiler/gnu_tools_arm_embedded/5.4_2016q2/bin/../lib/gcc/arm-none-eabi/5.4.1/armv7-ar/thumb/;c:/compiler/gnu_tools_arm_embedded/5.4_2016q2/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/lib/armv7-ar/thumb/;c:/compiler/gnu_tools_arm_embedded/5.4_2016q2/bin/../arm-none-eabi/lib/armv7-ar/thumb/;c:/compiler/gnu_tools_arm_embedded/5.4_2016q2/bin/../lib/gcc/arm-none-eabi/5.4.1/;c:/compiler/gnu_tools_arm_embedded/5.4_2016q2/bin/../lib/gcc/;c:/compiler/gnu_tools_arm_embedded/5.4_2016q2/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/lib/;c:/compiler/gnu_tools_arm_embedded/5.4_2016q2/bin/../arm-none-eabi/lib/
COLLECT_GCC_OPTIONS='-mcpu=cortex-a9' '-march=armv7-a' '-O0' '-fmessage-length=0' '-fsigned-char' '-ffunction-sections' '-fdata-sections' '-g3' '-std=gnu11' '-v' '-specs=nosys.specs' '-MMD' '-MP' '-MF' 'main.d' '-MT' 'main.o' '-c' '-o' 'main.o'
Finished building: ../main.c

Building target: BitShiftError.elf
Invoking: Cross ARM C Linker
arm-none-eabi-gcc -mcpu=cortex-a9 -march=armv7-a -O0 -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -g3 -Xlinker --gc-sections -Wl,-Map,"BitShiftError.map" -v --specs=nosys.specs -o "BitShiftError.elf" ./main.o
Using built-in specs.
Reading specs from c:/compiler/gnu_tools_arm_embedded/5.4_2016q2/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/lib/nosys.specs
rename spec link_gcc_c_sequence to nosys_link_gcc_c_sequence
COLLECT_GCC=arm-none-eabi-gcc
COLLECT_LTO_WRAPPER=c:/compiler/gnu_tools_arm_embedded/5.4_2016q2/bin/../lib/gcc/arm-none-eabi/5.4.1/lto-wrapper.exe
Target: arm-none-eabi
Configured with: /home/build/work/GCC-5-0-build/src/gcc/configure --build=i686-linux-gnu --host=i686-w64-mingw32 --target=arm-none-eabi --prefix=/home/build/work/GCC-5-0-build/install-mingw --libexecdir=/home/build/work/GCC-5-0-build/install-mingw/lib --infodir=/home/build/work/GCC-5-0-build/install-mingw/share/doc/gcc-arm-none-eabi/info --mandir=/home/build/work/GCC-5-0-build/install-mingw/share/doc/gcc-arm-none-eabi/man --htmldir=/home/build/work/GCC-5-0-build/install-mingw/share/doc/gcc-arm-none-eabi/html --pdfdir=/home/build/work/GCC-5-0-build/install-mingw/share/doc/gcc-arm-none-eabi/pdf --enable-languages=c,c++ --disable-decimal-float --disable-libffi --disable-libgomp --disable-libmudflap --disable-libquadmath --disable-libssp --disable-libstdcxx-pch --disable-nls --disable-shared --disable-threads --disable-tls --with-gnu-as --with-gnu-ld --with-headers=yes --with-newlib --with-python-dir=share/gcc-arm-none-eabi --with-sysroot=/home/build/work/GCC-5-0-build/install-mingw/arm-none-eabi --with-libiconv-prefix=/home/build/work/GCC-5-0-build/build-mingw/host-libs/usr --with-gmp=/home/build/work/GCC-5-0-build/build-mingw/host-libs/usr --with-mpfr=/home/build/work/GCC-5-0-build/build-mingw/host-libs/usr --with-mpc=/home/build/work/GCC-5-0-build/build-mingw/host-libs/usr --with-isl=/home/build/work/GCC-5-0-build/build-mingw/host-libs/usr --with-cloog=/home/build/work/GCC-5-0-build/build-mingw/host-libs/usr --with-libelf=/home/build/work/GCC-5-0-build/build-mingw/host-libs/usr --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --with-pkgversion='GNU Tools for ARM Embedded Processors' --with-multilib-list=armv6-m,armv7-m,armv7e-m,armv7-r,armv8-m.base,armv8-m.main
Thread model: single
gcc version 5.4.1 20160609 (release) [ARM/embedded-5-branch revision 237715] (GNU Tools for ARM Embedded Processors)
COMPILER_PATH=c:/compiler/gnu_tools_arm_embedded/5.4_2016q2/bin/../lib/gcc/arm-none-eabi/5.4.1/;c:/compiler/gnu_tools_arm_embedded/5.4_2016q2/bin/../lib/gcc/;c:/compiler/gnu_tools_arm_embedded/5.4_2016q2/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/
LIBRARY_PATH=c:/compiler/gnu_tools_arm_embedded/5.4_2016q2/bin/../lib/gcc/arm-none-eabi/5.4.1/armv7-ar/thumb/;c:/compiler/gnu_tools_arm_embedded/5.4_2016q2/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/lib/armv7-ar/thumb/;c:/compiler/gnu_tools_arm_embedded/5.4_2016q2/bin/../arm-none-eabi/lib/armv7-ar/thumb/;c:/compiler/gnu_tools_arm_embedded/5.4_2016q2/bin/../lib/gcc/arm-none-eabi/5.4.1/;c:/compiler/gnu_tools_arm_embedded/5.4_2016q2/bin/../lib/gcc/;c:/compiler/gnu_tools_arm_embedded/5.4_2016q2/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/lib/;c:/compiler/gnu_tools_arm_embedded/5.4_2016q2/bin/../arm-none-eabi/lib/
COLLECT_GCC_OPTIONS='-mcpu=cortex-a9' '-march=armv7-a' '-O0' '-fmessage-length=0' '-fsigned-char' '-ffunction-sections' '-fdata-sections' '-g3' '-v' '-specs=nosys.specs' '-o' 'BitShiftError.elf'
 c:/compiler/gnu_tools_arm_embedded/5.4_2016q2/bin/../lib/gcc/arm-none-eabi/5.4.1/collect2.exe -plugin c:/compiler/gnu_tools_arm_embedded/5.4_2016q2/bin/../lib/gcc/arm-none-eabi/5.4.1/liblto_plugin-0.dll -plugin-opt=c:/compiler/gnu_tools_arm_embedded/5.4_2016q2/bin/../lib/gcc/arm-none-eabi/5.4.1/lto-wrapper.exe -plugin-opt=-fresolution=R:\TEMP\cc6avl9k.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lg -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lnosys --sysroot=c:\compiler\gnu_tools_arm_embedded\5.4_2016q2\bin\../arm-none-eabi -X -o BitShiftError.elf c:/compiler/gnu_tools_arm_embedded/5.4_2016q2/bin/../lib/gcc/arm-none-eabi/5.4.1/armv7-ar/thumb/crti.o c:/compiler/gnu_tools_arm_embedded/5.4_2016q2/bin/../lib/gcc/arm-none-eabi/5.4.1/armv7-ar/thumb/crtbegin.o c:/compiler/gnu_tools_arm_embedded/5.4_2016q2/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/lib/armv7-ar/thumb/crt0.o -Lc:/compiler/gnu_tools_arm_embedded/5.4_2016q2/bin/../lib/gcc/arm-none-eabi/5.4.1/armv7-ar/thumb -Lc:/compiler/gnu_tools_arm_embedded/5.4_2016q2/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/lib/armv7-ar/thumb -Lc:/compiler/gnu_tools_arm_embedded/5.4_2016q2/bin/../arm-none-eabi/lib/armv7-ar/thumb -Lc:/compiler/gnu_tools_arm_embedded/5.4_2016q2/bin/../lib/gcc/arm-none-eabi/5.4.1 -Lc:/compiler/gnu_tools_arm_embedded/5.4_2016q2/bin/../lib/gcc -Lc:/compiler/gnu_tools_arm_embedded/5.4_2016q2/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/lib -Lc:/compiler/gnu_tools_arm_embedded/5.4_2016q2/bin/../arm-none-eabi/lib --gc-sections -Map BitShiftError.map ./main.o --start-group -lgcc -lg -lc --end-group --start-group -lgcc -lc -lnosys --end-group c:/compiler/gnu_tools_arm_embedded/5.4_2016q2/bin/../lib/gcc/arm-none-eabi/5.4.1/armv7-ar/thumb/crtend.o c:/compiler/gnu_tools_arm_embedded/5.4_2016q2/bin/../lib/gcc/arm-none-eabi/5.4.1/armv7-ar/thumb/crtn.o
Finished building target: BitShiftError.elf

Invoking: Cross ARM GNU Create Flash Image
arm-none-eabi-objcopy -O ihex "BitShiftError.elf" "BitShiftError.hex"
Finished building: BitShiftError.hex

Invoking: Cross ARM GNU Print Size
arm-none-eabi-size --format=berkeley "BitShiftError.elf"
   text data bss dec hex filename
   1232 1080 40 2352 930 BitShiftError.elf
Finished building: BitShiftError.siz

14:54:14 Build Finished (took 576ms)

Revision history for this message
Dennis Pahl (d-pahl) wrote :
Revision history for this message
Dennis Pahl (d-pahl) wrote :
Revision history for this message
Tejas Belagod (belagod-tejas) wrote :

&u32ExternRamSizeDetectionVariable_g + u32MemSize_g

is doing pointer arithmetic. You will need to cast the & to an unsigned int and then do the addition.

(*(unsigned int)(&u32ExternRamSizeDetectionVariable_g) + u32MemSize_g)

Revision history for this message
Dennis Pahl (d-pahl) wrote :

Missed the pointer arithmetic which was happening. Therefore the additional shift was correct. Thanks Tejas Belagod for your answer.

Changed in gcc-arm-embedded:
assignee: nobody → Dennis Pahl (d-pahl)
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.