Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 165547 - dev-lang/mono-1.2.2.1 libmono-static.a: could not read symbols: Bad value. recompile with -fPIC
Summary: dev-lang/mono-1.2.2.1 libmono-static.a: could not read symbols: Bad value. re...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Hardened (show other bugs)
Hardware: AMD64 Linux
: High normal (vote)
Assignee: The Gentoo Linux Hardened Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-02-06 02:18 UTC by Michael Crawford (ali3nx)
Modified: 2007-09-10 19:11 UTC (History)
2 users (show)

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


Attachments
Allow mono-compiler.h to trigger on __PIC__ for PIC code. (mono-pictls.patch,395 bytes, patch)
2007-02-06 08:18 UTC, Kevin F. Quinn (RETIRED)
Details | Diff
Allow mono-compiler.h to trigger on __PIC__ for PIC code. (mono-pictls.patch,515 bytes, patch)
2007-02-06 09:11 UTC, Kevin F. Quinn (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Crawford (ali3nx) 2007-02-06 02:18:13 UTC
dev-lang/mono-1.2.2.1 appears to fail linking of libmono-static.a if compiled with pie enabled using hardened/amd64/multilib with the default gcc profile.

Reproducible: Always

Steps to Reproduce:
1. emerge =mono-1.2.2.1 

Actual Results:  
x86_64-pc-linux-gnu-gcc -I../.. -I../../libgc/include -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -pthread -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -march=opteron -O2 -pipe -fno-strict-aliasing -Wdeclaration-after-statement -g -Wall -Wunused -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wno-cast-qual -Wcast-align -Wwrite-strings -mno-tls-direct-seg-refs -Wl,-version-script=./ldscript.mono -o mono main.o -pthread -Wl,--export-dynamic -Wl,--export-dynamic  ./.libs/libmono-static.a /usr/lib64/libgthread-2.0.so /usr/lib64/libgmodule-2.0.so -ldl /usr/lib64/libglib-2.0.so -lrt -lpthread -lm
/usr/lib/gcc/x86_64-pc-linux-gnu/3.4.6/../../../../x86_64-pc-linux-gnu/bin/ld: ./.libs/libmono-static.a(threads.o): relocation R_X86_64_TPOFF32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
./.libs/libmono-static.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[4]: *** [mono] Error 1
make[4]: Leaving directory `/var/tmp/portage/mono-1.2.2.1/work/mono-1.2.2.1/mono/mini'
make[3]: *** [all] Error 2

Expected Results:  
-fPIE friendly mono. doesn't everyone like pie =]

I'm currently testing other gcc profiles. Building with either lt or nptl toolchain produced identical results both before and after fixing the broken/missing /usr/lib -> /usr/lib64 symlink. Noted for refrence that this chroot was built from stage1-amd64-hardened+multilib-2006.0 on a non grsec+pax kernel.
Comment 1 Michael Crawford (ali3nx) 2007-02-06 03:07:37 UTC
compiles/does not compile
--------------------------------------------------
[1] x86_64-pc-linux-gnu-3.4.6                   NO
[2] x86_64-pc-linux-gnu-3.4.6-hardenednopie     OK
[3] x86_64-pc-linux-gnu-3.4.6-hardenednopiessp  OK
[4] x86_64-pc-linux-gnu-3.4.6-hardenednossp     NO
[5] x86_64-pc-linux-gnu-3.4.6-vanilla           OK

surely appears to be an issue with pie.

hammer ~ # emerge --info
Portage 2.1.1-r2 (hardened/amd64/multilib, gcc-3.4.6, glibc-2.3.6-r5, 2.6.19-gentoo-r4 x86_64)
=================================================================
System uname: 2.6.19-gentoo-r4 x86_64 AMD Opteron(tm) Processor 246
Gentoo Base System release 1.12.6
Last Sync: Sun, 04 Feb 2007 13:30:01 +0000
ccache version 2.4 [disabled]
app-admin/eselect-compiler: [Not Present]
dev-java/java-config: 1.3.7, 2.0.31
dev-lang/python:     2.4.3-r4
dev-python/pycrypto: 2.0.1-r5
dev-util/ccache:     2.4-r6
dev-util/confcache:  [Not Present]
sys-apps/sandbox:    1.2.17
sys-devel/autoconf:  2.13, 2.60
sys-devel/automake:  1.5, 1.6.3, 1.7.9-r1, 1.9.6-r2, 1.10
sys-devel/binutils:  2.16.1-r3
sys-devel/gcc-config: 1.3.14
sys-devel/libtool:   1.5.22
virtual/os-headers:  2.6.19.2-r2
ACCEPT_KEYWORDS="amd64"
AUTOCLEAN="yes"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=opteron -O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/X11/xkb"
CONFIG_PROTECT_MASK="/etc/env.d /etc/env.d/java/ /etc/gconf /etc/java-config/vms/ /etc/terminfo"
CXXFLAGS="-march=opteron -O2 -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoconfig candy distlocks metadata-transfer sandbox sfperms strict"
GENTOO_MIRRORS="http://distfiles.gentoo.org http://distro.ibiblio.org/pub/linux/distributions/gentoo"
MAKEOPTS="-j2"
PKGDIR="/usr/portage/packages"
PORTAGE_RSYNC_EXTRA_OPTS=""
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'"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage /usr/portage/local/layman/webapps-experimental /usr/portage/local/layman/sunrise"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="3dnow 3dnowext S3TC X X509 Xaw3d a52 aac aalib acl acpi activefilter ada admin adns aiglx aim akode alsa alsa_pcm_plugins_adpcm alsa_pcm_plugins_alaw alsa_pcm_plugins_asym alsa_pcm_plugins_copy alsa_pcm_plugins_dmix alsa_pcm_plugins_dshare alsa_pcm_plugins_dsnoop alsa_pcm_plugins_empty alsa_pcm_plugins_extplug alsa_pcm_plugins_file alsa_pcm_plugins_hooks alsa_pcm_plugins_iec958 alsa_pcm_plugins_ioplug alsa_pcm_plugins_ladspa alsa_pcm_plugins_lfloat alsa_pcm_plugins_linear alsa_pcm_plugins_meter alsa_pcm_plugins_mulaw alsa_pcm_plugins_multi alsa_pcm_plugins_null alsa_pcm_plugins_plug alsa_pcm_plugins_rate alsa_pcm_plugins_route alsa_pcm_plugins_share alsa_pcm_plugins_shm alsa_pcm_plugins_softvol amarok amd amd64 amr ansi aotuv apache2 artworkextra asf audacious audiofile authdaemond automount avantgo bash-completion bcmath bdf berkdb bidi big-tables blender-game bluetooth branding browserplugin bzip2 cairo cap caps ccache cdda cddb cdinstall cdio cdparanoia cdr cdrom cgi chroot cjk clanJavaScript clanVoice cle266 clearcase client cluster codecs cpudetection cracklib crypt css curlwrappers custom-cflags cvs dbus dga dhcp dio directfb diskio djbfft dlloader dmi dnd dpms dri dts dv dvb dvd dvdr dvdread dvi eap-tls edl eep elf elibc_glibc emul-linux-x86 encode erandom evo exif expat exscalibar ext-png ext-zlib extensions extraengine extrafilters fame fastcgi fat fbcon ffmpeg fftw firefox flac fltk fluidsynth fmod font-server fontconfig foomaticdb fortran fpx freewnn fuse gb gcc64 gcl gd geoip ggi gif gimp gimpprint ginac glade glgd glitz gmtfull gnokii gnome gnome-print gnomedb gnuplot gnutls gpgme gphoto2 gpm graphicsmagick graphviz gs gsl gtk gtk2 gtkhtml guile hal hardened hardenedphp haskell hbci hddtemp hdf hfs howl icq ide idl idn ifp image imagemagick imap imlib immqt-bc innodb input_devices_evdev input_devices_joystick input_devices_keyboard input_devices_mouse ipod ipv6 irda irmc ithreads jabber java java5 javacomm javamail javascript jbig jboss jce jfs jms jmx john joystick jpeg jpeg2k jpgraph jta junit justify jython kakasi kde kerberos kernel_linux lame latex lcd_devices_bayrad lcd_devices_cfontz lcd_devices_cfontz633 lcd_devices_glk lcd_devices_hd44780 lcd_devices_lb216 lcd_devices_lcdm001 lcd_devices_mtxorb lcd_devices_ncurses lcd_devices_text lcms ldap leim libclamav libdsk libgda libnotify libsamplerate libvisual libwww live lm_sensors log4j logitech-mouse logrotate logwatch lua lzo lzw m17n-lib mad madwifi maildir matroska mdb midi migemo mikmod mime mixer mjpeg mmap mng modplug mono motif mozbranding mozsvg mozxmlterm mp3 mp4 mp4live mpeg mpeg2 mpi mplayer mpm-worker msn mssql mule musepack music musicbrainz mysql mysqli nagios-dns nagios-ntp nagios-ping nagios-ssh nautilus ncurses net netcdf network neural nfs nls nowin nptl nptlonly nsplugin ntfs ntlm numeric nxclient oav objc ocaml odbc offensive ofx ogg on-the-fly-crypt openal openexr opengl oracle oscar ospfapi oss pam pam_chroot pam_console pam_timestamp parse-clocks pascal pcap pcntl pcre pda pdf perforce perl pg-hier pg-intdatetime pg-vacuumdelay php physfs pic pike plotutils png portaudio posix postgres povray pri print procmail pthreads python qt3 qt4 quicktime quotas quotes radius rdesktop readline reiser4 reiserfs resperl rhino rle rogue rplay rpm ruby samba sametime sasl scanner sdl server servlet-2.3 servlet-2.4 servletapi sftplogging shared sharedmem silc skk slp smime sndfile snmp snortsam socks5 softquota sox speex spell sql sqlite sqlite3 sse sse2 ssl stencil-buffer stroke struts subversion svg swat sysfs syslog sysvipc szip t1lib tcl tcltk tcpd tcsim test tetex tga theora threads tidy tiff tk transcode truetype uim unicode urandom usb userland_GNU userlocales utf8 v4l v4l2 vcd vda vhosts video_cards_fbdev video_cards_mach64 video_cards_vesa video_cards_vga videos virus-scan vnc vorbis wddx wifi winbind wma wmf wxwindows x264 xanim xatrix xchatdccserver xext xface xfs xgetdefault xine xinerama xinetd xml xml2 xmlrpc xorg xosd xpm xrandr xscreensaver xslt xv xvid xvmc yahoo yp yv12 zeroconf zip zlib zvbi"
Unset:  CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LC_ALL, LDFLAGS, LINGUAS
Comment 2 Kevin F. Quinn (RETIRED) gentoo-dev 2007-02-06 08:17:38 UTC
This is because it's using the local-exec TLS model (indicated by the R_X86_64_TPOFF32 relocation type), which only works non-PIC.

Short of patching gcc to generate PIC code for the local-exec TLS model, the only way to fix this is to alter the relevant code to use a different model (initial-exec is ok).

Actually, it looks like the mono code is designed to cope with this; switching to the initial-exec model when built PIC.  The problem is that it's conditional on '#ifdef PIC'.  Patch to follow.
Comment 3 Kevin F. Quinn (RETIRED) gentoo-dev 2007-02-06 08:18:52 UTC
Created attachment 109301 [details, diff]
Allow mono-compiler.h to trigger on __PIC__ for PIC code.
Comment 4 Kevin F. Quinn (RETIRED) gentoo-dev 2007-02-06 09:11:02 UTC
Created attachment 109309 [details, diff]
Allow mono-compiler.h to trigger on __PIC__ for PIC code.

Actually, this is probably better - uses the initial-exec version when building PIE instead of local-dynamic.  initial-exec is quite a bit faster, but can only be used in executables not shared libraries.  Presumably the mono build defines PIC when building for shared libraries (which is a standard libtool thing to do) so if __PIC__ is defined (i.e. compiler is -fPIC or -fPIE) but PIC isn't, then we must be -fPIE and building for an executable.
Comment 5 Michael Crawford (ali3nx) 2007-02-06 22:40:13 UTC
compile tested today in the same chroot. works for me

>>> Regenerating /etc/ld.so.cache...
>>> Original instance of package unmerged safely.
>>> Regenerating /etc/ld.so.cache...
>>> dev-lang/mono-1.2.2.1 merged.

>>> No packages selected for removal by clean.

>>> Auto-cleaning packages...

>>> No outdated packages were found on your system.


 * GNU info directory index is up-to-date.

hammer mono # gcc-config -l
 [1] x86_64-pc-linux-gnu-3.4.6 *
 [2] x86_64-pc-linux-gnu-3.4.6-hardenednopie
 [3] x86_64-pc-linux-gnu-3.4.6-hardenednopiessp
 [4] x86_64-pc-linux-gnu-3.4.6-hardenednossp
 [5] x86_64-pc-linux-gnu-3.4.6-vanilla
Comment 6 Peter Johanson (RETIRED) gentoo-dev 2007-02-06 22:43:35 UTC
Please don't close bugs as WORKSFORME if it's something that hasn't actually hit portage yet. Thanks.
Comment 7 Jurek Bartuszek (RETIRED) gentoo-dev 2007-07-01 19:20:13 UTC
Is this bug still present with mono-1.2.4?
Comment 8 Julian Sasse 2007-09-04 21:21:09 UTC
This bug IS still a problem with mono-1.2.4.
Kevin's patch to define PIC and PIC_INITIAL_EXEC in mono-compiler.h fixes the linking error for 1.2.4 as well (at least in my test on hardened/amd64/multilib).
Disclaimer: I haven't tested to see if/how well mono 1.2.4 works now in hardened profile, but at least it compiles and links OK with this patch.
Comment 9 Jurek Bartuszek (RETIRED) gentoo-dev 2007-09-09 22:43:01 UTC
This patch has just been commited to upstream (mono) svn repository (see http://bugzilla.ximian.com/show_bug.cgi?id=82772). Our 1.2.4 and 1.2.5 releases are going to be patched soon (hopefully). 
Comment 10 Jurek Bartuszek (RETIRED) gentoo-dev 2007-09-10 19:11:16 UTC
Fixed in CVS, thanks