1 # -*- coding: utf-8 -*-
3 # kate: space-indent on; indent-width 2; mixedindent off; indent-mode python;
5 # Copyright (C) 2009 Amand 'alrj' Tihon <amand.tihon@alrj.org>
7 # This file is part of bold, the Byte Optimized Linker.
9 # You can redistribute this file and/or modify it under the terms of the
10 # GNU General Public License as published by the Free Software Foundation,
11 # either version 3 of the License or (at your option) any later version.
13 """Define all the exceptions."""
15 class NotRelocatableObject(Exception):
16 """Raised when an input file is not a relocatable ELF object."""
17 def __init__(self, path):
20 return "File '%s' is not a relocatable object file" % self.path
22 class UnsupportedObject(Exception):
23 """Raised when an input file is not of a supported arch."""
24 def __init__(self, path, reason):
28 return "File '%s' is not supported: %s" % (self.path, self.reason)
30 class LibNotFound(Exception):
31 """Raised if a shared library could not be found."""
32 def __init__(self, libname):
33 self.libname = libname
35 return "Cannot find shared library for '%s'" % self.libname
37 class UndefinedSymbol(Exception):
38 """Raised if a symbol is referenced but not declared."""
39 def __init__(self, symbol_name):
40 self.symbol = symbol_name
42 return "Undefined reference to '%s'" % self.symbol
44 class RedefinedSymbol(Exception):
45 """Raised if a symbol is defined more than once."""
46 def __init__(self, symbol_name):
47 self.symbol = symbol_name
49 return "Symbol '%s' is declared twice" % self.symbol