From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 64461 invoked by alias); 13 Mar 2015 12:24:56 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 64423 invoked by uid 48); 13 Mar 2015 12:24:52 -0000 From: "jcmvbkbc at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/65416] New: xtensa: memory allocated by alloca is used before the stack pointer is updated Date: Fri, 13 Mar 2015 12:24:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 5.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jcmvbkbc at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-03/txt/msg01427.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65416 Bug ID: 65416 Summary: xtensa: memory allocated by alloca is used before the stack pointer is updated Product: gcc Version: 5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: jcmvbkbc at gcc dot gnu.org Created attachment 35025 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35025&action=edit preprocessed source with a single function that demonstrates the issue Hi, I'm building gcc for xtensa linux. The function 'fork_inferior' has the following fragment: argv = (char **) alloca (4 * sizeof (char *)); argv[0] = shell_file; argv[1] = "-c"; argv[2] = shell_command; argv[3] = (char *) 0; that gcc compiles into this: addi a3, sp, -32 l32r a4, .LC23 s32i.n a2, a3, 8 movi.n a2, 0 s32i.n a2, a3, 12 l32r a2, .LC26 s32i.n a3, a4, 0 l32i.n a4, a7, 0 l32i.n a2, a2, 0 s32i.n a4, a3, 0 l32r a4, .LC25 s32i.n a2, a7, 20 l32i.n a10, a7, 24 l32r a2, .LC27 movsp sp, a3 Here argv is a3. The space below the stack pointer is used before the stack pointer is updated. This is reproducible with gcc-4.8.3 and the current 5.0 mainline. Command line: xtensa-buildroot-linux-uclibc-gcc -mlongcalls -mtext-section-literals -pipe -Os -S -o fork-child.s fork-child.i Compilers: Using built-in specs. COLLECT_GCC=/home/jcmvbkbc/tmp/br/build-xea3/host/usr/bin/xtensa-buildroot-linux-uclibc-gcc COLLECT_LTO_WRAPPER=/home/jcmvbkbc/tmp/br/build-xea3/host/usr/libexec/gcc/xtensa-buildroot-linux-uclibc/4.8.3/lto-wrapper Target: xtensa-buildroot-linux-uclibc Configured with: ./configure --prefix=/home/jcmvbkbc/tmp/br/build-xea3/host/usr --sysconfdir=/home/jcmvbkbc/tmp/br/build-xea3/host/etc --enable-static --target=xtensa-buildroot-linux-uclibc --with-sysroot=/home/jcmvbkbc/tmp/br/build-xea3/host/usr/xtensa-buildroot-linux-uclibc/sysroot --disable-__cxa_atexit --with-gnu-ld --disable-libssp --disable-multilib --with-gmp=/home/jcmvbkbc/tmp/br/build-xea3/host/usr --with-mpfr=/home/jcmvbkbc/tmp/br/build-xea3/host/usr --enable-target-optspace --disable-libsanitizer --disable-tls --disable-libmudflap --enable-threads --with-mpc=/home/jcmvbkbc/tmp/br/build-xea3/host/usr --without-isl --without-cloog --disable-decimal-float --with-pkgversion='Buildroot 2014.08-00004-ge3e7af8' --with-bugurl=http://bugs.buildroot.net/ --enable-languages=c,c++ --with-build-time-tools=/home/jcmvbkbc/tmp/br/build-xea3/host/usr/xtensa-buildroot-linux-uclibc/bin --enable-shared --disable-libgomp Thread model: posix gcc version 4.8.3 (Buildroot 2014.08-00004-ge3e7af8) and Using built-in specs. COLLECT_GCC=/home/jcmvbkbc/ws/tensilica/projects/201409-call0/build-5.0.0-windowed-check/root/bin/xtensa-buildroot-linux-uclibc-gcc COLLECT_LTO_WRAPPER=/home/jcmvbkbc/ws/tensilica/projects/201409-call0/build-5.0.0-windowed-check/root/libexec/gcc/xtensa-buildroot-linux-uclibc/5.0.0/lto-wrapper Target: xtensa-buildroot-linux-uclibc Configured with: ../gcc/configure --prefix=/home/jcmvbkbc/ws/tensilica/projects/201409-call0/build-5.0.0-windowed-check/root --target=xtensa-buildroot-linux-uclibc --disable-shared --disable-libssp --disable-libisl --enable-languages=c,c++ --with-sysroot=/home/jcmvbkbc/tmp/br/build-dejagnu-windowed/host/usr/xtensa-buildroot-linux-uclibc/sysroot --disable-threads --disable-tls Thread model: single gcc version 5.0.0 20150303 (experimental) (GCC)