X with DRI. At last! Can Someone else try?

Declan Moriarty junk_mail at iol.ie
Mon Jan 30 13:45:39 PST 2006


There's no need to read unless you're interested in X. I have
book changes & the patch mentioned on another email

On X & DRI:

I can't give you a fps, because glxgears gets a swift knee in the
privates from the kernel when it tries to run, but glxinfo tells me 
I have dri. I have filed a bug agaiunst glxgears.

>From /var/log/sys.log:
Jan 30 04:45:33 genius kernel: grsec: denied resource overstep by
requesting 4096 for RLIMIT_CORE against limit 0 for
/usr/X11R6/bin/glxgears[glxgears:21911] uid/euid:0/0 gid/egid:0/0, 
parent /bin/bash[bash:16020] uid/euid:0/0gid/egid:0/0

Here is what seems like the process, and if anyone else is going
to build xorg-6.9.0, I would like to hear results.

1. Xorg can't use ld -z now. X also uses gcc to do the linking. To
achieve this, alter the specs file
cd /usr/lib/gcc/i686-*/3.4.4
cp specs  specs.orig
vim +135 specs & remove this bit  ' %{!nonow: -z now}' from the
middle of the line.
:wq 
cp specs specs.softlink

2. Untar X11R6.9.0-src1-7  and cd into xc
3. cd extras/Mesa and put in the patch for libGL.so.1.2 from the
Pax team
	Patch -Np1 -i ../../../mesa-6.4-pic-notextrel.patch
http://bugs.freedesktop.org/show_bug.cgi?id=4197	

3. Cd back to ~/xc and issue 'touch config/imake/imakemdep.cpp.h' 

4. All sed commands from the xorg-6.8.2 instructions

find programs/ -type f -name Imakefile | sed -e '/Xserver/d' | \
    xargs sed -e '1,0s/^/CFLAGS+=-pie -fpie\n&/' -i

sed -e '1,0s/^/CFLAGS+=-pie -fpie\n&/' -i programs/Xserver/Imakefile    

sed -e 's/^CFLAGS.*$/& -pie -fpie/' -i programs/xterm/Makefile.in

And this one of mine

sed -e '/RPCLIB =/d' -i programs/xdm/Imakefile

Build lndir if you need it. Update your locate database.
You now need to remove any existing version of libGL.so.1.2 before
building, as well as any library linked against it
You might find this handy

cat > check-textrel << "EOF"
#!/bin/sh
get_textrel() {
        exe=$1
        echo -- $exe --
        if file $exe | grep "ELF " >/dev/null  ; then
                readelf -d $exe 2>/dev/null | grep TEXTREL
2>&1>/dev/null && echo TEXTREL in exe $exe
                ldd $exe | awk '{print $3}' | while read lib; do
                        readelf -d $lib | grep TEXTREL
2>&1>/dev/null && echo TEXTREL library $lib exec $exe
                done
        fi
}

if [ "$1" = "" ]; then
        echo Usage: $0 "<path/filename>"
        #exit 1
        #paths=`echo ${PATH} | tr ':' '\n'`
fi

for exe in "$@" $paths ; do
        [ -f $exe ] && get_textrel $exe
        [ -d $exe ] && (
                for e in $exe/* ; do
                get_textrel $e
                done
        )
done
EOF		

Put this script (from the gentoo-hardened website) into your path
If /usr/X11R6/lib or /usr/X11R6/bin exist and have files,  run
this command

check-textrel * |grep TEXTREL 

in /usr/X11R6/bin, in /usr/X11R6/lib, & in /usr/X11R6/lib/modules.
I found textrels in these files

libGL.so;	libGLU.so	libOSMesa.so; 	libGLw.so
glxinfo		glxgears;	xdriinfo;	radeon_dri.so

Anything with textrels will have to go. Things will link against
libs in particular, and you will have assembler & non-pic instructions
hardcoded in which leads to exotic positioning errors if you have
CONFIG_PAX_NOELFRELOCS set in your kernel. It is an essential part
of security, so it should be set. Make sure
also to check /lib, as kernel modules in particular refer there.

BEWARE OF SYMLINKS! symlinks show as textrel free, whether the
file they point at is textrel free or not. This little bit of
knowledge saves you considerable pain and frustration.
Libs from X are stored this way: libGL.so, libGL.so.1 will both be
symlinks pointing to libGL.so.1.2. Everything references the .so
or the major version, and few things try to guess minor versions.

Instead of  the 6.8.2 instruction, use

install -d ../xcbuild/exports/include/X11 (making 4 directories)
cd ../xcbuild

The host.def from xorg-6.8.2 can be used with these additions
#define BuildXF86DRI     YES
#define BuildXterm      YES (Presuming you want it :-)

Make it as per Xorg-6.8.2.
Finish as per Xorg-6.8.2 instructions with these differences

Make sure the textrel free versions of libGL.so etc have been
used. The binaries are positioned in xcbuild/programs/filename, and the
libs in xcbuild/lib/obvious-name e.g. lib/GL for libGL If you find
textrels, use ldd to see what it linked against. Most will remake
simply as long as the compiled xcbuild is intact. Remove the
binary, the .o, and DONE if it exists and type make from the
correct directory.

make install
make install.man
ln -sf ../X11R6/bin /usr/bin/X11
ln -sf ../X11R6/lib/X11 /usr/lib/X11
ln -sf ../X11R6/include/X11 /usr/include/X11

rm /usr/X11R6/lib/lib{Xau,Xdmcp,oldX,XprintUtil,XprintAppUtil}.a
rm /usr/X11R6/lib/lib{OSMesa,dmx,Xfont,fntstubs,xf86config}.a

echo "/usr/X11R6/lib" >> /etc/ld.so.conf
ldconfig
cat >> /etc/sysconfig/createfiles << "EOF"
/tmp/.ICE-unix dir 1777 root root
EOF

Now restore the original gcc specs file modified for X.

About your kernel:

1. The only acceptable mention of DRM in the kernel is
# CONFIG_DRM is not set
Anything else breaks the DRM code. Don't ask me - I just found
out.

2. You need to keep the compiled Xorg source, and the compiled
kernel source if you are to have a hope of getting the Radeon DRM
functional. Make it so.

3. You also may need 'forced unloading of kernel modules' if you 
have framebuffer support compiled in. 

DRI:
I downloaded a nightly build. Any attempt to check out the source
from cvs and make that only ends in tears. God help anyone trying
to handle Mesa through Xorg-7.0.0. God might, but the guys in DRI
think only programmers should approach this. In the nightly build,
binary libs are provided which are linked against a libGL.so.1.2
containing textrels. I ended up with a common-20060126-linux-pc
and a radeon-20060126-linux-pc archive.

The common archive will have been installed by X linked against
your textrel free version of libGL.so. It's unnecessary

The radeon archive makes kernel modules. Here we go:

cd radeon-*/
ls -l radeon (showed me a version of radeon_dri.so containing the
poison textrels). Make sure all others in your driver pack are
textrel free. My textrel-free radeon_dri.so was in
xcbuild/lib/GL/mesa/drivers/dri/radeon. Copy it in. This is bad
practise (swapping libs between versions) If hassle starts, use
the archive dated 20051220 (Installed in xorg-6.9.0)

cp /usr/X11R6/lib/modules/radeon_dri.so radeon/ (Overwrites it)
You should now be textrel free. CHECK!

Put the line
CFLAGS+= -no-pie -fno-stack-protector-all

in before the real data in radeon-*/drm/linux-core/Makefile.kernel
That instruction will save you considerable pain.

The install.sh in radeon-* is something I formed an intimate
relationship with. Try these steps

sed 's/which/type -p/' -i install.sh (Unless you installed which.)

Next, mimick the DRI's "SuSE" setup:

cp <kernel source>/.config /boot/vmlinuz.config
cp <kernel source>/include/linux/autoconf.h /boot/vmlinuz.autoconf.h
cp <kernel-source>/include/linux/version.h /boot/vmlinuz.version.h

SuSE no longer provides these files, I am informed, but the guys in
DRI haven't found out yet :-D. This just spoonfeeds the install.sh
so it gets versions correct.

Now, finally, run ./install.sh. Make sure to use the same compiler
as you compiled your kernel with. Stop X before starting this
compile. Restart, and you just might have dri.

See my email on book suggestions for the patch.
-- 

	With best Regards,


	Declan Moriarty.



More information about the hlfs-dev mailing list