Bug#319298: Xorg segfaults on alpha due to unhandled relocations
Package: xserver-xorg
Version: 6.8.2.dfsg.1-3
Severity: grave
Tags: patch
As reported on debian-alpha, trying to run xorg-xserver on alpha outputs
a large number of
Elf_RelocateEntry() Unsupported relocation type 28
messages and then segfaults. Once again, the toolchain has moved the
bar for ELF support.
#include "elfloader_must_die.h"
Although so far the two people seeing this bug both use the MGA driver,
I don't have any reason to believe it's particularly driver-specific,
hence the severity. In any case, it's definitely a bug in the
elfloader, not a bug in the driver; as evidenced by the fact that the
error is not reproducible with the statically-linked xserver-xorg-dbg.
The attached patch, which comes from upstream by way of Jay Estabrook
at HP, adds the necessary handling for the additional relocation type on
Alpha, fixing the latest segfault. As per the name, it should slip
right into the patches directory at #305; if you want to move it down to
#203 next to the other alpha reloc fix that it depends on, you'll have
to fix up the offsets in patch 303_arm_cache_flush.diff as well.
-- Package-specific info:
VGA-compatible devices on PCI bus:
0000:00:05.0 VGA compatible controller: Matrox Graphics, Inc. MGA 2164W [Millennium II]
Xorg X server configuration file status:
-rw-r--r-- 1 root root 3438 2005-07-19 12:13 /etc/X11/xorg.conf
Contents of /etc/X11/xorg.conf:
# XF86Config-4 (XFree86 X server configuration file) generated by dexconf, the
# Debian X Configuration tool, using values from the debconf database.
#
# Edit this file with caution, and see the XF86Config-4 manual page.
# (Type "man XF86Config-4" at the shell prompt.)
#
# This file is automatically updated on xserver-xfree86 package upgrades *only*
# if it has not been modified since the last upgrade of the xserver-xfree86
# package.
#
# If you have edited this file but would like it to be automatically updated
# again, run the following commands as root:
#
# cp /etc/X11/XF86Config-4 /etc/X11/XF86Config-4.custom
# md5sum /etc/X11/XF86Config-4 > /var/lib/xfree86/XF86Config-4.md5sum
# dpkg-reconfigure xserver-xfree86
Section "Files"
FontPath "unix/:7100" # local font server
# if the local font server has problems, we can fall back on these
FontPath "/var/lib/defoma/x-ttcidfont-conf.d/dirs/CID"
FontPath "/var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType"
FontPath "/usr/lib/X11/fonts/Type1"
FontPath "/usr/lib/X11/fonts/CID"
FontPath "/usr/lib/X11/fonts/Speedo"
FontPath "/usr/lib/X11/fonts/misc"
FontPath "/usr/lib/X11/fonts/cyrillic"
FontPath "/usr/lib/X11/fonts/100dpi"
FontPath "/usr/lib/X11/fonts/75dpi"
EndSection
Section "Module"
Load "GLcore"
Load "bitmap"
Load "dbe"
Load "ddc"
Load "dri"
Load "extmod"
Load "freetype"
Load "glx"
Load "int10"
Load "record"
Load "speedo"
Load "type1"
Load "vbe"
Load "xaa"
Load "libi2c"
EndSection
Section "InputDevice"
Identifier "Generic Keyboard"
Driver "keyboard"
Option "CoreKeyboard"
Option "XkbRules" "xfree86"
Option "XkbModel" "microsoft"
Option "XkbLayout" "dv_intl"
EndSection
Section "InputDevice"
Identifier "Configured Mouse"
Driver "mouse"
Option "CorePointer"
Option "Device" "/dev/psaux"
Option "Protocol" "PS/2"
Option "ZAxisMapping" "4 5"
EndSection
Section "InputDevice"
Identifier "Generic Mouse"
Driver "mouse"
Option "SendCoreEvents" "true"
Option "Device" "/dev/input/mice"
Option "Protocol" "ImPS/2"
Option "ZAxisMapping" "4 5"
EndSection
Section "Device"
Identifier "Matrox Millennium II"
Driver "mga"
Option "UseFBDev"
BusID "0:5:0"
EndSection
Section "Device"
Identifier "nVidia GeForce2 MX 400"
Driver "nv"
EndSection
Section "Monitor"
Identifier "CTX 17"
HorizSync 30-92
VertRefresh 50-85
Option "DPMS"
EndSection
Section "Screen"
Identifier "Default Screen"
Device "Matrox Millennium II"
Monitor "CTX 17"
DefaultDepth 24
SubSection "Display"
Depth 1
Modes "1280x1024" "1152x864" "1024x768" "800x600" "640x480"
EndSubSection
SubSection "Display"
Depth 4
Modes "1280x1024" "1152x864" "1024x768" "800x600" "640x480"
EndSubSection
SubSection "Display"
Depth 8
Modes "1280x1024" "1152x864" "1024x768" "800x600" "640x480"
EndSubSection
SubSection "Display"
Depth 15
Modes "1280x1024" "1152x864" "1024x768" "800x600" "640x480"
EndSubSection
SubSection "Display"
Depth 16
Modes "1280x1024" "1152x864" "1024x768" "800x600" "640x480"
EndSubSection
SubSection "Display"
Depth 24
Modes "1280x1024" "1152x864" "1024x768" "800x600" "640x480"
EndSubSection
EndSection
Section "ServerLayout"
Identifier "Default Layout"
Screen "Default Screen"
InputDevice "Generic Keyboard"
InputDevice "Configured Mouse"
InputDevice "Generic Mouse"
EndSection
Section "DRI"
Mode 0666
EndSection
-- System Information:
Debian Release: testing/unstable
APT prefers unstable
APT policy: (500, 'unstable'), (500, 'testing')
Architecture: alpha
Shell: /bin/sh linked to /bin/bash
Kernel: Linux 2.4.27-2-generic
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Versions of packages xserver-xorg depends on:
ii debconf [debconf-2.0] 1.4.52 Debian configuration management sy
ii libc6.1 2.3.2.ds1-22 GNU C Library: Shared libraries an
ii libselinux1 1.24-1 SELinux shared libraries
ii libxau6 6.8.2.dfsg.1-3 X Authentication library
ii libxdmcp6 6.8.2.dfsg.1-3 X Display Manager Control Protocol
ii xserver-common 6.8.2.dfsg.1-3 files and utilities common to all
ii zlib1g 1:1.2.2-9 compression library - runtime
diff -ru3 ./xc/programs/Xserver/hw/xfree86/loader/elf.h ../build-tree.new/xc/programs/Xserver/hw/xfree86/loader/elf.h
--- ./xc/programs/Xserver/hw/xfree86/loader/elf.h 2005-07-20 04:06:55.000000000 -0700
+++ ../build-tree.new/xc/programs/Xserver/hw/xfree86/loader/elf.h 2005-07-20 03:53:22.000000000 -0700
@@ -273,6 +273,7 @@
#define R_ALPHA_GLOB_DAT 25 /* Create GOT entry */
#define R_ALPHA_JMP_SLOT 26 /* Create PLT entry */
#define R_ALPHA_RELATIVE 27 /* Adjust by program base */
+#define R_ALPHA_BRSGP 28 /* Calc displacement for BRS */
/* IA-64 relocations. */
#define R_IA64_NONE 0x00 /* none */
diff -ru3 ./xc/programs/Xserver/hw/xfree86/loader/elfloader.c ../build-tree.new/xc/programs/Xserver/hw/xfree86/loader/elfloader.c
--- ./xc/programs/Xserver/hw/xfree86/loader/elfloader.c 2005-07-20 05:13:47.000000000 -0700
+++ ../build-tree.new/xc/programs/Xserver/hw/xfree86/loader/elfloader.c 2005-07-19 13:57:50.000000000 -0700
@@ -1623,6 +1623,53 @@
break;
}
+ case R_ALPHA_BRSGP:
+ {
+ Elf_Sym *syms;
+ int Delta;
+
+ dest32 = (unsigned int *)((secp + rel->r_offset) + rel->r_addend);
+
+# ifdef ELFDEBUG
+ ELFDEBUG("R_ALPHA_BRSGP %s\t",
+ ElfGetSymbolName(elffile, ELF_R_SYM(rel->r_info)));
+
+ ELFDEBUG("secp=%lx\t", secp);
+ ELFDEBUG("symval=%lx\t", symval);
+ ELFDEBUG("dest32=%lx\t", dest32);
+ ELFDEBUG("*dest32=%8.8x\t", *dest32);
+# endif
+ syms = (Elf_Sym *) elffile->saddr[elffile->symndx];
+
+ if (syms[ELF_R_SYM(rel->r_info)].st_other & 0x8)
+ Delta = -4;
+ else
+ Delta = 4;
+
+ symval -= (Elf_Addr) (((unsigned char *)dest32) + Delta);
+ if (symval % 4) {
+ ErrorF("R_ALPHA_BRSGP bad aligment of offset\n");
+ }
+ symval = symval >> 2;
+
+# ifdef ELFDEBUG
+ ELFDEBUG("symval=%lx\t", symval);
+# endif
+
+ if (symval & 0xffe00000) {
+# ifdef ELFDEBUG
+ ELFDEBUG("R_ALPHA_BRSGP symval too large\n");
+# endif
+ }
+
+ *dest32 = (*dest32 & ~0x1fffff) | (symval & 0x1fffff);
+
+# ifdef ELFDEBUG
+ ELFDEBUG("*dest32=%8.8x\n", *dest32);
+# endif
+ break;
+ }
+
#endif /* alpha */
#if defined(__mc68000__)
case R_68K_32:
Reply to: