--- BinariesCheck.py +++ BinariesCheck.py @@ -34,6 +34,8 @@ 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 @@ -46,6 +48,8 @@ self.non_pic=1 self.stack = 0 self.exec_stack = 0 + self.debuginfo=0 + self.symtab=0 is_debug=BinaryInfo.debug_file_regex.search(path) @@ -87,6 +91,14 @@ self.exec_stack = 1 continue + if BinaryInfo.debuginfo_regex.search(l): + self.debuginfo=1 + continue + + if BinaryInfo.symtab_regex.search(l): + self.symtab=1 + continue + if self.non_pic: self.non_pic=BinaryInfo.non_pic_regex.search(res[1]) else: @@ -216,6 +228,17 @@ # 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]): has_lib.append(i[0]) @@ -430,6 +453,14 @@ '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.''', + 'executable-stack', '''The binary declares the stack as executable. Executable stack is usually an error as it is only needed if the code contains GCC trampolines or similar