]> git.alrj.org Git - bold.git/commitdiff
Check for external symbols.
authorAmand Tihon <amand.tihon@alrj.org>
Sat, 15 Aug 2009 18:49:36 +0000 (20:49 +0200)
committerAmand Tihon <amand.tihon@alrj.org>
Sat, 15 Aug 2009 18:52:44 +0000 (20:52 +0200)
Verifies that all undefined symbols can actually be found in the
shared libraries given on the command line.

Bold/linker.py
bold

index 0f447c1a8f470067ada9e65f504111a285f1a0e7..625a28d995de623e54e1c14435b004443e7d59fc 100644 (file)
@@ -18,6 +18,7 @@ from BinArray import BinArray
 from elf import Elf64, Elf64_Phdr, Elf64_Shdr, TextSegment, DataSegment
 from elf import SStrtab, SSymtab, SProgBits, SNobits, Dynamic, Interpreter
 from errors import *
+from ctypes import CDLL
 from ctypes.util import find_library
 import struct
 
@@ -225,6 +226,26 @@ class BoldLinker(object):
     self.shlibs.append(fullname)
 
 
+  def check_external(self):
+    """Verify that all globally undefined symbols are present in shared
+    libraries."""
+    libs = []
+    for libname in self.shlibs:
+      libs.append(CDLL(libname))
+
+    for symbol in self.undefined_symbols:
+      # Hackish ! Eek!
+      if symbol.startswith('_bold__'):
+        continue
+      found = False
+      for lib in libs:
+        if hasattr(lib, symbol):
+          found = True
+          break
+      if not found:
+        raise UndefinedSymbol(symbol)
+
+
   def link(self):
     """Do the actual linking."""
     # Prepare two segments. One for .text, the other for .data + .bss
diff --git a/bold b/bold
index 74428bdcb49f8f089d267d3ca8c73d44ddb3a21e..b33766d6806dbf781a9cef16d4f8dcb5520cff36 100755 (executable)
--- a/bold
+++ b/bold
@@ -121,6 +121,9 @@ def main():
 
   try:
     linker.build_symbols_tables()
+
+    linker.check_external()
+
     linker.build_external(with_jump=options.ccall, align_jump=options.align)
 
     linker.link()