[haiku-development] Re: Question on Hybrid lib selection & GCC4 games

  • From: Rene Gollent <anevilyak@xxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Sat, 3 Jan 2015 13:51:55 -0500

On  Sat, 03 Jan 2015 10:51:23 -0500, Augustin Cavalier wrote:
> The name mangling format for GCC4 is different than for GCC2, so the
> runtime_loader can detect whether it's loading a GCC2 or GCC4 binary, and then
> select the correct library directory (on GCC2Hybrid, GCC2 libs are in 
> /system/lib
> and GCC4 libs are in /system/lib/x86).

If you're going to answer a technical question about code you've
clearly never actually looked at, then it would behoove you to first
have a look to see if your answer is correct before replying, because
this one isn't in any way whatsoever [1].

The first thing the runtime loader does is look for the haiku version
symbols, which haiku-native binaries built within the past few years
will include. These identify the API version as well as the ABI, and
are used to add compatibility shims in case API behavior changes
between revisions.

For older binaries which do not include this symbol, i.e. older Haiku
binaries and/or BeOS binaries, the .comment ELF section of the binary
is searched for the GCC version string, which in turn is broken down
to determine which compiler generated the code.

Name mangling would be a very error prone and inefficient way to try
and determine the version, as 1) C symbols aren't mangled at all, and
as such couldn't be used to determine the ABI of a C library, and 2)
even for C++ binaries, a mix of mangled and unmangled symbols will be
included, such that one would potentially need to search the entire
symbol table to determine whether there are any such symbols included
at all.

Rene

[1] 
http://cgit.haiku-os.org/haiku/tree/src/system/runtime_loader/elf_haiku_version.cpp

Other related posts: