blob: 17d9af4de4289f1b669c445e05604928e77c5a8a [file] [log] [blame]
Brad Bishop316dfdd2018-06-25 12:45:53 -04001From dcb45256970b15b672d0004533826c94083356e5 Mon Sep 17 00:00:00 2001
Patrick Williamsc124f4f2015-09-15 14:41:29 -05002From: Yuanjie Huang <yuanjie.huang@windriver.com>
3Date: Fri, 17 Apr 2015 14:48:20 +0800
Brad Bishop316dfdd2018-06-25 12:45:53 -04004Subject: [PATCH 4/6] avoid failure on symbol provided by application
Patrick Williamsc124f4f2015-09-15 14:41:29 -05005
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>
Brad Bishop316dfdd2018-06-25 12:45:53 -040016
Patrick Williamsc124f4f2015-09-15 14:41:29 -050017---
18 src/mklibs | 28 ++++++++++++++++++++++++----
19 1 file changed, 24 insertions(+), 4 deletions(-)
20
21diff --git a/src/mklibs b/src/mklibs
Brad Bishop316dfdd2018-06-25 12:45:53 -040022index a3533c0..66b7a09 100755
Patrick Williamsc124f4f2015-09-15 14:41:29 -050023--- 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 Bishop316dfdd2018-06-25 12:45:53 -040035 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 Williamsc124f4f2015-09-15 14:41:29 -050038
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 Bishop316dfdd2018-06-25 12:45:53 -040049@@ -171,7 +176,7 @@ def undefined_symbols(obj):
Patrick Williamsc124f4f2015-09-15 14:41:29 -050050 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 Bishop316dfdd2018-06-25 12:45:53 -040058@@ -498,12 +503,13 @@ while 1:
Patrick Williamsc124f4f2015-09-15 14:41:29 -050059 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 Bishop316dfdd2018-06-25 12:45:53 -040072 checked_libs.append(sysroot + ldlib)
73@@ -513,6 +519,12 @@ while 1:
Patrick Williamsc124f4f2015-09-15 14:41:29 -050074 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 Bishop316dfdd2018-06-25 12:45:53 -040086@@ -568,6 +580,14 @@ while 1:
Patrick Williamsc124f4f2015-09-15 14:41:29 -050087 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 Bishop316dfdd2018-06-25 12:45:53 -04001022.16.1
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500103