[Bug target/78397] The stack is not 8 bytes aligned on ARM

2017-01-13 Thread alexandre.martins at stormshield dot eu
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78397

--- Comment #4 from Alexandre Martins  
---
Unfortunatly, it's not crashing into the __aeabi_read_tp function, but into the
dynamic linker of freebsd (rtld-elf). For info, this function is located into
the libc on freebsd.

Must the dynamic linker assume the stack can be miss aligned and re-align it if
the function called is a 'public interface' ?

[Bug target/78397] The stack is not 8 bytes aligned on ARM

2016-11-17 Thread alexandre.martins at stormshield dot eu
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78397

Alexandre Martins  changed:

   What|Removed |Added

 CC||alexandre.martins@stormshie
   ||ld.eu

--- Comment #2 from Alexandre Martins  
---
Created attachment 40069
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=40069&action=edit
proposed patch

When trying to fix this bug, I made this patch. Hope it help ...

[Bug target/78397] The stack is not 8 bytes aligned on ARM

2016-11-17 Thread alexandre.martins at stormshield dot eu
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78397

--- Comment #1 from Alexandre Martins  
---
Created attachment 40068
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=40068&action=edit
Demo generated assembly

[Bug target/78397] New: The stack is not 8 bytes aligned on ARM

2016-11-17 Thread alexandre.martins at stormshield dot eu
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78397

Bug ID: 78397
   Summary: The stack is not 8 bytes aligned on ARM
   Product: gcc
   Version: 5.4.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: target
  Assignee: unassigned at gcc dot gnu.org
  Reporter: alexandre.martins at stormshield dot eu
  Target Milestone: ---
  Host: armv5te
Target: armv5te
 Build: armv5te

Created attachment 40067
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=40067&action=edit
Demo C file to reproduce the bug

Greetings

I'm currently developing on an ARMv5te platform on FreeBSD 10.3. I'm mixing
code compiled by clang 3.4 (libc, rtld, ...) and by gcc 5.4.0 (my program).

Time to time, an assertion in the rtld of FreeBSD warn us that a lock is not in
a consistent state. The lock is stored on the stack, so I suspect stack
corruption.

After few hours of digging, I see that clang assume that the stack is 8 bytes
aligned (as
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.faqs/ka4127.html
say) and perform some optimisations (?) on pointer computations. In my problem,
too add 4 to an address supposed to be 8 bytes aligned, clang produce : "orr
r0, r0, #4". It's working well when the stack is 8 bytes aligned, but not when
it's 4 bytes aligned.

Unfortunately, some of my code, when compiled with GCC and optimised, unalign
the stack. You will find the source code and the assembly in attached file.