summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
authorMark Hatle <mark.hatle@windriver.com>2011-03-01 12:42:28 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-03-03 16:57:44 +0000
commit78c2b79d549ca5be29c096beca87c4bf9cf8d6bb (patch)
tree9dd173805b1e8d3d7cc65f68a24b2f894b71fdc3 /meta/lib
parent23ecbad5cd2b83263cdd79ddb31a7cd10f7ede7f (diff)
downloadpoky-78c2b79d549ca5be29c096beca87c4bf9cf8d6bb.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. (From OE-Core rev: 17dae13fabe2932a47ecc86fcafb1d177226513f) Signed-off-by: Mark Hatle <mark.hatle@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
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