Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 206726 - sys-apps/memtest86-3.4 fails to compile on hardened
Summary: sys-apps/memtest86-3.4 fails to compile on hardened
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: AMD64 Linux
: High normal (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-01-20 01:23 UTC by Andreas Westin
Modified: 2017-03-20 07:08 UTC (History)
9 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Add -nopie to if USE=hardened (memtest86-3.4-nopie.patch,435 bytes, text/plain)
2012-04-28 23:34 UTC, Anthony Basile
Details
Applies the patch to the ebuild (fix-ebuild-memtest86-3.4.patch,337 bytes, text/plain)
2012-04-28 23:36 UTC, Anthony Basile
Details
updated plain & stupid patch for 4.0s (memtest86-4.0-hardened.patch,1008 bytes, patch)
2012-12-29 20:41 UTC, Attila Tóth
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Westin 2008-01-20 01:23:50 UTC
memtest86-3.4 fails with this message:

gcc -c -Wall -march=i486 -m32 -Os -fomit-frame-pointer -fno-builtin -ffreestanding  -fno-stack-protector -o test.o test.c
test.c: In function `movinvr':
test.c:294: error: can't find a register in class `BREG' while reloading `asm'
test.c:356: error: can't find a register in class `BREG' while reloading `asm'
make: *** [test.o] Error 1



Reproducible: Always




Portage 2.1.4 (hardened/amd64, gcc-3.4.6, glibc-2.7-r1, 2.6.23.13-grsec x86_64)
=================================================================
System uname: 2.6.23.13-grsec x86_64 AMD Athlon(tm) 64 X2 Dual Core Processor 4200+
Timestamp of tree: Sun, 20 Jan 2008 00:46:01 +0000
app-shells/bash:     3.2_p33
dev-lang/python:     2.5.1-r5
dev-python/pycrypto: 2.0.1-r6
sys-apps/baselayout: 1.12.11.1
sys-apps/sandbox:    1.2.18.1-r2
sys-devel/autoconf:  2.61-r1
sys-devel/automake:  1.10
sys-devel/binutils:  2.18-r1
sys-devel/gcc-config: 1.4.0-r4
sys-devel/libtool:   1.5.24
virtual/os-headers:  2.6.23-r3
ACCEPT_KEYWORDS="amd64 ~amd64"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=k8 -O2 -pipe -msse3"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /var/qmail/alias /var/qmail/control /var/vpopmail/etc"
CONFIG_PROTECT_MASK="/etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/php/apache2-php5/ext-active/ /etc/php/cgi-php5/ext-active/ /etc/php/cli-php5/ext-active/ /etc/revdep-rebuild /etc/terminfo /etc/udev/rules.d"
CXXFLAGS="-march=k8 -O2 -pipe -msse3"
DISTDIR="/usr/portage/distfiles"
FEATURES="candy ccache distlocks metadata-transfer parallel-fetch sandbox sfperms strict unmerge-orphans userfetch"
GENTOO_MIRRORS="http://mirror.gentoo.no/ "
PKGDIR="/usr/portage/packages"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --filter=H_**/files/digest-*"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://rsync.europe.gentoo.org/gentoo-portage"
USE="X amd64 apache2 cracklib crypt hardened justify mailwrapper midi mysql nls nptl nptlonly ntpl pam pcre pic readline session ssl urandom xorg zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" ELIBC="glibc" INPUT_DEVICES="mouse keyboard" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" USERLAND="GNU" VIDEO_CARDS="fbdev nv"
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LC_ALL, LDFLAGS, LINGUAS, MAKEOPTS, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 1 barthek 2008-01-25 10:58:21 UTC
as a workaround - you can switch to vanilla gcc with gcc-config, compile memtest86 and then revert back to default hardened compiler :)
Comment 2 Geoff Kassel 2008-02-14 13:01:11 UTC
I can confirm this bug also occurs on hardened/x86.

Any ideas on a non-vanilla GCC approach to fixing this issue?

Here's my emerge --info:

Portage 2.1.3.19 (hardened/x86/2.6, gcc-3.4.6, glibc-2.6.1-r0, 2.6.23-hardened-r4 i686)
=================================================================
System uname: 2.6.23-hardened-r4 i686 AMD Athlon(tm) 64 X2 Dual Core Processor 4200+
Timestamp of tree: Sun, 10 Feb 2008 02:16:01 +0000
ccache version 2.4 [enabled]
app-shells/bash:     3.2_p17-r1
dev-java/java-config: 1.3.7, 2.1.4
dev-lang/python:     2.3.6-r4, 2.4.4-r6
dev-python/pycrypto: 2.0.1-r6
dev-util/ccache:     2.4-r7
sys-apps/baselayout: 1.12.10-r5
sys-apps/sandbox:    1.2.18.1-r2
sys-devel/autoconf:  2.13, 2.61-r1
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2, 1.10
sys-devel/binutils:  2.18-r1
sys-devel/gcc-config: 1.4.0-r4
sys-devel/libtool:   1.5.24
virtual/os-headers:  2.6.23-r3
ACCEPT_KEYWORDS="x86"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-march=athlon -O2 -pipe -fforce-addr"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/kde/3.5/env /usr/kde/3.5/share/config /usr/kde/3.5/shutdown /usr/share/X11/xkb /usr/share/config /var/bind /var/lib/hsqldb /var/qmail/alias /var/qmail/control /var/service"
CONFIG_PROTECT_MASK="/etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/php/apache2-php5/ext-active/ /etc/php/cgi-php5/ext-active/ /etc/php/cli-php5/ext-active/ /etc/revdep-rebuild /etc/terminfo /etc/udev/rules.d"
CXXFLAGS="-march=athlon -O2 -pipe -fforce-addr"
DISTDIR="/storage/portage/distfiles"
FEATURES="buildpkg ccache distlocks metadata-transfer parallel-fetch sandbox sfperms strict unmerge-orphans userfetch"
GENTOO_MIRRORS="http://ftp.iinet.net.au/pub/Gentoo http://distfiles.gentoo.org http://www.ibiblio.org/pub/Linux/distributions/gentoo"
LINGUAS="en en_GB en_US"
MAKEOPTS="-j3"
PKGDIR="/storage/portage/packages"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --delete-after --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --filter=H_**/files/digest-*"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://rsync.au.gentoo.org/gentoo-portage"
USE="3ds 7zip S3TC X X509 Xaw3d a52 aac accounting acl acpi activefilter adns aim aliaschain alsa amd amr anthy apache2 apm arts artswrappersuid artworkextra asterisk async athena atlas auctex avantgo bash-completion bcmath bdf beep berkdb big-tables bindist binfilter blas blender-game bzip2 cairo calendar cap caps cdb cddb cdf cdparanoia cgi chasen chroot cjk clamav clanJavaScript clanVoice cle266 clisp cln cluster cmucl cnamefix cpdflib cracklib crypt css ctype cups curl curlwrappers cvs dba dbase dbcp dbm dbus dbx devfs26 devil devmap dga dillo dio distribution djbfft dnsdb doc drac dri dv dvb dvd dvdr dvdread editor edl emacs emacs-w3 emoticon encode erandom escreen esd ethereal etwin evo examples exiscan exiscan-acl ext-png ext-zlib extensions fam fastcgi fat fax fbcon fbdev festival ffmpeg fftw filepro firefox flac flatfile flood fluidsynth fmod fortran frascend freetts freetype freewnn ftp fusion fwdzone gb gcj gcl gd gdbm gif gimp gimpprint ginac glade glgd glibc-omitfp glut gmtfull gmthigh gmtsuppl gmttria gnome gnomedb gnuplot gpm gps graphviz gs gsl gsm gsnd gstreamer gtk gtk2 hal hardened hardenedphp haskell hdf iconv icq icu ide idl ieee1394 image imap inetd ingres inifile innodb iodbc ipalias ipcs ipod ipv6 ipv6arpa irda ithreads j2ee jabber jack-tmpfs java javacomm javamail javascript jbig jboss jce jikes jit jmx joystick jp2 jpeg jpeg2k jta junit justify jython kakasi kde kdeenablefinal kerberos krb4 l7filter ladcca latex latin1 lcms ldap ldirectord leim libdsk libg++ libgda libsamplerate lids live lmtp log4j logrotate ltsp lua lynxkeymap lzw m17n-lib maildir mailwrapper max-idx-128 mbox mcve md5sum mdb memlimit midi migemo mikmod mime mixer mmap mod_python moneyplex mono mozcalendar mozdevelop mozilla mozsvg mozxmlterm mp3 mpeg mpeg4 mpi mplayer msdav msession msn mssql mule multipleip multitarget music mysql mysqli nagios-dns nagios-ntp nagios-ping ncurses net neural nhc98 nis nls nntp nocardbus nocd nptl nptlonly nsplugin ntlm oav objc ocaml odbc offensive ofx ogg oggvorbis oldworld openal openexr opengl openntpd oscar ospfapi pam parse-clocks passfile pcntl pcre pda pdf perl pg-intdatetime pg-vacuumdelay php physfs pic plotutils png pnp pop portaudio posix postgres povray ppds prelude print procmail python qemu-fast qhull qt3 qt4 quicktime quotes readline rhino roundrobin rplay ruby samba sasl savedconfig sdk sdl semanticfix servlet-2.3 servlet-2.4 session silc silverxp simplexml skey skk slp sndfile snortsam soap sockets socks5 softmmu softquota sox speedo spell ssl stats stencil-buffer stroke struts svg svga sysvipc szip t1lib tcl tcltk tcpd tcsim theora threads tidy tiff timidity tk tlen tokenizer tools transcode translator transparent-proxy truetype type1 ucs4 uim uml unicode urandom usb uudeview v4l v4l2 vcd vcdimager vda vhosts videos vim-with-x virus-scan vnc voice vorbis vpopmail wddx wmf wxwindows x264 x86 xchattext xcomposite xemacs xface xforms xfs xinerama xinetd xml xml2 xmlrpc xorg xosd xprint xrandr xscreensaver xsl xv yahoo yv12 zeo zlib zvbi" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1 emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias asis auth_basic auth_digest authn_alias authn_anon authn_dbd authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cern_meta charset_lite dav dav_fs dav_lock dbd deflate dir disk_cache dumpio env expires ext_filter file_cache filter headers ident imagemap include info log_config log_forensic logio mem_cache mime mime_magic negotiation proxy proxy_ajp proxy_balancer proxy_connect proxy_ftp proxy_http rewrite setenvif speling status unique_id userdir usertrack version vhost_alias" APACHE2_MPMS="worker" ELIBC="glibc" INPUT_DEVICES="keyboard mouse" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="en en_GB en_US" USERLAND="GNU" VIDEO_CARDS="ati fbdev radeon vesa vga"
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LC_ALL, LDFLAGS, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS

Comment 3 Magnus Granberg gentoo-dev 2009-01-18 03:16:31 UTC
@@ -41,8 +44,7 @@ reloc.o: reloc.c
        $(CC) -c $(CFLAGS) -fno-strict-aliasing reloc.c

 test.o: test.c
-       $(CC) -c -Wall -march=i486 -m32 -Os -fomit-frame-pointer -fno-builtin \
-        -ffreestanding test.c
+       $(CC) -c $(CFLAGS) -fno-PIC -o $@ $<

 clean:
        rm -f *.o memtest.bin memtest memtest_shared memtest_shared.bin

but get
ld: warning: creating a DT_TEXTREL in object.
objcopy -O binary memtest_shared memtest_shared.bin
and not tested..
Comment 4 barthek 2009-10-25 23:18:51 UTC
hmm... so memtest86 3.5 made its way into the portage tree and still exhibits the issue described here. any chance of fixing this up please?
Comment 5 Juergen Rose 2010-01-14 21:55:41 UTC
I got the same error with memtest86-3.5. Any news?
Comment 6 Matt Turner gentoo-dev 2012-04-28 23:03:32 UTC
This bug is identical to bugs 375967 and 376245. I'm disappointed that no one bothered to search for BREG in bugzilla. You'd have immediately come upon these fixed bugs with patches.

Although, I must admit that I think bothering to compile memtest86 with hardened flags is quite stupid. Someone please *try* to come up with a way memtest86 is going to get hacked and do damage to your system.
Comment 7 Anthony Basile gentoo-dev 2012-04-28 23:18:23 UTC
(In reply to comment #6)
> This bug is identical to bugs 375967 and 376245. I'm disappointed that no
> one bothered to search for BREG in bugzilla. You'd have immediately come
> upon these fixed bugs with patches.
> 
> Although, I must admit that I think bothering to compile memtest86 with
> hardened flags is quite stupid. Someone please *try* to come up with a way
> memtest86 is going to get hacked and do damage to your system.

Since memtest isn't a running process, "hardening" it is silly.  So, just turn off pie by adding if use hardened; then CFLAGS+=" -nopie" ; fi.  Let me see if I can produce a patch.
Comment 8 Anthony Basile gentoo-dev 2012-04-28 23:34:16 UTC
Created attachment 310381 [details]
Add -nopie to if USE=hardened
Comment 9 Anthony Basile gentoo-dev 2012-04-28 23:36:24 UTC
Created attachment 310383 [details]
Applies the patch to the ebuild
Comment 10 Anthony Basile gentoo-dev 2012-04-28 23:41:32 UTC
You may want to also fix the build system.  The Makefile:

1) Does not respect CFLAGS, to fix that, change

   CFLAGS=....

to

   CFLAGS+=

2) It calls gcc and ld directly.  You probably want to use toolchain-funcs.eclass's tc-getCC() and tc-getLD().

3) Check if LDFLAGS are respected and/or are a problem.  memtest86 is peculiar so the strict rule "respect LDFLAGS" may need to be broken here.  This also holds for CFLAGS.
Comment 11 Attila Tóth 2012-12-29 20:41:35 UTC
Created attachment 333708 [details, diff]
updated plain & stupid patch for 4.0s

memtest86-4.0s still fails because of the same reason. Although the Makefile differs. The patch is dumb and not a proper way to handle the issue, like it was suggested before in this thread. It works for me.
Besides fixing the ebuild by making it hardened-aware, I'm more worried about the fact, that I'm running out of 32bit installs. My 64bit installs are no-multilib. There might be good to have a memtest-bin ebuild?

Regards:Dw.
Comment 12 Anthony Basile gentoo-dev 2013-10-10 20:55:10 UTC
(In reply to Attila Tóth from comment #11)
> Created attachment 333708 [details, diff] [details, diff]
> updated plain & stupid patch for 4.0s
> 
> memtest86-4.0s still fails because of the same reason. Although the Makefile
> differs. The patch is dumb and not a proper way to handle the issue, like it
> was suggested before in this thread. It works for me.
> Besides fixing the ebuild by making it hardened-aware, I'm more worried
> about the fact, that I'm running out of 32bit installs. My 64bit installs
> are no-multilib. There might be good to have a memtest-bin ebuild?
> 
> Regards:Dw.

I just committed this fix combined with the memtest86-4.3.3-build.patch.  Please test memtest86-4.3.3-r1 ebuild on both a hardened and non-hardened system.  It should work on both.
Comment 13 Attila Tóth 2013-10-16 10:24:10 UTC
(In reply to Anthony Basile from comment #12)
> (In reply to Attila Tóth from comment #11)
> > Created attachment 333708 [details, diff] [details, diff] [details, diff]
> > updated plain & stupid patch for 4.0s
> > 
> > memtest86-4.0s still fails because of the same reason. Although the Makefile
> > differs. The patch is dumb and not a proper way to handle the issue, like it
> > was suggested before in this thread. It works for me.
> > Besides fixing the ebuild by making it hardened-aware, I'm more worried
> > about the fact, that I'm running out of 32bit installs. My 64bit installs
> > are no-multilib. There might be good to have a memtest-bin ebuild?
> > 
> > Regards:Dw.
> 
> I just committed this fix combined with the memtest86-4.3.3-build.patch. 
> Please test memtest86-4.3.3-r1 ebuild on both a hardened and non-hardened
> system.  It should work on both.

Compiles for me on hardened amd64. I had to unmask it on a nomultilib system.
Comment 14 Juergen Rose 2013-10-16 13:46:10 UTC
(In reply to Anthony Basile from comment #12)
> (In reply to Attila Tóth from comment #11)
> > Created attachment 333708 [details, diff] [details, diff] [details, diff]
> > updated plain & stupid patch for 4.0s
> > 
> > memtest86-4.0s still fails because of the same reason. Although the Makefile
> > differs. The patch is dumb and not a proper way to handle the issue, like it
> > was suggested before in this thread. It works for me.
> > Besides fixing the ebuild by making it hardened-aware, I'm more worried
> > about the fact, that I'm running out of 32bit installs. My 64bit installs
> > are no-multilib. There might be good to have a memtest-bin ebuild?
> > 
> > Regards:Dw.
> 
> I just committed this fix combined with the memtest86-4.3.3-build.patch. 
> Please test memtest86-4.3.3-r1 ebuild on both a hardened and non-hardened
> system.  It should work on both.

It does not work for me on a default (non-hardened) system with:
...
x86_64-pc-linux-gnu-gcc -Wall -march=i486 -m32 -O1 -fomit-frame-pointer -fno-builtin -ffreestanding -fPIC -fno-stack-protector -nopie    -c -o config.o config.c
x86_64-pc-linux-gnu-gcc: error: unrecognized option ‘-nopie’
x86_64-pc-linux-gnu-gcc: error: unrecognized option ‘-nopie’x86_64-pc-linux-gnu-gcc: error: unrecognized option ‘-nopie’
make: *** [test.o] Error 1
make: *** Waiting for unfinished jobs....
make: *** [reloc.o] Error 1
x86_64-pc-linux-gnu-gcc: error: unrecognized option ‘-nopie’
make: *** [patn.o] Error 1
x86_64-pc-linux-gnu-gcc: error: unrecognized option ‘-nopie’
x86_64-pc-linux-gnu-gcc: error: unrecognized option ‘-nopie’
x86_64-pc-linux-gnu-gcc: error: unrecognized option ‘-nopie’

make: *** [lib.o] Error 1
Comment 15 Attila Tóth 2013-10-16 14:06:56 UTC
(In reply to Juergen Rose from comment #14)
> (In reply to Anthony Basile from comment #12)
> > (In reply to Attila Tóth from comment #11)
> > > Created attachment 333708 [details, diff] [details, diff] [details, diff] [details, diff]
> > > updated plain & stupid patch for 4.0s
> > > 
> > > memtest86-4.0s still fails because of the same reason. Although the Makefile
> > > differs. The patch is dumb and not a proper way to handle the issue, like it
> > > was suggested before in this thread. It works for me.
> > > Besides fixing the ebuild by making it hardened-aware, I'm more worried
> > > about the fact, that I'm running out of 32bit installs. My 64bit installs
> > > are no-multilib. There might be good to have a memtest-bin ebuild?
> > > 
> > > Regards:Dw.
> > 
> > I just committed this fix combined with the memtest86-4.3.3-build.patch. 
> > Please test memtest86-4.3.3-r1 ebuild on both a hardened and non-hardened
> > system.  It should work on both.
> 
> It does not work for me on a default (non-hardened) system with:
> ...
> x86_64-pc-linux-gnu-gcc -Wall -march=i486 -m32 -O1 -fomit-frame-pointer
> -fno-builtin -ffreestanding -fPIC -fno-stack-protector -nopie    -c -o
> config.o config.c
> x86_64-pc-linux-gnu-gcc: error: unrecognized option ‘-nopie’
> x86_64-pc-linux-gnu-gcc: error: unrecognized option
> ‘-nopie’x86_64-pc-linux-gnu-gcc: error: unrecognized option ‘-nopie’
> make: *** [test.o] Error 1
> make: *** Waiting for unfinished jobs....
> make: *** [reloc.o] Error 1
> x86_64-pc-linux-gnu-gcc: error: unrecognized option ‘-nopie’
> make: *** [patn.o] Error 1
> x86_64-pc-linux-gnu-gcc: error: unrecognized option ‘-nopie’
> x86_64-pc-linux-gnu-gcc: error: unrecognized option ‘-nopie’
> x86_64-pc-linux-gnu-gcc: error: unrecognized option ‘-nopie’
> 
> make: *** [lib.o] Error 1

The patch could be conditional on hardened. The version without nopie could be the default, and the nopie variant could be used in case of hardened only.
Comment 16 Juergen Rose 2013-10-17 10:18:07 UTC
(In reply to Attila Tóth from comment #15)
> (In reply to Juergen Rose from comment #14)
> > (In reply to Anthony Basile from comment #12)
> > > (In reply to Attila Tóth from comment #11)
> > > > Created attachment 333708 [details, diff] [details, diff] [details, diff] [details, diff] [details, diff]
> > > > updated plain & stupid patch for 4.0s
> > > > 
> > > > memtest86-4.0s still fails because of the same reason. Although the Makefile
> > > > differs. The patch is dumb and not a proper way to handle the issue, like it
> > > > was suggested before in this thread. It works for me.
> > > > Besides fixing the ebuild by making it hardened-aware, I'm more worried
> > > > about the fact, that I'm running out of 32bit installs. My 64bit installs
> > > > are no-multilib. There might be good to have a memtest-bin ebuild?
> > > > 
> > > > Regards:Dw.
> > > 
> > > I just committed this fix combined with the memtest86-4.3.3-build.patch. 
> > > Please test memtest86-4.3.3-r1 ebuild on both a hardened and non-hardened
> > > system.  It should work on both.
> > 
> > It does not work for me on a default (non-hardened) system with:
> > ...
> > x86_64-pc-linux-gnu-gcc -Wall -march=i486 -m32 -O1 -fomit-frame-pointer
> > -fno-builtin -ffreestanding -fPIC -fno-stack-protector -nopie    -c -o
> > config.o config.c
> > x86_64-pc-linux-gnu-gcc: error: unrecognized option ‘-nopie’
> > x86_64-pc-linux-gnu-gcc: error: unrecognized option
> > ‘-nopie’x86_64-pc-linux-gnu-gcc: error: unrecognized option ‘-nopie’
> > make: *** [test.o] Error 1
> > make: *** Waiting for unfinished jobs....
> > make: *** [reloc.o] Error 1
> > x86_64-pc-linux-gnu-gcc: error: unrecognized option ‘-nopie’
> > make: *** [patn.o] Error 1
> > x86_64-pc-linux-gnu-gcc: error: unrecognized option ‘-nopie’
> > x86_64-pc-linux-gnu-gcc: error: unrecognized option ‘-nopie’
> > x86_64-pc-linux-gnu-gcc: error: unrecognized option ‘-nopie’
> > 
> > make: *** [lib.o] Error 1
> 
> The patch could be conditional on hardened. The version without nopie could
> be the default, and the nopie variant could be used in case of hardened only.

And how can I make the patch conditional?
Comment 17 Juergen Rose 2013-10-17 10:23:32 UTC
Btw., that memtest86-4.3.3-r1 does not compiler under default gentoo, does not really fit to this bug description. Should I file a separate bug?
Comment 18 Alexander Tsoy 2013-10-17 10:28:06 UTC
(In reply to Juergen Rose from comment #17)
> Btw., that memtest86-4.3.3-r1 does not compiler under default gentoo, does
> not really fit to this bug description. Should I file a separate bug?

Hmm. You already did it. Bug 487600
Comment 19 Juergen Rose 2013-10-17 11:28:51 UTC
(In reply to Alexander Tsoy from comment #18)
> (In reply to Juergen Rose from comment #17)
> > Btw., that memtest86-4.3.3-r1 does not compiler under default gentoo, does
> > not really fit to this bug description. Should I file a separate bug?
> 
> Hmm. You already did it. Bug 487600

OK, thanks. I forgot it.
Comment 20 Attila Tóth 2013-10-17 17:46:40 UTC
(In reply to Juergen Rose from comment #16)
> (In reply to Attila Tóth from comment #15)
> > (In reply to Juergen Rose from comment #14)
> > 
> > The patch could be conditional on hardened. The version without nopie could
> > be the default, and the nopie variant could be used in case of hardened only.
> 
> And how can I make the patch conditional?

There are currently two patches in the files directory:
1. memtest86-4.3.3-build-nopie.patch - which is good for hardened
2. memtest86-4.3.3-build.patch - which is good for non-hardened

memtest86-4.3.3.ebuild applies the non-hardened patch, while memtest86-4.3.3-r1.ebuild applies the hardened version.

Current code in src_prepare for hardened in memtest86-4.3.3-r1.ebuild:
        epatch "${FILESDIR}"/${P}-build-nopie.patch #66630 + #206726

Current code in src_prepare for non-hardened in memtest86-4.3.3.ebuild:
        epatch "${FILESDIR}"/${P}-build.patch #66630


My suggestion:
        if use hardened ; then
                epatch "${FILESDIR}"/${P}-build-nopie.patch #66630 + #206726
        else
                epatch "${FILESDIR}"/${P}-build.patch #66630
        fi

It will be fine for everyone thereafter.
Comment 21 Magnus Granberg gentoo-dev 2013-10-17 20:50:15 UTC
The problem is the test.c file have asm code and the code is not
PIC freindly codede. If we disable PIE on that file we get TEXTREL instead and get QA note for it.
Options
1. Fix the asm or use C code in the test.c
2. Add -nopie for hardened compiler and hide the TEXTREL QA

To check for hardened the gcc-specs-pie should be use in the ebuild
Comment 22 Anthony Basile gentoo-dev 2013-10-18 18:06:38 UTC
(In reply to Magnus Granberg from comment #21)
> The problem is the test.c file have asm code and the code is not
> PIC freindly codede. If we disable PIE on that file we get TEXTREL instead
> and get QA note for it.
> Options
> 1. Fix the asm or use C code in the test.c
> 2. Add -nopie for hardened compiler and hide the TEXTREL QA
> 
> To check for hardened the gcc-specs-pie should be use in the ebuild

You can use -fno-pie instead of -nopie and that should work on both hardened and vanilla profiles.

The textrels are not an issue here because memtest86 does not run as a process.
Comment 23 Anthony Basile gentoo-dev 2013-10-18 19:14:38 UTC
(In reply to Anthony Basile from comment #22)
> (In reply to Magnus Granberg from comment #21)
> > The problem is the test.c file have asm code and the code is not
> > PIC freindly codede. If we disable PIE on that file we get TEXTREL instead
> > and get QA note for it.
> > Options
> > 1. Fix the asm or use C code in the test.c
> > 2. Add -nopie for hardened compiler and hide the TEXTREL QA
> > 
> > To check for hardened the gcc-specs-pie should be use in the ebuild
> 
> You can use -fno-pie instead of -nopie and that should work on both hardened
> and vanilla profiles.
> 
> The textrels are not an issue here because memtest86 does not run as a
> process.

I fixed the -fno-pie for vanilla.  Can people please do a compile and run test.
Comment 24 SpanKY gentoo-dev 2017-03-20 07:08:51 UTC
memtest86-4.3.7 builds fine on hardened