SHA256
1
0
forked from pool/rpmlint
rpmlint/suse-debuginfo.diff

100 lines
4.3 KiB
Diff
Raw Normal View History

From: Jan Blunck <jblunck@suse.de>
Subject: Add checks for static libraries missing symtab and debuginfo
Static libraries without a symbol table are not linkable. Binaries linking
against static libraries without debuginfo are not debuggable.
---
BinariesCheck.py | 31 +++++++++++++++++++++++++++++--
1 file changed, 29 insertions(+), 2 deletions(-)
Index: BinariesCheck.py
===================================================================
--- BinariesCheck.py.orig
+++ BinariesCheck.py
@@ -32,6 +32,8 @@ class BinaryInfo:
undef_regex=re.compile('^undefined symbol:\s+(\S+)')
unused_regex=re.compile('^\s+(\S+)')
debug_file_regex=re.compile('\.debug$')
+ debuginfo_regex=re.compile('^\s+\[\s*\d+\]\s+\.debug_.*\s+')
+ symtab_regex=re.compile('^\s+\[\s*\d+\]\s+\.symtab\s+')
def __init__(self, pkg, path, file, is_ar):
self.had_error=0
@@ -42,6 +44,8 @@ class BinaryInfo:
self.comment=0
self.soname=0
self.non_pic=1
+ self.debuginfo=0
+ self.symtab=0
is_debug=BinaryInfo.debug_file_regex.search(path)
@@ -65,6 +69,10 @@ class BinaryInfo:
r=BinaryInfo.soname_regex.search(l)
if r:
self.soname=r.group(1)
+ if BinaryInfo.debuginfo_regex.search(l):
+ self.debuginfo=1
+ if BinaryInfo.symtab_regex.search(l):
+ self.symtab=1
if self.non_pic:
self.non_pic=BinaryInfo.non_pic_regex.search(res[1])
else:
@@ -114,6 +122,7 @@ shared_object_regex=re.compile('shared o
executable_regex=re.compile('executable')
libc_regex=re.compile('libc\.')
ldso_soname_regex=re.compile('^ld(-linux(-(ia|x86_)64))?\.so')
+ar_regex=re.compile('\.a$')
so_regex=re.compile('/lib(64)?/[^/]+\.so(\.[0-9]+)*$')
validso_regex=re.compile('(\.so\.\d+(\.\d+)*|\d\.so)$')
sparc_regex=re.compile('SPARC32PLUS|SPARC V9|UltraSPARC')
@@ -171,7 +180,7 @@ class BinariesCheck(AbstractCheck.Abstra
for i in info:
is_elf = string.find(i[1], 'ELF') != -1
- is_ar = string.find(i[1], 'current ar archive') != -1
+ is_ar = ar_regex.search(i[0])
is_ocaml_native = string.find(i[1], 'Objective caml native') != -1
is_shell = string.find(i[1], "shell script") != -1
is_binary = is_elf or is_ar or is_ocaml_native
@@ -196,13 +205,23 @@ class BinariesCheck(AbstractCheck.Abstra
# stripped ?
if not unstrippable.search(i[0]) and not is_ocaml_native:
- if not_stripped.search(i[1]) and \
+ if not is_ar and not_stripped.search(i[1]) and \
(os.environ.get('BUILD_IS_RUNNING', None) == None or \
os.environ.get('BUILD_DEBUG_FLAGS','').find('-g') != -1):
printWarning(pkg, 'unstripped-binary-or-object', i[0])
# inspect binary file
bin_info=BinaryInfo(pkg, pkg.dirName()+i[0], i[0], is_ar)
+ # stripped static library
+ if is_ar:
+ if bin_info.had_error:
+ pass
+ elif not bin_info.symtab:
+ printError(pkg, 'static-library-without-symtab', i[0])
+ elif not bin_info.debuginfo and \
+ (os.environ.get('BUILD_IS_RUNNING', None) == None or \
+ os.environ.get('BUILD_DEBUG_FLAGS','').find('-g') != -1):
+ printWarning(pkg, 'static-library-without-debuginfo', i[0])
# so name in library
if so_regex.search(i[0]):
@@ -441,6 +460,14 @@ with the intended shared libraries only.
'ldd-failed',
'''Executing ldd on this file failed, all checks could not be run.''',
+
+'static-library-without-symtab',
+'''The static library doesn't contain any symbols and therefore can't be linked
+against. This may indicated that it was strip.''',
+
+'static-library-without-debuginfo',
+'''The static library doesn't contain any debuginfo. Binaries linking against
+this static library can't be properly debugged.''',
)
# BinariesCheck.py ends here