Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 24 Sep 2008 13:25:14 +1000
From:      Callum Gibson <callumgibson@optusnet.com.au>
To:        freebsd-x11@freebsd.org
Subject:   Working! (was Re: Matrox G550 fails dual-head, used to work)
Message-ID:  <20080924032514.GA19313@omma.gibson.athome>
In-Reply-To: <20080903204028.GA17408@omma.gibson.athome>
References:  <alpine.BSF.1.10.0808132106190.11861@wonkity.com> <20080903204028.GA17408@omma.gibson.athome>

next in thread | previous in thread | raw e-mail | index | archive | help
On 04Sep08 06:40, Callum Gibson wrote:
}to be willing to do), the only other option is to use the linux binary
}driver from the ports. This also used to work, and apparently people have
}it working under 6.X, but under 7.X you get:
}
}http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/117907
}
}I'm beginning to think this will be the only way to get dual dvi going
}for matrox cards, but it seems to involve addressing a problem with the
}linuxulator which I don't yet understand.

I've worked out how to get the linux mga_hal driver to work under 7.X
and now have dual DVI screens working with my G550 again!  It turns out
to have nothing to do with linux emulation at all.

Apparently mga_hal only ever worked because Xorg loaded in the linux .so
files directly, and likewise the linux libs pulled in the FreeBSD
libc.so.6, not the linux libc - no emulation required. This is arguably
not meant to work, but I guess both systems use gcc and there are no
system calls so it happens to work.

Ok, so after installing mga_hal from ports you'll have 2 new .so files
in /usr/local/lib/modules/drivers. You'll need to symlink or copy these
to where Xorg 7.3 expects to find them, which is
/usr/local/lib/xorg/modules/drivers.  Note, if you have xf86-video-mga
installed you might want to back up the previous version of mga_drv.so.
You might also want to copy the files so if you make a mistake and mangle
the mga_hal libraries you can start again.

One this is done, you should see the GLIBC dependency error as per PR
117907 when you try to start Xorg.  For whatever reason, something in
the runtime linker has changed between FreeBSD 6.X and 7.X so that it
picks up a version dependency in mga_drv.so and mga_hal_drv.so, even
though it's marked as a weak symbol from what I can tell. You can see
this by running:

% readelf -V /usr/local/lib/xorg/modules/drivers/mga_drv.so

At the bottom you will see:

Version needs section '.gnu.version_r' contains 1 entries:
 Addr: 0x0000000000003de0  Offset: 0x003de0  Link to section: 3 (.dynstr)
  000000: Version: 1  File: libc.so.6  Cnt: 1
  0x0010:   Name: GLIBC_2.1.3  Flags: none  Version: 2

You can run the following to see all the version info that is causing problems.

% readelf -a /usr/local/lib/xorg/modules/drivers/mga_drv.so |grep VER
  [ 4] .gnu.version      VERSYM          00003aee 003aee 0002f0 02   A  2   0  2
  [ 5] .gnu.version_r    VERNEED         00003de0 003de0 000020 00   A  3   1  4
 0x6ffffffe (VERNEED)                    0x3de0
 0x6fffffff (VERNEEDNUM)                 1
 0x6ffffff0 (VERSYM)                     0x3aee

Now, you need to hack both the linux .so files to eliminate this dependency.
Eliminating the version sections is the easy bit. As root from
/usr/local/lib/xorg/modules/drivers...

# objcopy -R .gnu.version -R .gnu.version_r mga_drv.so
# objcopy -R .gnu.version -R .gnu.version_r mga_hal_drv.so

We also need to remove references to those sections from the Dynamic segment
so the linker doesn't still go looking for them. You can find the relevant
parts by doing this:

The first hex number should be the same (maps to the tag type), but the
second column of numbers (the value) might be different depending on
your library. You will see the same tags in mga_hal_drv.so (with different
values again).

Now for the tricky bit. You need to edit the .so file with a hex editor
(eg. editors/hexedit in port) and search for the tags. Note, in hexedit, the
tag's hex value is byte-swapped on little endian machines. So I search for
feffff6f (rather than 6ffffffe) to find the VERNEED tag and after that
you will see (using my values above) "E0 3D". Here is the whole relevant
line as displayed in hexedit:

000354C0   FE FF FF 6F  E0 3D 00 00  FF FF FF 6F  01 00 00 00  F0 FF FF 6F  EE 3A

You need to null out the tag and values entirely. In other words write over
"FE FF FF 6F  E0 3D" with zeroes. Likewise "FF FF FF 6F  01" and
"F0 FF FF 6F  EE 3A".

After saving, try:

% readelf -a /usr/local/lib/xorg/modules/drivers/mga_drv.so |grep VER

again, and there should be no output. Repeat editing on mga_hal_drv.so.

As per other posts on this issue, you can now run Xorg -ignoreABI and
it will successfully load up the linux .so files, and resolve the libc.so.6
reference against compat6x's libc.so.6 in /usr/local/lib/compat. You'll
probably still need an appropriate xorg.conf for xinerama to work, but
you should not have the GLIBC fatal error.

The only other issue I have had since is that I noticed my window titles
weren't redrawing properly and then starting firefox caused a crash. I
removed BackingStore option, which I'd inherited from someone's xorg.conf,
and that seems to have fixed the problem. So far, so good. All the other
usual stuff is there, including subpixel rendering for font smoothing.

I'm not sure if there is a way to do that hexediting in ports for 7.X
machines or if a pre-hacked version of the libs could be distributed.

    C

-- 

Callum Gibson @ home
http://members.optusnet.com.au/callumgibson/



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080924032514.GA19313>