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