18.03.2016 16:01, Jiri B пишет:
> On Fri, Mar 18, 2016 at 06:26:47AM +0300, Andrei Borzenkov wrote:
>>> [...]
>>>   CFLAGS=-ftrampolines -fno-stack-protector -fno-pie -nopie
>>>
>>> So I gave it a try and it seems better (?)
>>>
>>> $ ls -l 
>>> /home/jirib/openbsd/pobj/grub-2.02-beta3/fake-amd64/usr/local/lib/grub/i386-pc/lzma_decompress.im*
>>> -rwxr-xr-x  1 jirib  wheel  3068 Mar 17 21:45 
>>> /home/jirib/openbsd/pobj/grub-2.02-beta3/fake-amd64/usr/local/lib/grub/i386-pc/lzma_decompress.image*
>>> -rw-r--r--  1 jirib  wheel  2832 Mar 17 21:45 
>>> /home/jirib/openbsd/pobj/grub-2.02-beta3/fake-amd64/usr/local/lib/grub/i386-pc/lzma_decompress.img
>>>
>>> $ objdump -f 
>>> /home/jirib/openbsd/pobj/grub-2.02-beta3/fake-amd64/usr/local/lib/grub/i386-pc/lzma_decompress.image
>>>
>>> /home/jirib/openbsd/pobj/grub-2.02-beta3/fake-amd64/usr/local/lib/grub/i386-pc/lzma_decompress.image:
>>>      file format elf32-i386
>>> architecture: i386, flags 0x00000002:
>>> EXEC_P
>>> start address 0x00008200
>>>
>>> It is OK?
>>>
>>
>> It certainly looks better than before. Does it actually work?
>>
>> We aready use -fno-PIE, looks like we need to explicitly check for
>> -fno-pie as well.
> 
> I just booted OpenBSD from "native OpenBSD" grub2:
> 

Good. Please test attached patch.

@Vladimir: I was unsure whether to add explicit -fpie test, but at the
end I do not see what it buys us. Both options have been introduced at
the same time and we want neither enabled. Current test covers both.

Is it OK to commit?
From: Andrei Borzenkov <arvidj...@gmail.com>
Subject: [PATCH] configure: set -fno-pie together with -fno-PIE

OpenBSD 5.9 apparently defaults to -fpie. We use -fno-PIE when appropriate
already, but that is not enough - it does not turn off -fpie.

Actually check for -fPIE is not precise enough. __PIE__ is set for both
-fpie and -fPIE but with different values. As far as I can tell, both
options were introduced at the same time, so both should always be supported.

This fixes compilation on OpenBSD 5.9 which otherwise created insanely big
lzma_decompress.img.

Reported, suggested and tested by: Jiri B <ji...@devio.us>

---
 configure.ac | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index a85b134..57e1713 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1185,9 +1185,9 @@ CFLAGS="$TARGET_CFLAGS"
 # Position independent executable.
 grub_CHECK_PIE
 [# Need that, because some distributions ship compilers that include
-# `-fPIE' in the default specs.
+# `-fPIE' or '-fpie' in the default specs.
 if [ x"$pie_possible" = xyes ]; then
-  TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE"
+  TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE -fno-pie"
 fi]
 
 CFLAGS="$TARGET_CFLAGS"
-- 
tg: (76eac44..) u/fno-pie (depends on: master)
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to