From 78c2b79d549ca5be29c096beca87c4bf9cf8d6bb Mon Sep 17 00:00:00 2001 From: Mark Hatle Date: Tue, 1 Mar 2011 12:42:28 -0600 Subject: 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 Signed-off-by: Richard Purdie --- meta/lib/oe/qa.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'meta/lib') 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: #print "'%x','%x' %s" % (ord(expectation), ord(result), self.name) raise Exception("This does not work as expected") - def __init__(self, name, bits32): + def __init__(self, name, bits = 0): self.name = name - self.bits32 = bits32 + self.bits = bits def open(self): self.file = file(self.name, "r") @@ -38,10 +38,20 @@ class ELFFile: self.my_assert(self.data[1], 'E') self.my_assert(self.data[2], 'L') self.my_assert(self.data[3], 'F') - if self.bits32 : + if self.bits == 0: + if self.data[ELFFile.EI_CLASS] == chr(ELFFile.ELFCLASS32): + self.bits == 32 + elif self.data[ELFFile.EI_CLASS] == chr(ELFFile.ELFCLASS64): + self.bits == 64 + else: + # Not 32-bit or 64.. lets assert + raise Exception("ELF but not 32 or 64 bit.") + elif self.bits == 32: self.my_assert(self.data[ELFFile.EI_CLASS], chr(ELFFile.ELFCLASS32)) - else: + elif self.bits == 64: self.my_assert(self.data[ELFFile.EI_CLASS], chr(ELFFile.ELFCLASS64)) + else: + raise Exception("Must specify unknown, 32 or 64 bit size.") self.my_assert(self.data[ELFFile.EI_VERSION], chr(ELFFile.EV_CURRENT) ) self.sex = self.data[ELFFile.EI_DATA] @@ -60,6 +70,9 @@ class ELFFile: def abiVersion(self): return ord(self.data[ELFFile.EI_ABIVERSION]) + def abiSize(self): + return self.bits + def isLittleEndian(self): return self.sex == "<" -- cgit v1.2.3-54-g00ecf