summaryrefslogtreecommitdiffstats
path: root/meta/lib/oe/qa.py
AgeCommit message (Collapse)Author
2021-01-04lib/oe/qa: handle the 'no specific instruction set' ELF e_machine valueRoss Burton
[RP: Update OEQA selftest to match change] Signed-off-by: Ross Burton <ross.burton@arm.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit b7cfc0f51cc0b4866f913f6eae4fcc6f72d2578c) Signed-off-by: Steve Sakoman <steve@sakoman.com>
2019-12-29chrpath: Cleanup and fix previous patchRoss Burton
Ensure self.data isn't accessed without assignment. Also clean up old style popen use and replace with modern/simpler subprocess. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2019-05-09meta/lib+scripts: Convert to SPDX license headersRichard Purdie
This adds SPDX license headers in place of the wide assortment of things currently in our script headers. We default to GPL-2.0-only except for the oeqa code where it was clearly submitted and marked as MIT on the most part or some scripts which had the "or later" GPL versioning. The patch also drops other obsolete bits of file headers where they were encoountered such as editor modelines, obsolete maintainer information or the phrase "All rights reserved" which is now obsolete and not required in copyright headers (in this case its actually confusing for licensing as all rights were not reserved). More work is needed for OE-Core but this takes care of the bulk of the scripts and meta/lib directories. The top level LICENSE files are tweaked to match the new structure and the SPDX naming. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-09-13insane: Recognise BPF as a valid EM_MACHINE typeKhem Raj
BPF Linux ELF objects are generated with kernel-selftests with >= 4.18 kernel and when clang is enabled which packages BPF objects into packages, therefore recongnise this as a valid ELF target Add a selftest for BPF Do not flag BPF objects in target, since they pretty much will be ok for most of kernels architectures we care do support BPF Signed-off-by: Khem Raj <raj.khem@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-12-16meta: remove True option to getVar callsJoshua Lock
getVar() now defaults to expanding by default, thus remove the True option from getVar() calls with a regex search and replace. Search made with the following regex: getVar ?\(( ?[^,()]*), True\) Signed-off-by: Joshua Lock <joshua.g.lock@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
2016-11-15lib/oe/qa: handle binaries with segments outside the first 4kbRoss Burton
The ELF parser was assuming that the segment tables are in the first 4kb of the binary. Whilst this generally appears to be the case, there have been instances where the segment table is elsewhere (offset 2MB, in this sample I have). Solve this problem by mmap()ing the file instead. Also clean up the code a little whilst chasing the problem. Signed-off-by: Ross Burton <ross.burton@intel.com>
2016-10-11lib/oe/qa: add ELF machine to string functionRoss Burton
Add a function (and test suite) to turn the ELF machine field (e_machine) into a string, so we can tell the user "x86-64" instead of 0x3E. Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-06-02classes/lib: Complete transition to python3Richard Purdie
This patch contains all the other misc pieces of the transition to python3 which didn't make sense to be broken into individual patches. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-05-21meta/scripts: python3: rename file -> openRichard Purdie
file() API doesn't exist in python 3, convert to open(). Also handle some cases where files aren't closed. Compatible with python 2.7. [Contributions from Ed and Richard] Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-05-21meta/selftest/scripts: Use print function for python3 compatibilityRichard Purdie
Used print function instead of print statement to make the code work in python 3. [Changes from both Ed and Richard] Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-03-25lib/oe/qa: add method to check if static or dynamic linkedRoss Burton
It's useful to know if a binary is statically or dynamically linked, so add a method to determine this. Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-02-28lib/oe/qa: add explicit exception for 'file isn't an ELF'Ross Burton
Signed-off-by: Ross Burton <ross.burton@intel.com>
2016-02-16lib/qa.py: raise ValueError if file isn't an ELFRoss Burton
Instead of raising a generic Exception that can't be handled specifically, raise a ValueError. Also update the callers so any unexpected exceptions are not ignored. Also, rename isBigEngian() to isBigEndian(). Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-02-16lib/oe/qa: ELFFile: check that a path is a file before opening itRoss Burton
When opening an ELF file check that a filename points to a normal file before attempting to open it, as if the file turns out to be something more exotic like a FIFO it could hang forever. (From OE-Core rev: 4b3576bc30d8f8cdcde25189def8b059fc92b27c) Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-05-09image/kernel-module-split/eglibc-ld.inc: Remove has_key() usageRichard Purdie
The has_key() attribute has been removed in python 3 since there is better syntax available. Use the improved syntax. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-05-09classes/recipes/lib: Fix various python whitespace issuesRichard Purdie
There are some left over tab characters in the python functions. This removes them and resolves python 3 errors. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-05-09clases/lib: Use modern exception syntaxRichard Purdie
Update older code to use modern exception handling syntax which is the form accepted by python 3. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-12-06qa.py: Toolchain path should not be hardcoded to execute objdumpMuhammad Shakeel
Currently objdump command is invoked from the STAGING_BINDIR_TOOLCHAIN directory. In case of external toolchain if this directory doesn't exist then objdump fails to execute. Instead of hardcoding the path it should search PATH to find it. Signed-off-by: Christopher Larson <chris_larson@mentor.com> Signed-off-by: Muhammad Shakeel <muhammad_shakeel@mentor.com> Signed-off-by: Saul Wold <sgw@linux.intel.com>
2012-12-04qa.py: Modify the env for the child process onlyMuhammad Shakeel
Modified environment is only required for new subprocess to execute objdump command and not for the current process. We should only modify the copy of env to pass it on to the child. Signed-off-by: Christopher Larson <chris_larson@mentor.com> Signed-off-by: Muhammad Shakeel <muhammad_shakeel@mentor.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-10-18lib/oe/qa: Trap exceptions when running objdumpPhil Blundell
This avoids propagating a failure if we encounter an ELF file that objdump can't parse for any reason. Some versions and/or configurations of objdump will refuse to read files for "the wrong" architecture. Signed-off-by: Phil Blundell <pb@pbcl.net> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-10-18insane: Rationalise phdrs-based QA checksPhil Blundell
Various different QA checks are based on essentially the same data from the ELF program headers. Calling objdump to extract it repeatedly is inefficient, particularly if the shell is involved. Instead, let's cache the output from objdump inside the qa.elf object and allow it to be reused by multiple tests. Also, using objdump instead of scanelf to check for bad RPATHs (in the same way that the useless-rpaths check was doing already) allows the dependency on pax-utils-native to be dropped. Signed-off-by: Phil Blundell <philb@gnu.org> Signed-off-by: Saul Wold <sgw@linux.intel.com>
2011-03-03qa.py: Fix a typo when evaluating bitsizeMark Hatle
This should be setting a variable, not performing a comparison. Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
2011-03-02insane.bbclass: Fix ELF bitsize comparisonMark Hatle
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>
2010-05-06lib/oe: Import oe lib from OE.devJoshua Lock
This library moves the common Python methods into modules of an 'oe' Python package. Signed-off-by: Joshua Lock <josh@linux.intel.com>