Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug
Bug#: 165547
Alias:
Product:
Component:
Status: RESOLVED
Resolution: FIXED
Assigned To: The Gentoo Linux Hardened Team <hardened@gentoo.org>
Hardware:
OS:
Version:
Priority:
Severity:
Reporter: Mike Crawford <ali3nx@eliteitminds.com>
Add CC:
CC:
Remove selected CCs
URL:
Summary:
Status Whiteboard:
Keywords:

Filename Description Type Creator Created Size Actions
mono-pictls.patch Allow mono-compiler.h to trigger on __PIC__ for PIC code. patch Kevin F. Quinn (RETIRED) 2007-02-06 08:18 0000 395 bytes Details | Diff
mono-pictls.patch Allow mono-compiler.h to trigger on __PIC__ for PIC code. patch Kevin F. Quinn (RETIRED) 2007-02-06 09:11 0000 515 bytes Details | Diff
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 165547 depends on: Show dependency tree
Bug 165547 blocks:
Votes: 0    Show votes for this bug    Vote for this bug

Additional Comments: (this is where you put emerge --info)


Not eligible to see or edit group visibility for this bug.






View Bug Activity   |   Format For Printing   |   XML   |   Clone This Bug


Description:   Opened: 2007-02-06 02:18 0000
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 From Mike Crawford 2007-02-06 03:07:37 0000 -------
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 From Kevin F. Quinn (RETIRED) 2007-02-06 08:17:38 0000 -------
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 From Kevin F. Quinn (RETIRED) 2007-02-06 08:18:52 0000 -------
Created an attachment (id=109301) [details]
Allow mono-compiler.h to trigger on __PIC__ for PIC code.

------- Comment #4 From Kevin F. Quinn (RETIRED) 2007-02-06 09:11:02 0000 -------
Created an attachment (id=109309) [details]
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 From Mike Crawford 2007-02-06 22:40:13 0000 -------
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 From Peter Johanson (RETIRED) 2007-02-06 22:43:35 0000 -------
Please don't close bugs as WORKSFORME if it's something that hasn't actually
hit portage yet. Thanks.

------- Comment #7 From Jurek Bartuszek 2007-07-01 19:20:13 0000 -------
Is this bug still present with mono-1.2.4?

------- Comment #8 From Julian Sasse 2007-09-04 21:21:09 0000 -------
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 From Jurek Bartuszek 2007-09-09 22:43:01 0000 -------
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 From Jurek Bartuszek 2007-09-10 19:11:16 0000 -------
Fixed in CVS, thanks

Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug