Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 254355 (PR39013) - net-libs/libnet-1.1.2.1-r1 fails to compile under gcc-4.3.3 due to pie/plt error
Summary: net-libs/libnet-1.1.2.1-r1 fails to compile under gcc-4.3.3 due to pie/plt error
Status: RESOLVED FIXED
Alias: PR39013
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo Toolchain Maintainers
URL: http://gcc.gnu.org/PR39013
Whiteboard:
Keywords:
: 259970 (view as bug list)
Depends on:
Blocks: 262567
  Show dependency tree
 
Reported: 2009-01-09 21:16 UTC by dacook
Modified: 2009-04-05 19:16 UTC (History)
11 users (show)

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


Attachments
patch to libnet-1.1.2.1-r1.ebuild (libnet-1.1.2.1-fpic.patch,660 bytes, patch)
2009-01-09 21:19 UTC, dacook
Details | Diff
readelf -a of the gre.o file compile with -fPIE (gre.pie.readelf-a.o.txt,20.27 KB, text/plain)
2009-01-19 02:03 UTC, Magnus Granberg
Details
readelf -a of the gre.o file compile with -fPIC (gre.pic.readelf-a.o.txt,20.27 KB, text/plain)
2009-01-19 02:10 UTC, Magnus Granberg
Details
gre compile with gcc 4.1 and -fPIE readelf -a (readelf-a_gcc-4.1_pie_gre.o.txt,39.08 KB, text/plain)
2009-01-23 16:02 UTC, Magnus Granberg
Details
gre compile with gcc 4.3 and -fPIE readelf -a (readelf-a_gcc-4.3_pie_gre.o.txt,40.07 KB, text/plain)
2009-01-23 16:04 UTC, Magnus Granberg
Details
gre compile with gcc 4.3 hardened and -fPIC gre.s (gre.s_pic.txt,13.17 KB, text/plain)
2009-01-25 12:43 UTC, Magnus Granberg
Details
gre compile with gcc 4.3 hardened and -fPIE gre.s (gre.i_pie.txt,241.35 KB, text/plain)
2009-01-25 12:44 UTC, Magnus Granberg
Details
gre compile with gcc 4.1 vanilla and -fPIE gre.s (gre.i_pie_gcc-4.1.txt,193.13 KB, text/plain)
2009-01-25 12:45 UTC, Magnus Granberg
Details
compile sample/gre with -fPIC quick fix (compile-gre-with-pic.patch,239 bytes, text/plain)
2009-01-26 16:45 UTC, Magnus Granberg
Details
Patch from gcc bugzilla #39013 fixed for gcc 4.3.3 (13_all_gcc-4.3-pr39013.patch,2.36 KB, patch)
2009-01-30 23:05 UTC, Magnus Granberg
Details | Diff
fix the bug in the patch with this (69_all_gcc-43-pr39013.patch,2.40 KB, patch)
2009-03-16 11:25 UTC, Magnus Granberg
Details | Diff
fix a typo in tha last patch (69_all_gcc-43-pr39013.patch,2.39 KB, text/plain)
2009-03-16 12:12 UTC, Magnus Granberg
Details

Note You need to log in before you can comment on or make changes to this bug.
Description dacook 2009-01-09 21:16:54 UTC
net-libs/libnet:1.1 fails during linking with the following error:

make[1]: Entering directory `/var/tmp/portage/net-libs/libnet-1.1.2.1-r1/work/libnet/sample'
/bin/sh ../libtool --tag=CC   --mode=link x86_64-pc-linux-gnu-gcc  -march=amdfam10 -pipe -fomit-frame-pointer -O2 -fforce-addr -mno-tls-direct-seg-refs -Wall  -Wl,-O1 -o gre gre.o ../src/libnet.la 
libtool: link: x86_64-pc-linux-gnu-gcc -march=amdfam10 -pipe -fomit-frame-pointer -O2 -fforce-addr -mno-tls-direct-seg-refs -Wall -Wl,-O1 -o .libs/gre gre.o  ../src/.libs/libnet.so
/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/../../../../x86_64-pc-linux-gnu/bin/ld: gre.o: relocation R_X86_64_PC32 against undefined symbol `libnet_getgre_length' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/../../../../x86_64-pc-linux-gnu/bin/ld: final link failed: Bad value
collect2: ld returned 1 exit status
make[1]: *** [gre] Error 1
make[1]: Leaving directory `/var/tmp/portage/net-libs/libnet-1.1.2.1-r1/work/libnet/sample'
make: *** [all-recursive] Error 1

It does not exhibit on x86/hardened (gcc-3.4.6-r2) or amd64/desktop (gcc-4.3.2-r2).  Modifying the ebuild to add '-fPIC' to the CFLAGS works.  Patch to follow.
Comment 1 dacook 2009-01-09 21:19:02 UTC
Created attachment 177910 [details, diff]
patch to libnet-1.1.2.1-r1.ebuild

Approaches varied, but this seemed the most common approach in portage to adding -fPIC.
Comment 2 dacook 2009-01-09 21:20:43 UTC
emerge --info:

Portage 2.1.6.4 (hardened/linux/amd64/2008.0/server, gcc-4.3.2, glibc-2.9_p20081201-r1, 2.6.27-hardened-r3 x86_64)
=================================================================
System uname: Linux-2.6.27-hardened-r3-x86_64-AMD_Phenom-tm-_9850_Quad-Core_Processor-with-glibc2.2.5
Timestamp of tree: Thu, 08 Jan 2009 14:05:01 +0000
app-shells/bash:     3.2_p48
dev-lang/python:     2.4.4-r6, 2.5.2-r8
dev-python/pycrypto: 2.0.1-r6
sys-apps/baselayout: 2.0.0
sys-apps/openrc:     0.4.1-r1
sys-apps/sandbox:    1.3.2
sys-devel/autoconf:  2.63
sys-devel/automake:  1.10.2
sys-devel/binutils:  2.19
sys-devel/gcc-config: 1.4.0-r4
sys-devel/libtool:   2.2.6a
virtual/os-headers:  2.6.28-r1
ACCEPT_KEYWORDS="amd64 ~amd64"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=amdfam10 -pipe -fomit-frame-pointer -O2 -fforce-addr -mno-tls-direct-seg-refs"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/gconf /etc/gentoo-release /etc/init.d/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/udev/rules.d"
CXXFLAGS="-march=amdfam10 -pipe -fomit-frame-pointer -O2 -fforce-addr -mno-tls-direct-seg-refs"
DISTDIR="/usr/portage/distfiles"
FEATURES="buildpkg collision-protect distlocks fakeroot fixpackages parallel-fetch protect-owned sandbox sfperms strict unmerge-orphans userfetch userpriv usersandbox"
GENTOO_MIRRORS="http://distfiles.gentoo.org http://distro.ibiblio.org/pub/linux/distributions/gentoo"
LDFLAGS="-Wl,-O1"
MAKEOPTS="-j6"
PKGDIR="/usr/portage/packages"
PORTAGE_RSYNC_EXTRA_OPTS="-P"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="acl amd64 apache2 audit berkdb bzip2 caps cli cracklib crypt cups dbus dri gd gdbm glibc-omitfp gmp gpm hardened hpn iconv idn ipv6 iscsi isdnlog ithreads justify keyscrub kqemu kvm libedit lvm lzma lzo mailwrapper midi mktemp mmx mudflap multilib mysql ncurses nls nptl nptlonly openmp pam passwdqc pcre perl pic pppd python qemu readline reflection screen session snmp socks5 spl sse sse2 sse3 ssh ssl sysfs tcpd threads truetype unicode urandom utils vde vim-syntax xattr xml 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 mmap_emul 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="keyboard mouse evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" USERLAND="GNU" VIDEO_CARDS="fbdev glint i810 intel mach64 mga neomagic nv r128 radeon savage sis tdfx trident vesa vga via vmware voodoo"
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, FFLAGS, INSTALL_MASK, LANG, LC_ALL, LINGUAS, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTDIR_OVERLAY
Comment 3 Magnus Granberg gentoo-dev 2009-01-18 04:10:23 UTC
Have that to but i would add a patch for Makefile.in
gre.o: CFLAGS += -fPIC
But we need to check way gcc 4.3.2 need -fPIC instead of -fPIE on that.
http://hardened.gentooexperimental.org/trac/secure/ticket/50

emerge --info
Portage 2.1.6.4 (hardened/linux/amd64/2008.0/server, gcc-4.3.2, glibc-2.8_p20080602-r1, 2.6.25-hardened-r4 x86_64)
=================================================================
System uname: Linux-2.6.25-hardened-r4-x86_64-Intel-R-_Xeon-R-_CPU_E5420_@_2.50GHz-with-glibc2.4
Timestamp of tree: Sat, 17 Jan 2009 23:00:02 +0000
app-shells/bash:     3.2_p48
dev-lang/python:     2.5.2-r8
sys-apps/baselayout: 2.0.0
sys-apps/openrc:     0.4.1-r1
sys-apps/sandbox:    1.3.2
sys-devel/autoconf:  2.63
sys-devel/automake:  1.10.2
sys-devel/binutils:  2.18-r4
sys-devel/gcc-config: 1.4.0-r4
sys-devel/libtool:   1.5.26
virtual/os-headers:  2.6.28-r1
ACCEPT_KEYWORDS="amd64 ~amd64"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -pipe"
CHOST="x86_64-pc-linux-gnu"


Comment 4 Magnus Granberg gentoo-dev 2009-01-19 02:03:45 UTC
Created attachment 178949 [details]
readelf -a of the gre.o file compile with -fPIE
Comment 5 Magnus Granberg gentoo-dev 2009-01-19 02:10:29 UTC
Created attachment 178951 [details]
readelf -a of the gre.o file compile with -fPIC

This object file is okey and works.
It have R_X86_64_PLT32 0000000000000000 libnet_getgre_length + fffffffffffffffc
instead of R_X86_64_PC32 0000000000000000 libnet_getgre_length + fffffffffffffffc
Comment 6 Magnus Granberg gentoo-dev 2009-01-23 14:50:57 UTC
On gcc 4.1 vanilla with -fPIE on gre.c it works fine but not on gcc 4.3
Comment 7 Magnus Granberg gentoo-dev 2009-01-23 16:02:40 UTC
Created attachment 179456 [details]
gre compile with gcc 4.1 and -fPIE  readelf -a
Comment 8 Magnus Granberg gentoo-dev 2009-01-23 16:04:43 UTC
Created attachment 179458 [details]
gre compile with gcc 4.3 and -fPIE  readelf -a

gre.o: CFLAGS += -fPIE
gre: LDFLAGS += -pie
added in the Makefile.in
Comment 9 Magnus Granberg gentoo-dev 2009-01-25 12:43:23 UTC
Created attachment 179666 [details]
gre compile with gcc 4.3 hardened and -fPIC gre.s

the s file from gcc -save-temps
Comment 10 Magnus Granberg gentoo-dev 2009-01-25 12:44:01 UTC
Created attachment 179668 [details]
gre compile with gcc 4.3 hardened and -fPIE gre.s

the s file from gcc -save-temps
Comment 11 Magnus Granberg gentoo-dev 2009-01-25 12:45:09 UTC
Created attachment 179669 [details]
gre compile with gcc 4.1 vanilla and -fPIE gre.s

the s file from gcc -save-temps
Comment 12 Tony Vroon (RETIRED) gentoo-dev 2009-01-26 14:47:11 UTC
Fails in the same manner here:
Portage 2.1.6.7 (hardened/linux/amd64/2008.0/no-multilib, gcc-4.3.2, glibc-2.9_p20081201-r1, 2.6.28-hardened x86_64)
=================================================================
System uname: Linux-2.6.28-hardened-x86_64-Intel-R-_Xeon-TM-_CPU_3.20GHz-with-glibc2.3.2
Timestamp of tree: Sun, 25 Jan 2009 23:45:01 +0000
app-shells/bash:     3.2_p48
dev-lang/python:     2.4.4-r6, 2.5.2-r8
dev-python/pycrypto: 2.0.1-r6
sys-apps/baselayout: 2.0.0
sys-apps/openrc:     0.4.2
sys-apps/sandbox:    1.3.2
sys-devel/autoconf:  2.63
sys-devel/automake:  1.10.2
sys-devel/binutils:  2.19
sys-devel/gcc-config: 1.4.0-r4
sys-devel/libtool:   2.2.6a
virtual/os-headers:  2.6.28-r1
ACCEPT_KEYWORDS="amd64 ~amd64"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=nocona -O2 -pipe -fomit-frame-pointer"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/udev/rules.d"
CXXFLAGS="-march=nocona -O2 -pipe -fomit-frame-pointer"
DISTDIR="/usr/portage/distfiles"
FEATURES="distlocks fixpackages parallel-fetch protect-owned sandbox sfperms strict unmerge-orphans userfetch"
GENTOO_MIRRORS="http://distfiles.gentoo.org http://distro.ibiblio.org/pub/linux/distributions/gentoo"
LDFLAGS="-Wl,-O1"
MAKEOPTS="-j4"
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"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/srv/gentoo/overlay /usr/local/portage"
SYNC="rsync://red.linx.net/gentoo-portage"
USE="acl amd64 animgif bash-completion berkdb bzip2 calendar cgi cli cracklib crypt cups dahdi device-mapper diskio dri elf expat fastcgi gd gdbm gif gnutls gpm hardened iconv ipv6 isdnlog jpeg justify md5sum midi mmx mpm-prefork mudflap ncurses no-old-linux nptl nptlonly openmp pam pcre perl pic png pppd python readline reflection rss session snmp spl sqlite sse sse2 ssl sysfs syslog truetype unicode urandom vhosts xml 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 mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic auth_digest authn_anon authn_dbd 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 dbd deflate dir disk_cache env expires ext_filter file_cache filter headers ident imagemap include info log_config logio mem_cache mime mime_magic negotiation proxy proxy_ajp proxy_balancer proxy_connect proxy_http rewrite setenvif so speling status unique_id userdir usertrack vhost_alias" ELIBC="glibc" INPUT_DEVICES="keyboard mouse evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" USERLAND="GNU" VIDEO_CARDS="fbdev glint i810 intel mach64 mga neomagic nv r128 radeon savage sis tdfx trident vesa vga via vmware voodoo"
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, FFLAGS, INSTALL_MASK, LANG, LC_ALL, LINGUAS, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 13 Magnus Granberg gentoo-dev 2009-01-26 16:45:22 UTC
Created attachment 179778 [details]
compile sample/gre with -fPIC quick fix

This is only a quick fix for gre
It is a bug in the compiler that need to be fixed.
The compiler don't add @PLT to the symbol libnet_getgre_length in the object
file. gre.o
Works fine in gcc <4.2
Comment 14 Magnus Granberg gentoo-dev 2009-01-26 17:16:25 UTC
	eautoreconf
+	# Quick fix for #254355
+	if gcc-specs-pie && gcc-version > 4.3 ; then
+	    epatch "${FILESDIR}"/compile-gre-with-pic.patch
+	fi
 }

Fix for the ebuild
 
Comment 15 Tony Vroon (RETIRED) gentoo-dev 2009-01-28 14:37:34 UTC
Just to confirm, the newly released GCC 4.3.3 ebuild does not resolve this build error.
Comment 16 Magnus Granberg gentoo-dev 2009-01-28 15:52:53 UTC
(In reply to comment #15)
> Just to confirm, the newly released GCC 4.3.3 ebuild does not resolve this
> build error.
> 
Thay did change some stuff for the check of @PLT in gcc 4.3 and it is okey in 4.2.4
Need to track the chenge down.
Comment 17 Magnus Granberg gentoo-dev 2009-01-28 21:33:37 UTC
Comment on attachment 179668 [details]
gre compile with gcc 4.3 hardened and -fPIE gre.s

wrong file
Comment 18 Magnus Granberg gentoo-dev 2009-01-28 21:35:08 UTC
Comment on attachment 179669 [details]
gre compile with gcc 4.1 vanilla and -fPIE gre.s

wrong file
Comment 19 Magnus Granberg gentoo-dev 2009-01-28 22:18:53 UTC
Added the bug on gcc's bugzilla
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39013

Comment 20 solar (RETIRED) gentoo-dev 2009-01-28 22:32:30 UTC
patch from comment #13 is good. comment #14 is wrong . This most likely should be applied unconditionally.

Removing hardened@ due to the high traffic of the bug. Please add us back if you require any further input.
Comment 21 Magnus Granberg gentoo-dev 2009-01-30 23:05:16 UTC
Created attachment 180327 [details, diff]
Patch from gcc bugzilla #39013 fixed for gcc 4.3.3

This patch fix the missing @PLT when -fpie is used and inline
Comment 22 SpanKY gentoo-dev 2009-02-22 01:18:58 UTC
thanks, queued for the 4.3.3 patchset

http://sources.gentoo.org/gentoo/src/patchsets/gcc/4.3.3/gentoo/69_all_gcc43-pr39013.patch?rev=1.1
Comment 23 Jeremy Olexa (darkside) (RETIRED) archtester gentoo-dev Security 2009-03-09 00:23:54 UTC
*** Bug 259970 has been marked as a duplicate of this bug. ***
Comment 24 SpanKY gentoo-dev 2009-03-16 07:05:23 UTC
unfortunately, this patch seems to break other things ... see Bug 262567
Comment 25 SpanKY gentoo-dev 2009-03-16 08:02:57 UTC
the backport wasnt entirely correct ... the pedwarn() func has a diff decl in trunk than gcc-4.3.  so this change is needed:

-+    pedwarn (input_location, 0,
-+        "inline function %q+D declared but never defined", p);
++    pedwarn ("inline function %q+D declared but never defined", p);
Comment 26 Magnus Granberg gentoo-dev 2009-03-16 10:44:52 UTC
(In reply to comment #25)
> the backport wasnt entirely correct ... the pedwarn() func has a diff decl in
> trunk than gcc-4.3.  so this change is needed:
> 
> -+    pedwarn (input_location, 0,
> -+        "inline function %q+D declared but never defined", p);
> ++    pedwarn ("inline function %q+D declared but never defined", p);
> 
okey

Comment 27 Magnus Granberg gentoo-dev 2009-03-16 11:25:34 UTC
Created attachment 185178 [details, diff]
fix the bug in the patch with this

Hope this works :)
Comment 28 Magnus Granberg gentoo-dev 2009-03-16 11:48:26 UTC
(In reply to comment #27)
> Created an attachment (id=185178) [edit]
> fix the bug in the patch with this
> 
> Hope this works :)
> 
It did'd :(

Comment 29 Magnus Granberg gentoo-dev 2009-03-16 12:12:29 UTC
Created attachment 185179 [details]
fix a typo in tha last patch

It was a typo in the last patch sorry.
Comment 30 Magnus Granberg gentoo-dev 2009-03-31 00:52:01 UTC
This patch is needed for gcc 4.3.2 too so hardened gcc 4.3.2 can get stable.