summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
authorfoocampo <omar.ocampo.coronado@intel.com>2018-08-03 19:47:40 -0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-08-09 23:47:47 +0100
commit4c47e5f171fa2603355e2f9183065ce8137a18c7 (patch)
treece8582d29159692a4ffca4b10628a790a42adc52 /meta/lib
parentb8d5811b7306025bb8b2b7efd42eddb864584ba6 (diff)
downloadopenembedded-core-contrib-4c47e5f171fa2603355e2f9183065ce8137a18c7.tar.gz
openembedded-core-contrib-4c47e5f171fa2603355e2f9183065ce8137a18c7.tar.bz2
openembedded-core-contrib-4c47e5f171fa2603355e2f9183065ce8137a18c7.zip
package: skip strip on signed kernel modules
Executing strip action on kernel modules removes the signature. Is not possible to strip and keep the signature, therefore avoid strip signed kernel modules. Signed-off-by: Omar Ocampo <omar.ocampo.coronado@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oe/package.py20
1 files changed, 16 insertions, 4 deletions
diff --git a/meta/lib/oe/package.py b/meta/lib/oe/package.py
index fa3428ad61..21c80aaa38 100644
--- a/meta/lib/oe/package.py
+++ b/meta/lib/oe/package.py
@@ -21,11 +21,15 @@ def runstrip(arg):
os.chmod(file, newmode)
stripcmd = [strip]
-
+ skip_strip = False
# kernel module
if elftype & 16:
- stripcmd.extend(["--strip-debug", "--remove-section=.comment",
- "--remove-section=.note", "--preserve-dates"])
+ if is_kernel_module_signed(file):
+ bb.debug(1, "Skip strip on signed module %s" % file)
+ skip_strip = True
+ else:
+ stripcmd.extend(["--strip-debug", "--remove-section=.comment",
+ "--remove-section=.note", "--preserve-dates"])
# .so and shared library
elif ".so" in file and elftype & 8:
stripcmd.extend(["--remove-section=.comment", "--remove-section=.note", "--strip-unneeded"])
@@ -36,7 +40,8 @@ def runstrip(arg):
stripcmd.append(file)
bb.debug(1, "runstrip: %s" % stripcmd)
- output = subprocess.check_output(stripcmd, stderr=subprocess.STDOUT)
+ if not skip_strip:
+ output = subprocess.check_output(stripcmd, stderr=subprocess.STDOUT)
if newmode:
os.chmod(file, origmode)
@@ -46,6 +51,13 @@ def is_kernel_module(path):
with open(path) as f:
return mmap.mmap(f.fileno(), 0, prot=mmap.PROT_READ).find(b"vermagic=") >= 0
+# Detect if .ko module is signed
+def is_kernel_module_signed(path):
+ with open(path, "rb") as f:
+ f.seek(-28, 2)
+ module_tail = f.read()
+ return "Module signature appended" in "".join(chr(c) for c in bytearray(module_tail))
+
# Return type (bits):
# 0 - not elf
# 1 - ELF