avoid-failure-on-symbol-provided-by-application.patch 4.3 KB

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