NetBSD Problem Report #45520
From is@netbsd.org Tue Oct 25 07:57:38 2011
Return-Path: <is@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
by www.NetBSD.org (Postfix) with ESMTP id 7CD0763B86B
for <gnats-bugs@gnats.NetBSD.org>; Tue, 25 Oct 2011 07:57:38 +0000 (UTC)
Message-Id: <20111025075731.7C58C207AE@beverly.kleinbus.org>
Date: Tue, 25 Oct 2011 09:57:31 +0200 (CEST)
From: is@netbsd.org
Reply-To: is@netbsd.org
To: gnats-bugs@gnats.NetBSD.org
Subject: -pie broken, breaks some pkgsrc builds.
X-Send-Pr-Version: 3.95
>Number: 45520
>Category: port-arm
>Synopsis: execution of pie is broken, resulting in some broken pkgs
>Confidential: no
>Severity: critical
>Priority: high
>Responsible: port-arm-maintainer
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Oct 25 08:00:00 +0000 2011
>Closed-Date: Fri Sep 30 08:25:13 +0000 2016
>Last-Modified: Fri Sep 30 08:25:13 +0000 2016
>Originator: Ignatios Souvatzis
>Release: NetBSD 5.1
>Organization:
seal your e-mail: http://www.gnupg.org/
>Environment:
System: NetBSD marie 5.1 NetBSD 5.1 (MARIE) #0: Wed Jan 5 20:52:48 CET 2011 ignatios@random87:/var/itch/obj/shark/sys/arch/shark/compile/MARIE shark
Architecture: arm
Machine: shark
>Description:
PIE executables on ARM get SIGABORT.
>How-To-Repeat:
Try to build print/cups - it uses -pie in a lot of places, including
a helper program called "mantohtml" which is further used to translate
documentation, and results in aborts. Faster test:
% cat hello.c
int main() {
write(1, "hello\n", 6);
return 0;
}
% cat Makefile
MKMAN=no
PROG=hello
CFLAGS=-pie
LDFLAGS=-pie
.include <bsd.prog.mk>
test: hello
./hello
% make test
# compile hello/hello.o
cc -pie -Werror -c hello.c
# link hello/hello
cc -pie -o hello hello.o -Wl,-rpath-link,/lib -L/lib -Wl,-rpath-link,/usr/lib -L/usr/lib
./hello
*** Signal 6
Stop.
make: stopped in /home/is/ctest/hello
make: stopped in /home/is/ctest/hello
>Fix:
Workaround might be to remove -pie everywhere.
>Release-Note:
>Audit-Trail:
From: christos@zoulas.com (Christos Zoulas)
To: gnats-bugs@NetBSD.org, port-arm-maintainer@netbsd.org,
gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Cc:
Subject: Re: port-arm/45520: -pie broken, breaks some pkgsrc builds.
Date: Tue, 25 Oct 2011 10:26:03 -0400
On Oct 25, 8:00am, is@beverly.kleinbus.org (is@beverly.kleinbus.org) wrote:
-- Subject: port-arm/45520: -pie broken, breaks some pkgsrc builds.
| # compile hello/hello.o
| cc -pie -Werror -c hello.c
| # link hello/hello
| cc -pie -o hello hello.o -Wl,-rpath-link,/lib -L/lib -Wl,-rpath-link,/usr/lib -L/usr/lib
| ./hello
| *** Signal 6
>From the gcc manual:
-pie
Produce a position independent executable on targets which support
it. For predictable results, you must also specify the same set of
options that were used to generate code (-fpie, -fPIE, or model sub-
options) when you specify this option.
christos
From: is@netbsd.org
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: port-arm/45520: -pie broken, breaks some pkgsrc builds.
Date: Tue, 25 Oct 2011 22:41:34 +0200
On Tue, Oct 25, 2011 at 02:30:05PM +0000, Christos Zoulas wrote:
> >From the gcc manual:
>
> -pie
> Produce a position independent executable on targets which support
> it. For predictable results, you must also specify the same set of
> options that were used to generate code (-fpie, -fPIE, or model sub-
> options) when you specify this option.
ENOPARSE (I read that sentence in the manual myself, and didn't
understand it.) Same options when using the compiler as to when
what?
My demo program/Makefile is about the minimum I could distill the
mantohtml rules used when making the cups package - at least I
think so, and it breaks the same way on arm as the mantohtml, and
works the same way on i386 and amd64 as mantohtml. If options should
be added for right usage, please advise.
-is
From: christos@zoulas.com (Christos Zoulas)
To: gnats-bugs@NetBSD.org, port-arm-maintainer@netbsd.org,
gnats-admin@netbsd.org, netbsd-bugs@netbsd.org, is@netbsd.org
Cc:
Subject: Re: port-arm/45520: -pie broken, breaks some pkgsrc builds.
Date: Tue, 25 Oct 2011 17:35:42 -0400
On Oct 25, 8:45pm, is@netbsd.org (is@netbsd.org) wrote:
-- Subject: Re: port-arm/45520: -pie broken, breaks some pkgsrc builds.
| The following reply was made to PR port-arm/45520; it has been noted by GNATS.
|
| From: is@netbsd.org
| To: gnats-bugs@NetBSD.org
| Cc:
| Subject: Re: port-arm/45520: -pie broken, breaks some pkgsrc builds.
| Date: Tue, 25 Oct 2011 22:41:34 +0200
|
| On Tue, Oct 25, 2011 at 02:30:05PM +0000, Christos Zoulas wrote:
|
| > >From the gcc manual:
| >
| > -pie
| > Produce a position independent executable on targets which support
| > it. For predictable results, you must also specify the same set of
| > options that were used to generate code (-fpie, -fPIE, or model sub-
| > options) when you specify this option.
|
| ENOPARSE (I read that sentence in the manual myself, and didn't
| understand it.) Same options when using the compiler as to when
| what?
|
| My demo program/Makefile is about the minimum I could distill the
| mantohtml rules used when making the cups package - at least I
| think so, and it breaks the same way on arm as the mantohtml, and
| works the same way on i386 and amd64 as mantohtml. If options should
| be added for right usage, please advise.
cc -fpie -pie hello.c -o hello
christos
From: Ignatios Souvatzis <is@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc: port-arm-maintainer@netbsd.org, gnats-admin@netbsd.org,
netbsd-bugs@netbsd.org, is@netbsd.org
Subject: Re: port-arm/45520: -pie broken, breaks some pkgsrc builds.
Date: Wed, 26 Oct 2011 09:52:06 +0200
No change:
marie hello !% cc -pie -fpie -o hello hello.c
marie hello !% ./hello
Abort
marie hello !% cc -pie -fPIE -o hello hello.c
marie hello !% ./hello
Abort
e hello !% ktrace ./hello
Abort
marie hello !% kdump
6181 1 ktrace EMUL "netbsd"
6181 1 ktrace RET ktrace 0
6181 1 ktrace CALL execve(0xeffff897,0xefffe794,0xefffe79c)
6181 1 ktrace NAMI "./hello"
6181 1 ktrace NAMI "/usr/libexec/ld.elf_so"
From: christos@zoulas.com (Christos Zoulas)
To: Ignatios Souvatzis <is@netbsd.org>, gnats-bugs@NetBSD.org
Cc: port-arm-maintainer@netbsd.org, gnats-admin@netbsd.org,
netbsd-bugs@netbsd.org, is@netbsd.org
Subject: Re: port-arm/45520: -pie broken, breaks some pkgsrc builds.
Date: Wed, 26 Oct 2011 11:26:15 -0400
On Oct 26, 9:52am, is@netbsd.org (Ignatios Souvatzis) wrote:
-- Subject: Re: port-arm/45520: -pie broken, breaks some pkgsrc builds.
| No change:
|
| marie hello !% cc -pie -fpie -o hello hello.c
| marie hello !% ./hello
| Abort
| marie hello !% cc -pie -fPIE -o hello hello.c
| marie hello !% ./hello
| Abort
| e hello !% ktrace ./hello
| Abort
Try with:
cc -pie -fPIE -o hello hello.c -lgcc_s
I'll boot my arm box and fix it.
christos
From: christos@zoulas.com (Christos Zoulas)
To: Ignatios Souvatzis <is@netbsd.org>, gnats-bugs@NetBSD.org
Cc: port-arm-maintainer@netbsd.org, gnats-admin@netbsd.org,
netbsd-bugs@netbsd.org, is@netbsd.org
Subject: Re: port-arm/45520: -pie broken, breaks some pkgsrc builds.
Date: Wed, 26 Oct 2011 11:29:51 -0400
On Oct 26, 9:52am, is@netbsd.org (Ignatios Souvatzis) wrote:
-- Subject: Re: port-arm/45520: -pie broken, breaks some pkgsrc builds.
| No change:
|
| marie hello !% cc -pie -fpie -o hello hello.c
| marie hello !% ./hello
| Abort
| marie hello !% cc -pie -fPIE -o hello hello.c
| marie hello !% ./hello
| Abort
| e hello !% ktrace ./hello
| Abort
| marie hello !% kdump
| 6181 1 ktrace EMUL "netbsd"
| 6181 1 ktrace RET ktrace 0
| 6181 1 ktrace CALL execve(0xeffff897,0xefffe794,0xefffe79c)
| 6181 1 ktrace NAMI "./hello"
| 6181 1 ktrace NAMI "/usr/libexec/ld.elf_so"
|
pit:~ [11:26am] 4>cat > hello.c
#include <stdio.h>
int
main(int argc, char *argv[])
{
printf("hello world\n");
return 0;
}
pit:~ [11:27am] 5>cc -fpie -pie hello.c -o hello -lgcc_s
pit:~ [11:27am] 6>./hello
hello world
pit:~ [11:27am] 7>cc -fpie -pie hello.c -o hello
pit:~ [11:28am] 8>./hello
hello world
pit:~ [11:28am] 9>cc -pie hello.c -o hello
pit:~ [11:28am] 10>./hello
hello world
pit:~ [11:28am] 11>file hello
hello: ELF 32-bit LSB shared object, ARM, version 1, dynamically linked (uses shared libs), for NetBSD 5.99.40, not stripped
pit:~ [11:28am] 12>
christos
From: Matt Thomas <matt@3am-software.com>
To: Christos Zoulas <christos@zoulas.com>
Cc: Ignatios Souvatzis <is@netbsd.org>,
gnats-bugs@NetBSD.org,
port-arm-maintainer@netbsd.org,
gnats-admin@netbsd.org,
netbsd-bugs@netbsd.org,
is@netbsd.org
Subject: Re: port-arm/45520: -pie broken, breaks some pkgsrc builds.
Date: Wed, 26 Oct 2011 08:46:11 -0700
On Oct 26, 2011, at 8:26 AM, Christos Zoulas wrote:
> On Oct 26, 9:52am, is@netbsd.org (Ignatios Souvatzis) wrote:
> -- Subject: Re: port-arm/45520: -pie broken, breaks some pkgsrc builds.
>
> | No change:
> |
> | marie hello !% cc -pie -fpie -o hello hello.c
> | marie hello !% ./hello
> | Abort
> | marie hello !% cc -pie -fPIE -o hello hello.c
> | marie hello !% ./hello
> | Abort
> | e hello !% ktrace ./hello
> | Abort
>
> Try with:
>
> cc -pie -fPIE -o hello hello.c -lgcc_s
>
> I'll boot my arm box and fix it.
doesn't crt0 need to be compiled with -fpie as well?
From: is@netbsd.org
To: Christos Zoulas <christos@zoulas.com>
Cc: gnats-bugs@NetBSD.org, port-arm-maintainer@netbsd.org,
gnats-admin@netbsd.org, netbsd-bugs@netbsd.org, is@netbsd.org
Subject: Re: port-arm/45520: -pie broken, breaks some pkgsrc builds.
Date: Wed, 26 Oct 2011 21:08:07 +0200
On Wed, Oct 26, 2011 at 11:29:51AM -0400, Christos Zoulas wrote:
> pit:~ [11:28am] 9>cc -pie hello.c -o hello
> pit:~ [11:28am] 10>./hello
> hello world
> pit:~ [11:28am] 11>file hello
> hello: ELF 32-bit LSB shared object, ARM, version 1, dynamically linked (uses shared libs), for NetBSD 5.99.40, not stripped
> pit:~ [11:28am] 12>
Now - to identify what needs to be pulled up and whether this is
possible - is this a changed kernel (exec stuff), ld.elf_so or gcc?
Here they are:
marie hello !% uname -a
NetBSD marie 5.1 NetBSD 5.1 (MARIE) #0: Wed Jan 5 20:52:48 CET 2011 ignatios@random87:/var/itch/obj/shark/sys/arch/shark/compile/MARIE shark
marie hello !% gcc -v
Using built-in specs.
Target: arm--netbsdelf
Configured with: /usr/src/tools/gcc/../../gnu/dist/gcc4/configure --enable-long-long --disable-multilib --enable-threads --disable-symvers --build=x86_64-unknown-netbsd4.99.72 --host=arm--netbsdelf --target=arm--netbsdelf --enable-__cxa_atexit
Thread model: posix
gcc version 4.1.3 20080704 prerelease (NetBSD nb2 20081120)
Regards,
-is
From: christos@zoulas.com (Christos Zoulas)
To: is@netbsd.org
Cc: gnats-bugs@NetBSD.org, port-arm-maintainer@netbsd.org,
gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Subject: Re: port-arm/45520: -pie broken, breaks some pkgsrc builds.
Date: Wed, 26 Oct 2011 15:16:45 -0400
On Oct 26, 9:08pm, is@netbsd.org (is@netbsd.org) wrote:
-- Subject: Re: port-arm/45520: -pie broken, breaks some pkgsrc builds.
| On Wed, Oct 26, 2011 at 11:29:51AM -0400, Christos Zoulas wrote:
|
| > pit:~ [11:28am] 9>cc -pie hello.c -o hello
| > pit:~ [11:28am] 10>./hello
| > hello world
| > pit:~ [11:28am] 11>file hello
| > hello: ELF 32-bit LSB shared object, ARM, version 1, dynamically linked (uses shared libs), for NetBSD 5.99.40, not stripped
| > pit:~ [11:28am] 12>
|
| Now - to identify what needs to be pulled up and whether this is
| possible - is this a changed kernel (exec stuff), ld.elf_so or gcc?
Perhaps this is what you want:
exec_elf.c:revision 1.13
date: 2010/02/22 19:46:18; author: drochner; state: Exp; lines: +15 -3
branches: 1.13.2;
Run binaries with ELF_TYPE==DYN at virtual address PAGE_SIZE rather
than 0. This is still not the intent of PIE, but it allows them to
run with VA 0 disabled.
(The PAX_ASLR stuff which should deal with this needs work.)
Or try sysctl -w vm.user_va0_disable=0
christos
From: Ignatios Souvatzis <presse@ycm-bonn.de>
To: gnats-bugs@NetBSD.org
Cc: port-arm-maintainer@netbsd.org, gnats-admin@netbsd.org,
netbsd-bugs@netbsd.org, is@netbsd.org
Subject: Re: port-arm/45520: -pie broken, breaks some pkgsrc builds.
Date: Mon, 21 Nov 2011 11:18:37 +0100
I've ported:
> exec_elf.c:revision 1.13
rm -f .gdbinit
touch .gdbinit
# compile hello/hello.o
cc -pie -fPIE -Werror -c hello.c
# link hello/hello
cc -pie -o hello hello.o -lgcc_s -Wl,-rpath-link,/lib -L/lib -Wl,-rpath-link,/usr/lib -L/usr/lib
marie hello !% make test
./hello
vmcmd[0] = 0/0x1000 fd@0 prot=05 flags=4
execve: vmcmd 0 failed: 12
*** Signal 6
Stop.
make: stopped in /home/is/ctest/hello
Regards,
-is
State-Changed-From-To: open->feedback
State-Changed-By: matt@NetBSD.org
State-Changed-When: Sat, 03 Aug 2013 21:40:17 +0000
State-Changed-Why:
pie should be working now
State-Changed-From-To: feedback->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Fri, 30 Sep 2016 08:25:13 +0000
State-Changed-Why:
pies are definitely working now
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.