mirror of
https://git.yoctoproject.org/poky
synced 2026-05-30 12:29:55 +00:00
lib/oe/qa: add explicit exception for 'file isn't an ELF'
(From OE-Core rev: 4c1fe0cbcb98b0a69ad5b3a04432055d773ee4ba) Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
4553bb1b88
commit
4495e8bae0
@@ -792,9 +792,8 @@ def package_qa_walk(warnfuncs, errorfuncs, skip, package, d):
|
|||||||
elf = oe.qa.ELFFile(path)
|
elf = oe.qa.ELFFile(path)
|
||||||
try:
|
try:
|
||||||
elf.open()
|
elf.open()
|
||||||
except (IOError, ValueError):
|
except (IOError, oe.qa.NotELFFileError):
|
||||||
# IOError can happen if the packaging control files disappear,
|
# IOError can happen if the packaging control files disappear,
|
||||||
# ValueError means the file isn't an ELF.
|
|
||||||
elf = None
|
elf = None
|
||||||
for func in warnfuncs:
|
for func in warnfuncs:
|
||||||
func(path, package, d, elf, warnings)
|
func(path, package, d, elf, warnings)
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ python uninative_changeinterp () {
|
|||||||
elf = oe.qa.ELFFile(f)
|
elf = oe.qa.ELFFile(f)
|
||||||
try:
|
try:
|
||||||
elf.open()
|
elf.open()
|
||||||
except ValueError:
|
except oe.qa.NotELFFileError:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
#bb.warn("patchelf-uninative --set-interpreter %s %s" % (d.getVar("UNINATIVE_LOADER", True), f))
|
#bb.warn("patchelf-uninative --set-interpreter %s %s" % (d.getVar("UNINATIVE_LOADER", True), f))
|
||||||
|
|||||||
+9
-6
@@ -1,3 +1,6 @@
|
|||||||
|
class NotELFFileError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
class ELFFile:
|
class ELFFile:
|
||||||
EI_NIDENT = 16
|
EI_NIDENT = 16
|
||||||
|
|
||||||
@@ -23,7 +26,7 @@ class ELFFile:
|
|||||||
def my_assert(self, expectation, result):
|
def my_assert(self, expectation, result):
|
||||||
if not expectation == result:
|
if not expectation == result:
|
||||||
#print "'%x','%x' %s" % (ord(expectation), ord(result), self.name)
|
#print "'%x','%x' %s" % (ord(expectation), ord(result), self.name)
|
||||||
raise ValueError("%s is not an ELF" % self.name)
|
raise NotELFFileError("%s is not an ELF" % self.name)
|
||||||
|
|
||||||
def __init__(self, name, bits = 0):
|
def __init__(self, name, bits = 0):
|
||||||
self.name = name
|
self.name = name
|
||||||
@@ -32,7 +35,7 @@ class ELFFile:
|
|||||||
|
|
||||||
def open(self):
|
def open(self):
|
||||||
if not os.path.isfile(self.name):
|
if not os.path.isfile(self.name):
|
||||||
raise ValueError("%s is not a normal file" % self.name)
|
raise NotELFFileError("%s is not a normal file" % self.name)
|
||||||
|
|
||||||
self.file = file(self.name, "r")
|
self.file = file(self.name, "r")
|
||||||
self.data = self.file.read(ELFFile.EI_NIDENT+4)
|
self.data = self.file.read(ELFFile.EI_NIDENT+4)
|
||||||
@@ -49,24 +52,24 @@ class ELFFile:
|
|||||||
self.bits = 64
|
self.bits = 64
|
||||||
else:
|
else:
|
||||||
# Not 32-bit or 64.. lets assert
|
# Not 32-bit or 64.. lets assert
|
||||||
raise ValueError("ELF but not 32 or 64 bit.")
|
raise NotELFFileError("ELF but not 32 or 64 bit.")
|
||||||
elif self.bits == 32:
|
elif self.bits == 32:
|
||||||
self.my_assert(self.data[ELFFile.EI_CLASS], chr(ELFFile.ELFCLASS32))
|
self.my_assert(self.data[ELFFile.EI_CLASS], chr(ELFFile.ELFCLASS32))
|
||||||
elif self.bits == 64:
|
elif self.bits == 64:
|
||||||
self.my_assert(self.data[ELFFile.EI_CLASS], chr(ELFFile.ELFCLASS64))
|
self.my_assert(self.data[ELFFile.EI_CLASS], chr(ELFFile.ELFCLASS64))
|
||||||
else:
|
else:
|
||||||
raise ValueError("Must specify unknown, 32 or 64 bit size.")
|
raise NotELFFileError("Must specify unknown, 32 or 64 bit size.")
|
||||||
self.my_assert(self.data[ELFFile.EI_VERSION], chr(ELFFile.EV_CURRENT) )
|
self.my_assert(self.data[ELFFile.EI_VERSION], chr(ELFFile.EV_CURRENT) )
|
||||||
|
|
||||||
self.sex = self.data[ELFFile.EI_DATA]
|
self.sex = self.data[ELFFile.EI_DATA]
|
||||||
if self.sex == chr(ELFFile.ELFDATANONE):
|
if self.sex == chr(ELFFile.ELFDATANONE):
|
||||||
raise ValueError("self.sex == ELFDATANONE")
|
raise NotELFFileError("self.sex == ELFDATANONE")
|
||||||
elif self.sex == chr(ELFFile.ELFDATA2LSB):
|
elif self.sex == chr(ELFFile.ELFDATA2LSB):
|
||||||
self.sex = "<"
|
self.sex = "<"
|
||||||
elif self.sex == chr(ELFFile.ELFDATA2MSB):
|
elif self.sex == chr(ELFFile.ELFDATA2MSB):
|
||||||
self.sex = ">"
|
self.sex = ">"
|
||||||
else:
|
else:
|
||||||
raise ValueError("Unknown self.sex")
|
raise NotELFFileError("Unknown self.sex")
|
||||||
|
|
||||||
def osAbi(self):
|
def osAbi(self):
|
||||||
return ord(self.data[ELFFile.EI_OSABI])
|
return ord(self.data[ELFFile.EI_OSABI])
|
||||||
|
|||||||
Reference in New Issue
Block a user