* [gentoo-user] If I avaoided pic/PIC/pie; would it help/hurt?
@ 2017-12-05 22:48 Walter Dnes
2017-12-05 23:34 ` Nils Holland
0 siblings, 1 reply; 2+ messages in thread
From: Walter Dnes @ 2017-12-05 22:48 UTC (permalink / raw
To: Gentoo Users List
I'm looking at going with...
CFLAGS="-O2 -march=native -mfpmath=sse -fomit-frame-pointer -pipe -fno-pic -fno-PIC -fno-pie -fno-unwind-tables -fno-asynchronous-unwind-tables"
CXXFLAGS="${CFLAGS}"
...and with -pic in USE. This is the mirror image of the defaults. Any
obvious problems, aside from losing a bit of security? In case you're
wondering about the "pic" USE flag...
[d531][waltdnes][~] grep ":pic " /usr/portage/profiles/use.local.desc
app-arch/gzip:pic - disable optimized assembly code that is not PIC friendly
app-benchmarks/ramspeed:pic - Force shared libraries to be built as PIC (this is slower)
app-emulation/open-vm-tools:pic - Force shared libraries to be built as PIC
dev-util/electron:pic - Disable optimized assembly code that is not PIC friendly
games-emulation/yabause:pic - disable optimized assembly code that is not PIC friendly
games-fps/duke3d:pic - disable optimized assembly code that is not PIC friendly
gnome-base/orbit:pic - Force libname-server-2 to be built as PIC; needed on hardened systems
media-libs/libpostproc:pic - Force shared libraries to be built as PIC (this is slower).
media-libs/mesa:pic - disable optimized assembly code that is not PIC friendly
media-libs/x264:pic - disable optimized assembly code that is not PIC friendly
media-libs/x265:pic - Disable optimized assembly code that is not PIC friendly
media-libs/xvid:pic - disable optimized assembly code that is not PIC friendly
media-video/ffmpeg:pic - Force shared libraries to be built as PIC (this is slower)
media-video/libav:pic - Force shared libraries to be built as PIC (this is slower).
media-video/transcode:pic - disable optimized assembly code that is not PIC friendly
www-client/chromium:pic - Disable optimized assembly code that is not PIC friendly
--
Walter Dnes <waltdnes@waltdnes.org>
I don't run "desktop environments"; I run useful applications
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [gentoo-user] If I avaoided pic/PIC/pie; would it help/hurt?
2017-12-05 22:48 [gentoo-user] If I avaoided pic/PIC/pie; would it help/hurt? Walter Dnes
@ 2017-12-05 23:34 ` Nils Holland
0 siblings, 0 replies; 2+ messages in thread
From: Nils Holland @ 2017-12-05 23:34 UTC (permalink / raw
To: gentoo-user
On Tue, Dec 05, 2017 at 05:48:52PM -0500, Walter Dnes wrote:
> I'm looking at going with...
>
> CFLAGS="-O2 -march=native -mfpmath=sse -fomit-frame-pointer -pipe -fno-pic -fno-PIC -fno-pie -fno-unwind-tables -fno-asynchronous-unwind-tables"
> CXXFLAGS="${CFLAGS}"
Hmm ... is this really sufficient? In order to really not get a PIE
compiled, doesn't one also has to tell the linker about it? Testing on
a system that's already been upgraded to a GCC which produces PIEs by
default:
nils@boerne (GCC7) ~ $ gcc test.c
nils@boerne (GCC7) ~ $ file a.out
a.out: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 3.2.0, not stripped
-> As expected, this is a PIE ("ELF 32-bit LSB shared object").
ils@boerne (GCC7) ~ $ gcc -fno-pie test.c
nils@boerne (GCC7) ~ $ file a.out
a.out: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 3.2.0, not stripped
-> Despite "-fno-pie" being used, still a shared object / PIE.
ils@boerne (GCC7) ~ $ gcc -fno-pie -no-pie test.c
nils@boerne (GCC7) ~ $ file a.out
a.out: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 3.2.0, not stripped
-> Adding "-no-pie" to the game, and we get a normal "ELF 32-bit LSB
executable" (i.e. non-PIE).
So this might sound like you'd have to add "-no-pie" to your CFLAGS as
well, however, when I have a look at this bug report:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77464
I get the feeling that this is just asking for trouble.
Now, if I wanted to switch to a 17.0 profile, and still make sure
everything stays the way it was before PIE-wise (i.e. binaries get
compiled as non-PIE by default), I'd probably have a look instead at
overriding the "pie" USE flag that the new profile forces on GCC. It
should be able to set it to "-pie" in your local portage config. That
way, GCC should continue to be build with "--disable-default-pie",
which should make it emit normal non-PIE binaries by default, thus you
wouldn't have to specify anything PIE-related in your CFLAGS to
achieve just that. Might be the easier solution, I guess.
Greetings
Nils
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-12-05 23:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-05 22:48 [gentoo-user] If I avaoided pic/PIC/pie; would it help/hurt? Walter Dnes
2017-12-05 23:34 ` Nils Holland
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox