[Bug target/65416] New: xtensa: memory allocated by alloca is used before the stack pointer is updated
jcmvbkbc at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Mar 13 12:24:00 GMT 2015
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)
More information about the Gcc-bugs
mailing list