diff options
-rw-r--r-- | meta/lib/oe/package.py | 20 |
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): | |||
21 | os.chmod(file, newmode) | 21 | os.chmod(file, newmode) |
22 | 22 | ||
23 | stripcmd = [strip] | 23 | stripcmd = [strip] |
24 | 24 | skip_strip = False | |
25 | # kernel module | 25 | # kernel module |
26 | if elftype & 16: | 26 | if elftype & 16: |
27 | stripcmd.extend(["--strip-debug", "--remove-section=.comment", | 27 | if is_kernel_module_signed(file): |
28 | "--remove-section=.note", "--preserve-dates"]) | 28 | bb.debug(1, "Skip strip on signed module %s" % file) |
29 | skip_strip = True | ||
30 | else: | ||
31 | stripcmd.extend(["--strip-debug", "--remove-section=.comment", | ||
32 | "--remove-section=.note", "--preserve-dates"]) | ||
29 | # .so and shared library | 33 | # .so and shared library |
30 | elif ".so" in file and elftype & 8: | 34 | elif ".so" in file and elftype & 8: |
31 | stripcmd.extend(["--remove-section=.comment", "--remove-section=.note", "--strip-unneeded"]) | 35 | stripcmd.extend(["--remove-section=.comment", "--remove-section=.note", "--strip-unneeded"]) |
@@ -36,7 +40,8 @@ def runstrip(arg): | |||
36 | stripcmd.append(file) | 40 | stripcmd.append(file) |
37 | bb.debug(1, "runstrip: %s" % stripcmd) | 41 | bb.debug(1, "runstrip: %s" % stripcmd) |
38 | 42 | ||
39 | output = subprocess.check_output(stripcmd, stderr=subprocess.STDOUT) | 43 | if not skip_strip: |
44 | output = subprocess.check_output(stripcmd, stderr=subprocess.STDOUT) | ||
40 | 45 | ||
41 | if newmode: | 46 | if newmode: |
42 | os.chmod(file, origmode) | 47 | os.chmod(file, origmode) |
@@ -46,6 +51,13 @@ def is_kernel_module(path): | |||
46 | with open(path) as f: | 51 | with open(path) as f: |
47 | return mmap.mmap(f.fileno(), 0, prot=mmap.PROT_READ).find(b"vermagic=") >= 0 | 52 | return mmap.mmap(f.fileno(), 0, prot=mmap.PROT_READ).find(b"vermagic=") >= 0 |
48 | 53 | ||
54 | # Detect if .ko module is signed | ||
55 | def is_kernel_module_signed(path): | ||
56 | with open(path, "rb") as f: | ||
57 | f.seek(-28, 2) | ||
58 | module_tail = f.read() | ||
59 | return "Module signature appended" in "".join(chr(c) for c in bytearray(module_tail)) | ||
60 | |||
49 | # Return type (bits): | 61 | # Return type (bits): |
50 | # 0 - not elf | 62 | # 0 - not elf |
51 | # 1 - ELF | 63 | # 1 - ELF |