Bug 63461 - Inconsistent behaviour on ARM64 when inline assembly with .text directive is followed by a static variable
Summary: Inconsistent behaviour on ARM64 when inline assembly with .text directive is ...
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.8.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-10-05 15:24 UTC by Akos Kiss
Modified: 2014-10-06 08:08 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Example C source code (115 bytes, text/plain)
2014-10-05 15:25 UTC, Akos Kiss
Details
Preprocessed source (150 bytes, text/plain)
2014-10-05 15:26 UTC, Akos Kiss
Details
Assembly output (173 bytes, text/plain)
2014-10-05 15:26 UTC, Akos Kiss
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Akos Kiss 2014-10-05 15:24:34 UTC
On ARM64/Ubuntu 14.04.1 with the stock gcc (Ubuntu/Linaro 4.8.2-19ubuntu1) I've experienced the following: 

First, I wrote a macro with inline assembly containing a .text directive followed by a static variable (still in the macro). Then, I expanded that macro multiple times. The generated assembly output contains a .data directive before the first variable declaration but not afterwards.

This caused problems with dynamically linking shared libraries in WebKit (https://bugs.webkit.org/show_bug.cgi?id=137434).


gcc details:

Target: aarch64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.8.2-19ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudflap --disable-libitm --disable-libsanitizer --disable-libquadmath --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-arm64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-arm64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-arm64 --with-arch-directory=arm64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-multiarch --disable-werror --enable-checking=release --build=aarch64-linux-gnu --host=aarch64-linux-gnu --target=aarch64-linux-gnu
Thread model: posix
gcc version 4.8.2 (Ubuntu/Linaro 4.8.2-19ubuntu1)
Comment 1 Akos Kiss 2014-10-05 15:25:53 UTC
Created attachment 33649 [details]
Example C source code
Comment 2 Akos Kiss 2014-10-05 15:26:21 UTC
Created attachment 33650 [details]
Preprocessed source
Comment 3 Akos Kiss 2014-10-05 15:26:46 UTC
Created attachment 33651 [details]
Assembly output
Comment 4 Andreas Schwab 2014-10-05 15:33:45 UTC
Don't do that then.  Switching sections behind the compiler's back is undefined.
Comment 5 Mikael Pettersson 2014-10-05 15:45:06 UTC
Use .pushsection and .popsection .
Comment 6 Akos Kiss 2014-10-06 08:08:39 UTC
Thanks for the feedback!