]> git.alrj.org Git - bold.git/blob - Bold/errors.py
First support for .gnu.hash/DT_GNU_HASH.
[bold.git] / Bold / errors.py
1 # -*- coding: utf-8 -*-
2
3 # kate: space-indent on; indent-width 2; mixedindent off; indent-mode python;
4
5 # Copyright (C) 2009 Amand 'alrj' Tihon <amand.tihon@alrj.org>
6 #
7 # This file is part of bold, the Byte Optimized Linker.
8 #
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.
12
13 """Define all the exceptions."""
14
15 class NotRelocatableObject(Exception):
16   """Raised when an input file is not a relocatable ELF object."""
17   def __init__(self, path):
18     self.path = path
19   def __str__(self):
20     return "File '%s' is not a relocatable object file" % self.path
21
22 class UnsupportedObject(Exception):
23   """Raised when an input file is not of a supported arch."""
24   def __init__(self, path, reason):
25     self.path = path
26     self.reason = reason
27   def __str__(self):
28     return "File '%s' is not supported: %s" % (self.path, self.reason)
29
30 class LibNotFound(Exception):
31   """Raised if a shared library could not be found."""
32   def __init__(self, libname):
33     self.libname = libname
34   def __str__(self):
35     return "Cannot find shared library for '%s'" % self.libname
36
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
41   def __str__(self):
42     return "Undefined reference to '%s'" % self.symbol
43
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
48   def __str__(self):
49     return "Symbol '%s' is declared twice" % self.symbol