Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 1 | From dcb45256970b15b672d0004533826c94083356e5 Mon Sep 17 00:00:00 2001 |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2 | From: Yuanjie Huang <yuanjie.huang@windriver.com> |
| 3 | Date: Fri, 17 Apr 2015 14:48:20 +0800 |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 4 | Subject: [PATCH 4/6] avoid failure on symbol provided by application |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 5 | |
| 6 | Upstream-Status: Pending |
| 7 | |
| 8 | Undefined symbols in a library can be provided by the application |
| 9 | that links to the library, such as `logsink' in libmultipath.so.0. |
| 10 | This fix checks the type of object in which the symbol is needed |
| 11 | and the existence of the symbol in application, when a symbol |
| 12 | cannot be provided by libraries. It prevents false alarm on absence |
| 13 | of symbols. |
| 14 | |
| 15 | Signed-off-by: Yuanjie Huang <yuanjie.huang@windriver.com> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 16 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 17 | --- |
| 18 | src/mklibs | 28 ++++++++++++++++++++++++---- |
| 19 | 1 file changed, 24 insertions(+), 4 deletions(-) |
| 20 | |
| 21 | diff --git a/src/mklibs b/src/mklibs |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 22 | index a3533c0..66b7a09 100755 |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 23 | --- a/src/mklibs |
| 24 | +++ b/src/mklibs |
| 25 | @@ -133,9 +133,9 @@ class Symbol(object): |
| 26 | return '@'.join(ret) |
| 27 | |
| 28 | class UndefinedSymbol(Symbol): |
| 29 | - def __init__(self, name, weak, version, library): |
| 30 | + def __init__(self, name, weak, version, library, object): |
| 31 | super(UndefinedSymbol, self).__init__(name, version, library) |
| 32 | - self.weak, self.library = weak, library |
| 33 | + self.weak, self.library, self.object = weak, library, object |
| 34 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 35 | def symbol_is_blacklisted(name): |
| 36 | # The ARM Embedded ABI spec states symbols under this namespace as |
| 37 | @@ -152,6 +152,11 @@ def undefined_symbols(obj): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 38 | |
| 39 | output = command("mklibs-readelf", "--print-symbols-undefined", obj) |
| 40 | |
| 41 | + if len(obj) > len(dest_path) and obj[:len(dest_path)] == dest_path: |
| 42 | + object = obj[len(dest_path) + 1:-len('-so-stripped')] |
| 43 | + else: |
| 44 | + object = obj |
| 45 | + |
| 46 | result = [] |
| 47 | for line in output: |
| 48 | name, weak_string, version_string, library_string = line.split()[:4] |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 49 | @@ -171,7 +176,7 @@ def undefined_symbols(obj): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 50 | if library_string.lower() != 'none': |
| 51 | library = library_string |
| 52 | |
| 53 | - result.append(UndefinedSymbol(name, weak, version, library)) |
| 54 | + result.append(UndefinedSymbol(name, weak, version, library, object)) |
| 55 | |
| 56 | return result |
| 57 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 58 | @@ -498,12 +503,13 @@ while 1: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 59 | and re.search("^ps_", str(symbol))) |
| 60 | and not (re.search("ld-linux.so.3$", str(symbol))) |
| 61 | and not (re.search("^__gnu_local_gp", str(symbol)))): |
| 62 | - debug(DEBUG_SPAM, "needed_symbols adding %s, weak: %s" % (symbol, symbol.weak)) |
| 63 | + debug(DEBUG_SPAM, "needed_symbols adding %s, weak: %s, for %s" % (symbol, symbol.weak, obj)) |
| 64 | needed_symbols[str(symbol)] = symbol |
| 65 | libraries.update(library_depends(obj)) |
| 66 | |
| 67 | # calculate what symbols are present in small_libs and available_libs |
| 68 | present_symbols = {} |
| 69 | + present_symbol_progs = {} |
| 70 | checked_libs = small_libs |
| 71 | checked_libs.extend(available_libs) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 72 | checked_libs.append(sysroot + ldlib) |
| 73 | @@ -513,6 +519,12 @@ while 1: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 74 | names = symbol.base_names() |
| 75 | for name in names: |
| 76 | present_symbols[name] = symbol |
| 77 | + if not so_pattern.match(lib): |
| 78 | + debug(DEBUG_SPAM, "present_symbol_progs adding %s, from executable %s" % (' '.join(names), lib)) |
| 79 | + for name in names: |
| 80 | + progs = present_symbol_progs.get(name, set()) |
| 81 | + progs.add(lib) |
| 82 | + present_symbol_progs[name] = progs |
| 83 | |
| 84 | # are we finished? |
| 85 | num_unresolved = 0 |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 86 | @@ -568,6 +580,14 @@ while 1: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 87 | for name in needed_symbols: |
| 88 | if not name in symbol_provider: |
| 89 | if not needed_symbols[name].weak: |
| 90 | + # WORKAROUND: Undefined symbols in a library can be provided by the application |
| 91 | + # that links to the library. So if the object which requires the symbol is a library |
| 92 | + # and some application can provide the symbol, the undefined symbol is skipped. |
| 93 | + symbol = needed_symbols[name] |
| 94 | + if so_pattern.match(symbol.object) and present_symbol_progs.get(name, None): |
| 95 | + debug(DEBUG_SPAM, "symbol %s in library %s is provided by executable %s" \ |
| 96 | + % (name, symbol.object, ' '.join(present_symbol_progs[name]))) |
| 97 | + continue |
| 98 | raise Exception("No library provides non-weak %s" % name) |
| 99 | else: |
| 100 | lib = symbol_provider[name] |
| 101 | -- |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 102 | 2.16.1 |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 103 | |