summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
authorMark Hatle <mark.hatle@windriver.com>2011-03-01 12:42:28 -0600
committerSaul Wold <sgw@linux.intel.com>2011-03-01 16:36:44 -0800
commit3a39d969286a2b2abb81c9d055ad558c258bbea2 (patch)
tree4bbc609aa25e7dccf4224b5e6f3cbd867fc14175 /meta/lib
parent65d37c34b7d3615be328db138d5cd283abab227a (diff)
downloadpoky-3a39d969286a2b2abb81c9d055ad558c258bbea2.tar.gz
insane.bbclass: Fix ELF bitsize comparison
Fix the way the ELF size is compared to ensure that incorrectly sized ELF binaries are captured during the file scan. lib/oe/qa.py is changed to accept a bitsize as a parameter. Instead of previously defining true/false, it now takes "0" undefined, "32" 32-bit, and "64" 64-bit as the size argument. This allows us to preserve existing behavior of only loading one ELF type, while allowing the function to be able to discover the size on it's own. Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oe/qa.py21
1 files changed, 17 insertions, 4 deletions
diff --git a/meta/lib/oe/qa.py b/meta/lib/oe/qa.py
index 01813931bb..7adf4d03ae 100644
--- a/meta/lib/oe/qa.py
+++ b/meta/lib/oe/qa.py
@@ -25,9 +25,9 @@ class ELFFile:
25 #print "'%x','%x' %s" % (ord(expectation), ord(result), self.name) 25 #print "'%x','%x' %s" % (ord(expectation), ord(result), self.name)
26 raise Exception("This does not work as expected") 26 raise Exception("This does not work as expected")
27 27
28 def __init__(self, name, bits32): 28 def __init__(self, name, bits = 0):
29 self.name = name 29 self.name = name
30 self.bits32 = bits32 30 self.bits = bits
31 31
32 def open(self): 32 def open(self):
33 self.file = file(self.name, "r") 33 self.file = file(self.name, "r")
@@ -38,10 +38,20 @@ class ELFFile:
38 self.my_assert(self.data[1], 'E') 38 self.my_assert(self.data[1], 'E')
39 self.my_assert(self.data[2], 'L') 39 self.my_assert(self.data[2], 'L')
40 self.my_assert(self.data[3], 'F') 40 self.my_assert(self.data[3], 'F')
41 if self.bits32 : 41 if self.bits == 0:
42 if self.data[ELFFile.EI_CLASS] == chr(ELFFile.ELFCLASS32):
43 self.bits == 32
44 elif self.data[ELFFile.EI_CLASS] == chr(ELFFile.ELFCLASS64):
45 self.bits == 64
46 else:
47 # Not 32-bit or 64.. lets assert
48 raise Exception("ELF but not 32 or 64 bit.")
49 elif self.bits == 32:
42 self.my_assert(self.data[ELFFile.EI_CLASS], chr(ELFFile.ELFCLASS32)) 50 self.my_assert(self.data[ELFFile.EI_CLASS], chr(ELFFile.ELFCLASS32))
43 else: 51 elif self.bits == 64:
44 self.my_assert(self.data[ELFFile.EI_CLASS], chr(ELFFile.ELFCLASS64)) 52 self.my_assert(self.data[ELFFile.EI_CLASS], chr(ELFFile.ELFCLASS64))
53 else:
54 raise Exception("Must specify unknown, 32 or 64 bit size.")
45 self.my_assert(self.data[ELFFile.EI_VERSION], chr(ELFFile.EV_CURRENT) ) 55 self.my_assert(self.data[ELFFile.EI_VERSION], chr(ELFFile.EV_CURRENT) )
46 56
47 self.sex = self.data[ELFFile.EI_DATA] 57 self.sex = self.data[ELFFile.EI_DATA]
@@ -60,6 +70,9 @@ class ELFFile:
60 def abiVersion(self): 70 def abiVersion(self):
61 return ord(self.data[ELFFile.EI_ABIVERSION]) 71 return ord(self.data[ELFFile.EI_ABIVERSION])
62 72
73 def abiSize(self):
74 return self.bits
75
63 def isLittleEndian(self): 76 def isLittleEndian(self):
64 return self.sex == "<" 77 return self.sex == "<"
65 78