diff options
Diffstat (limited to 'meta/lib/oe/qa.py')
-rw-r--r-- | meta/lib/oe/qa.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/meta/lib/oe/qa.py b/meta/lib/oe/qa.py index 2ad6c63bdc..4efa21fd80 100644 --- a/meta/lib/oe/qa.py +++ b/meta/lib/oe/qa.py | |||
@@ -1,3 +1,6 @@ | |||
1 | class NotELFFileError(Exception): | ||
2 | pass | ||
3 | |||
1 | class ELFFile: | 4 | class ELFFile: |
2 | EI_NIDENT = 16 | 5 | EI_NIDENT = 16 |
3 | 6 | ||
@@ -23,7 +26,7 @@ class ELFFile: | |||
23 | def my_assert(self, expectation, result): | 26 | def my_assert(self, expectation, result): |
24 | if not expectation == result: | 27 | if not expectation == result: |
25 | #print "'%x','%x' %s" % (ord(expectation), ord(result), self.name) | 28 | #print "'%x','%x' %s" % (ord(expectation), ord(result), self.name) |
26 | raise ValueError("%s is not an ELF" % self.name) | 29 | raise NotELFFileError("%s is not an ELF" % self.name) |
27 | 30 | ||
28 | def __init__(self, name, bits = 0): | 31 | def __init__(self, name, bits = 0): |
29 | self.name = name | 32 | self.name = name |
@@ -32,7 +35,7 @@ class ELFFile: | |||
32 | 35 | ||
33 | def open(self): | 36 | def open(self): |
34 | if not os.path.isfile(self.name): | 37 | if not os.path.isfile(self.name): |
35 | raise ValueError("%s is not a normal file" % self.name) | 38 | raise NotELFFileError("%s is not a normal file" % self.name) |
36 | 39 | ||
37 | self.file = file(self.name, "r") | 40 | self.file = file(self.name, "r") |
38 | self.data = self.file.read(ELFFile.EI_NIDENT+4) | 41 | self.data = self.file.read(ELFFile.EI_NIDENT+4) |
@@ -49,24 +52,24 @@ class ELFFile: | |||
49 | self.bits = 64 | 52 | self.bits = 64 |
50 | else: | 53 | else: |
51 | # Not 32-bit or 64.. lets assert | 54 | # Not 32-bit or 64.. lets assert |
52 | raise ValueError("ELF but not 32 or 64 bit.") | 55 | raise NotELFFileError("ELF but not 32 or 64 bit.") |
53 | elif self.bits == 32: | 56 | elif self.bits == 32: |
54 | self.my_assert(self.data[ELFFile.EI_CLASS], chr(ELFFile.ELFCLASS32)) | 57 | self.my_assert(self.data[ELFFile.EI_CLASS], chr(ELFFile.ELFCLASS32)) |
55 | elif self.bits == 64: | 58 | elif self.bits == 64: |
56 | self.my_assert(self.data[ELFFile.EI_CLASS], chr(ELFFile.ELFCLASS64)) | 59 | self.my_assert(self.data[ELFFile.EI_CLASS], chr(ELFFile.ELFCLASS64)) |
57 | else: | 60 | else: |
58 | raise ValueError("Must specify unknown, 32 or 64 bit size.") | 61 | raise NotELFFileError("Must specify unknown, 32 or 64 bit size.") |
59 | self.my_assert(self.data[ELFFile.EI_VERSION], chr(ELFFile.EV_CURRENT) ) | 62 | self.my_assert(self.data[ELFFile.EI_VERSION], chr(ELFFile.EV_CURRENT) ) |
60 | 63 | ||
61 | self.sex = self.data[ELFFile.EI_DATA] | 64 | self.sex = self.data[ELFFile.EI_DATA] |
62 | if self.sex == chr(ELFFile.ELFDATANONE): | 65 | if self.sex == chr(ELFFile.ELFDATANONE): |
63 | raise ValueError("self.sex == ELFDATANONE") | 66 | raise NotELFFileError("self.sex == ELFDATANONE") |
64 | elif self.sex == chr(ELFFile.ELFDATA2LSB): | 67 | elif self.sex == chr(ELFFile.ELFDATA2LSB): |
65 | self.sex = "<" | 68 | self.sex = "<" |
66 | elif self.sex == chr(ELFFile.ELFDATA2MSB): | 69 | elif self.sex == chr(ELFFile.ELFDATA2MSB): |
67 | self.sex = ">" | 70 | self.sex = ">" |
68 | else: | 71 | else: |
69 | raise ValueError("Unknown self.sex") | 72 | raise NotELFFileError("Unknown self.sex") |
70 | 73 | ||
71 | def osAbi(self): | 74 | def osAbi(self): |
72 | return ord(self.data[ELFFile.EI_OSABI]) | 75 | return ord(self.data[ELFFile.EI_OSABI]) |