Add support for building <stubbed>libroot.so.

* <stubbed>libroot.so is a shared library which contains all the symbols
  from libroot, but without any code. This library will be required by
  the (to be introduced) stage0 of the bootstrap process, in order to
  be able to link the shared gcc syslibs (libstdc++.so, libsupc++.so
  and libgcc_s.so).
This commit is contained in:
Oliver Tappe
2014-08-13 13:32:46 +02:00
parent 1af12dfb22
commit b2883f6a0d
6 changed files with 5311 additions and 0 deletions
+1
View File
@@ -125,3 +125,4 @@ for architectureObject in [ MultiArchSubDirSetup ] {
SubInclude HAIKU_TOP src system libroot add-ons ;
SubInclude HAIKU_TOP src system libroot os ;
SubInclude HAIKU_TOP src system libroot posix ;
SubInclude HAIKU_TOP src system libroot stubbed ;
+28
View File
@@ -0,0 +1,28 @@
SubDir HAIKU_TOP src system libroot stubbed ;
local architectureObject ;
for architectureObject in [ MultiArchSubDirSetup ] {
on $(architectureObject) {
UsePrivateSystemHeaders ;
# Build <stubbed>libroot.so, containing only empty symbols.
local stubsSource ;
if $(TARGET_PACKAGING_ARCH) = x86_gcc2 {
stubsSource = [ FGristFiles libroot_stubs_legacy.c ] ;
} else {
stubsSource = [ FGristFiles libroot_stubs.c ] ;
}
local stubsObject = $(stubsSource:S=$(SUFOBJ)) ;
CCFLAGS on $(stubsObject) = -Wno-missing-prototypes -fno-builtin ;
Depends $(stubsObject) : $(stubsSource) ;
Objects $(stubsSource) ;
local stubbedLibroot
= [ MultiArchDefaultGristFiles libroot.so : stubbed ] ;
local versionScript
= [ FDirName $(HAIKU_TOP) src system libroot libroot_versions ] ;
LINKFLAGS on $(stubbedLibroot)
= -shared -soname=libroot.so --version-script $(versionScript) ;
Ld $(stubbedLibroot) : $(stubsObject) ;
}
}
+65
View File
@@ -0,0 +1,65 @@
#! /usr/bin/env python
import sys;
dataSymbolsByAddress = {}
versionedDataSymbolsByName = {}
functionSymbolsByAddress = {}
versionedFunctionSymbolsByName = {}
for line in sys.stdin.readlines():
if line[0] != '0':
# ignore lines without an address
continue
(address, type, symbol) = line.split()
# select interesting types of symbols
if not type in 'BCDGRSTuVvWw':
continue
# drop symbols from legacy compiler that contain a dot (those produce
# syntax errors)
if '.' in symbol:
continue
if type in 'BD':
if '@' in symbol:
versionedDataSymbolsByName[symbol] = address
else:
dataSymbolsByAddress[address] = symbol
else:
if '@' in symbol:
versionedFunctionSymbolsByName[symbol] = address
else:
functionSymbolsByAddress[address] = symbol
# add data symbols
for dataSymbol in sorted(dataSymbolsByAddress.values()):
print 'int %s;' % dataSymbol
print
# add function symbols
for functionSymbol in sorted(functionSymbolsByAddress.values()):
print 'void %s() {}' % functionSymbol
print
print "#include <symbol_versioning.h>"
print
# add symbol versioning information for data symbols
for symbol in sorted(versionedDataSymbolsByName.keys()):
address = versionedDataSymbolsByName[symbol]
targetSymbol = dataSymbolsByAddress[address]
(symbolName, unused, versionTag) = symbol.partition('LIBROOT_')
print 'DEFINE_LIBROOT_KERNEL_SYMBOL_VERSION("%s", "%s", "%s");' \
% (targetSymbol, symbolName, versionTag)
# add symbol versioning information for function symbols
for symbol in sorted(versionedFunctionSymbolsByName.keys()):
address = versionedFunctionSymbolsByName[symbol]
targetSymbol = functionSymbolsByAddress[address]
(symbolName, unused, versionTag) = symbol.partition('LIBROOT_')
print 'DEFINE_LIBROOT_KERNEL_SYMBOL_VERSION("%s", "%s", "%s");' \
% (targetSymbol, symbolName, versionTag)
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,19 @@
The source file libroot_stubs.c contains empty stubs for all symbols exported by
libroot.so, including definitions of all versioned symbols.
From libroot_stubs.c, <stubbed>libroot.so can be built, which is a stubbed
version of libroot.so (i.e. without any code). This stubbed library is used
during stage 0 of the bootstrap process, in order to build the gcc-syslibs
(libgcc, libsupc++ and libstdc++).
The python script generate_stubs.py can be used to regenerate libroot_stubs.c
from a built version of (the real) libroot.so. This may be necessary when new
symbols have been added to libroot.so.
The command for regenerating libroot_stubs.c is this:
nm <path-to-libroot.so> | generate_stubs.py >libroot.stubs.c
There is a separate version of the stubs file for the legacy compiler (gcc2),
which uses a different symbol mangling format and contains the symbols for
libgcc, too.
File diff suppressed because it is too large Load Diff