subscribe 526961 r...@ringlet.net
reassign 526961 gcc-4.3
retitle 526961 -fPIE -pie generates corrupt executable on mips/mipsel
severity 526961 normal
thanks

Okay, as promised, I was able to isolate the problem to a minimal
C program that exhibits the weird behavior.  It turns out the problem
is with gcc, not with the hardening wrapper; the wrapper simply runs
the compiler with PIE options, triggering the failure.

In short, for the gcc-4.3 team: if you compile the following short
program on mipsel/unstable with -fPIE -pie and then try to run
the resulting executable, it will segfault before even reaching
the entry point of main().  This showed up as a FTBFS for
the confget package on the mips and mipsel architectures; it was
later confirmed by Jakub Wilk on a QEMU virtual machine in
http://lists.debian.org/debian-mentors/2009/08/msg00163.html
and today I managed to set up a QEMU virtual machine of my own
and spent some time cutting up the confget code to the absolute
minimum that segfaults upon execution.

Here's the short program; see below for Debian package versions
in my QEMU mipsel virtual machine.  Note the "#if 1"; if you
change that into "#if 0" and do not initialize the array element,
everything will be fine, the program will run.  With the "#if 1",
compile the program with "cc -fPIE -pie -o cminimal cminimal.c";
running it will cause a segfault.

#include <stdio.h>
#include <string.h>

typedef struct {
        const char      *name;
} confget_backend;

confget_backend  confget_ini_backend = {
        "ini",
};

static confget_backend  *backends[] = {
#if 1
        &confget_ini_backend,
#else
        NULL,
#endif
};

/***
 * Main routine
 */
int
main(void)
{
        printf("Hell world, backends is %p!\n", (void *)backends);
        return (0);
}

Here's the information that "reportbug gcc-4.3" would've included:

Package: gcc-4.3
Version: 4.3.4-1
Severity: normal

-- System Information:
Debian Release: squeeze/sid
  APT prefers unstable
  APT policy: (990, 'unstable'), (300, 'testing')
Architecture: mipsel (mips)

Kernel: Linux 2.6.30-1-4kc-malta
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages gcc-4.3 depends on:
ii  binutils              2.19.51.20090805-1 The GNU assembler, linker and bina
ii  cpp-4.3               4.3.4-1            The GNU C preprocessor
ii  gcc-4.3-base          4.3.4-1            The GNU Compiler Collection (base 
ii  libc6                 2.9-24             GNU C Library: Shared libraries
ii  libgcc1               1:4.4.1-2          GCC support library
ii  libgomp1              4.4.1-2            GCC OpenMP (GOMP) support library

Versions of packages gcc-4.3 recommends:
ii  libc6-dev                     2.9-24     GNU C Library: Development Librari

Versions of packages gcc-4.3 suggests:
pn  gcc-4.3-doc                   <none>     (no description available)
pn  gcc-4.3-locales               <none>     (no description available)
pn  gcc-4.3-multilib              <none>     (no description available)
pn  libgcc1-dbg                   <none>     (no description available)
pn  libgomp1-dbg                  <none>     (no description available)
pn  libmudflap0-4.3-dev           <none>     (no description available)
pn  libmudflap0-dbg               <none>     (no description available)

-- no debconf information

Hope that helps!

G'luck,
Peter

-- 
Peter Pentchev  r...@ringlet.net    r...@space.bg    r...@freebsd.org
PGP key:        http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint FDBA FD79 C26F 3C51 C95E  DF9E ED18 B68D 1619 4553
The rest of this sentence is written in Thailand, on

Attachment: pgpsviuYxNe1N.pgp
Description: PGP signature

Reply via email to