diff options
| -rw-r--r-- | meta/classes/package.bbclass | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass index 97e97d2703..8b11fdd155 100644 --- a/meta/classes/package.bbclass +++ b/meta/classes/package.bbclass | |||
| @@ -484,16 +484,31 @@ def inject_minidebuginfo(file, dvar, dv, d): | |||
| 484 | bb.debug(1, 'ELF file {} has no debuginfo, skipping minidebuginfo injection'.format(file)) | 484 | bb.debug(1, 'ELF file {} has no debuginfo, skipping minidebuginfo injection'.format(file)) |
| 485 | return | 485 | return |
| 486 | 486 | ||
| 487 | # minidebuginfo does not make sense to apply to ELF objects other than | ||
| 488 | # executables and shared libraries, skip applying the minidebuginfo | ||
| 489 | # generation for objects like kernel modules. | ||
| 490 | for line in subprocess.check_output([readelf, '-h', debugfile], universal_newlines=True).splitlines(): | ||
| 491 | if not line.strip().startswith("Type:"): | ||
| 492 | continue | ||
| 493 | elftype = line.split(":")[1].strip() | ||
| 494 | if not any(elftype.startswith(i) for i in ["EXEC", "DYN"]): | ||
| 495 | bb.debug(1, 'ELF file {} is not executable/shared, skipping minidebuginfo injection'.format(file)) | ||
| 496 | return | ||
| 497 | break | ||
| 498 | |||
| 487 | # Find non-allocated PROGBITS, NOTE, and NOBITS sections in the debuginfo. | 499 | # Find non-allocated PROGBITS, NOTE, and NOBITS sections in the debuginfo. |
| 488 | # We will exclude all of these from minidebuginfo to save space. | 500 | # We will exclude all of these from minidebuginfo to save space. |
| 489 | remove_section_names = [] | 501 | remove_section_names = [] |
| 490 | for line in subprocess.check_output([readelf, '-W', '-S', debugfile], universal_newlines=True).splitlines(): | 502 | for line in subprocess.check_output([readelf, '-W', '-S', debugfile], universal_newlines=True).splitlines(): |
| 491 | fields = line.split() | 503 | # strip the leading " [ 1]" section index to allow splitting on space |
| 492 | if len(fields) < 8: | 504 | if ']' not in line: |
| 505 | continue | ||
| 506 | fields = line[line.index(']') + 1:].split() | ||
| 507 | if len(fields) < 7: | ||
| 493 | continue | 508 | continue |
| 494 | name = fields[0] | 509 | name = fields[0] |
| 495 | type = fields[1] | 510 | type = fields[1] |
| 496 | flags = fields[7] | 511 | flags = fields[6] |
| 497 | # .debug_ sections will be removed by objcopy -S so no need to explicitly remove them | 512 | # .debug_ sections will be removed by objcopy -S so no need to explicitly remove them |
| 498 | if name.startswith('.debug_'): | 513 | if name.startswith('.debug_'): |
| 499 | continue | 514 | continue |
