[Bug c/67223] New: Address misaligned for ldrexd

2015-08-14 Thread soldier.kam at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67223

Bug ID: 67223
   Summary: Address misaligned for ldrexd
   Product: gcc
   Version: 5.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: soldier.kam at gmail dot com
  Target Milestone: ---

Hi!
I compiled wrk (https://github.com/wg/wrk) for odroid-c1. Binary runs but cause
bus error. I thought that it is caused by ldrexd that requires address to be
doubleword aligned but it is not - it is 0xb5c3103c. See below for details.

In dmesg I found: 
"Alignment trap: wrk (19927) PC=0x00017494 Instr=0xe1b14f9f Address=0xb5c3212c
FSR 0x001"

GDBs "show registers":
r0 0x1e8481 201
r1 0xb5c3103c   3049459772
r2 0x1  1
r3 0x0  0
r4 0x16378  91000
r5 0xbefffa08   3204446728
r6 0x0  0
r7 0x152338
r8 0xbefffa08   3204446728
r9 0x0  0
r100xb6ff94c0   3070203072
r110xb0f85cfc   2969066748
r120xb5c3000c   3049455628
sp 0xb0f85cd0   0xb0f85cd0
lr 0x15fcc  90060
pc 0x17494  0x17494 
cpsr   0x200b0010   537591824

Assembler for this function:
00017440 :
   17440:   e92d4830push{r4, r5, fp, lr}
   17444:   e28db00cadd fp, sp, #12
   17448:   e24dd020sub sp, sp, #32
   1744c:   e50b0020str r0, [fp, #-32]  ; 0xffe0
   17450:   e14b22fcstrdr2, [fp, #-44]  ; 0xffd4
   17454:   e51b3020ldr r3, [fp, #-32]  ; 0xffe0
   17458:   e1c300d8ldrdr0, [r3, #8]
   1745c:   e14b22dcldrdr2, [fp, #-44]  ; 0xffd4
   17460:   e1510003cmp r1, r3
   17464:   0152cmpeq   r0, r2
   17468:   8a01bhi 17474 
   1746c:   e3a03000mov r3, #0
   17470:   ea48b   17598 
   17474:   e51b302cldr r3, [fp, #-44]  ; 0xffd4
   17478:   e2833004add r3, r3, #4
   1747c:   e1a03183lsl r3, r3, #3
   17480:   e51b2020ldr r2, [fp, #-32]  ; 0xffe0
   17484:   e0821003add r1, r2, r3
   17488:   e3a02001mov r2, #1
   1748c:   e3a03000mov r3, #0
   17490:   f57ff05fdmb sy
   17494:   e1b14f9fldrexd  r4, [r1]
   17498:   e0944002addsr4, r4, r2
   1749c:   e0a55003adc r5, r5, r3
   174a0:   e1a10f94strexd  r0, r4, [r1]
   174a4:   e350cmp r0, #0
   174a8:   1af9bne 17494 
   174ac:   f57ff05fdmb sy
   174b0:   e51b1020ldr r1, [fp, #-32]  ; 0xffe0
   174b4:   e3a02001mov r2, #1
   174b8:   e3a03000mov r3, #0
   174bc:   f57ff05fdmb sy
   174c0:   e1b14f9fldrexd  r4, [r1]
   174c4:   e0944002addsr4, r4, r2
   174c8:   e0a55003adc r5, r5, r3
   174cc:   e1a10f94strexd  r0, r4, [r1]
   174d0:   e350cmp r0, #0
   174d4:   1af9bne 174c0 
   ...

Output "gcc -v":
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/armv7l-unknown-linux-gnueabihf/5.2.0/lto-wrapper
Target: armv7l-unknown-linux-gnueabihf
Configured with: /build/gcc/src/gcc-5.2.0/configure --prefix=/usr
--libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man
--infodir=/usr/share/info
--with-bugurl=https://github.com/archlinuxarm/PKGBUILDs/issues
--enable-languages=c,c++,fortran,go,lto,objc,obj-c++ --enable-shared
--enable-threads=posix --with-system-zlib --with-isl --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch
--disable-libssp --enable-gnu-unique-object --enable-linker-build-id
--enable-lto --enable-plugin --enable-install-libiberty
--with-linker-hash-style=gnu --enable-gnu-indirect-function --disable-multilib
--disable-werror --enable-checking=release
--with-default-libstdcxx-abi=gcc4-compatible
--host=armv7l-unknown-linux-gnueabihf --build=armv7l-unknown-linux-gnueabihf
--with-arch=armv7-a --with-float=hard --with-fpu=vfpv3-d16
Thread model: posix
gcc version 5.2.0 (GCC)


[Bug target/67223] Address misaligned for ldrexd

2015-08-15 Thread soldier.kam at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67223

Marcin Kamionowski  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |INVALID

--- Comment #2 from Marcin Kamionowski  ---
Yes, you are correct about misaligned address returned from zmalloc. Now it
works without errors. Thank you for helping out. I was not aware of zmalloc
features.