Have noticed that issue during package maintenance for Arch Linux and reporting by Martin Nowak request. Arch Linux automatically verifies all packages targeting official repos with own `namcap` tool. At some point I have noticed it warning me that `libphobos2.so` has text relocations.
This is how package is built:
https://github.com/Dicebot/Arch-PKGBUILDs/blob/master/dmd/PKGBUILD
Essentially it is just `make -f posix.mak MODEL=$_archbits
DMD=$srcdir/dmd/src/dmd RELEASE=1`
$ uname -a
Linux vbox-arch-64 3.11.2-1-ARCH #1 SMP PREEMPT Fri Sep 27 07:35:36 CEST
2013 x86_64 GNU/Linux
$ readelf -d /usr/lib/libphobos2.so | grep TEXTREL
0x0000000000000016 (TEXTREL) 0x0
$ eu-readelf -r /usr/lib/libphobos2.so | wc -l
18615
Just noticed this too. It makes shared libraries unusable on hardened system (like grsecurity).
Comment #3 by safety0ff.bugz — 2013-10-31T14:55:11Z
Duplicate of #5278?
Comment #4 by mk — 2013-10-31T15:07:52Z
(In reply to comment #3)
> Duplicate of #5278?
Likely, but it's not just Gentoo. I use Grsecurity kernel on Debian and get this error:
./prog: error while loading shared libraries: /usr/local/lib/libphobos2.so.0.64: cannot make segment writable for relocation: Permission denied
The only solution is to disable MPROTECT for given exacutable.
http://pax.grsecurity.net/docs/mprotect.txt
Comment #5 by safety0ff.bugz — 2013-10-31T15:10:09Z
(In reply to comment #4)
> (In reply to comment #3)
> > Duplicate of #5278?
>
> Likely, but it's not just Gentoo.
I'm aware, it should probably be renamed.
Comment #6 by code — 2014-02-01T11:03:45Z
Indeed it's a problem that block SELinux out of the box.
I stumbled over this today trying to run a binary with sandbox.
In elfutils there is a small tool to find those relocations
eu-findtextrel
https://fedoraproject.org/wiki/User:Tibbs/Text_Relocation_Guidelines
Seems like it mostly barks about vtblZ and initZ symbols in libphobos2.so.
Those indeed need to contain absolute relocations but they should be data symbols, so I don't yet know what the problem is.
Comment #7 by code — 2014-02-01T16:09:08Z
One cause of this bug is that the .minfo* sections are marked as read-only but require dynamic relocations.
I think we should avoid the relocation and write the complete ModuleInfo into the .minfo sections, currently .minfo holds pointers to ModuleInfos.