X-Git-Url: https://git.alrj.org/?p=bold.git;a=blobdiff_plain;f=Bold%2Flinker.py;h=625a28d995de623e54e1c14435b004443e7d59fc;hp=0f447c1a8f470067ada9e65f504111a285f1a0e7;hb=2f6e3bc47112f6d0fc38f4898752a10d16630ba6;hpb=c0dd0c5834446604965b0be3a9b0bcd78ecf458d diff --git a/Bold/linker.py b/Bold/linker.py index 0f447c1..625a28d 100644 --- a/Bold/linker.py +++ b/Bold/linker.py @@ -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