Skip to content
Snippets Groups Projects
Commit 4063c1ed authored by Andreas Ziegler's avatar Andreas Ziegler
Browse files

store: fill all_needed_libs in breadth-first order

So far, the all_needed_libs dictionary was updated directly
after descending into the needed library, leading to a
depth-first order of libraries in all_needed_libs.

The ELF specification however states that symbols are
resolved in breadth-first order. This changes the results
for ELF files which use symbols which are defined in
more than one of the (transitively) imported libraries.
parent 6d46d52b
No related branches found
No related tags found
No related merge requests found
Pipeline #16208 passed
...@@ -76,6 +76,7 @@ class LibraryStore(BaseStore): ...@@ -76,6 +76,7 @@ class LibraryStore(BaseStore):
def _find_compatible_libs(self, target, callback, inherited_rpaths=None, def _find_compatible_libs(self, target, callback, inherited_rpaths=None,
ld_library_paths=None): ld_library_paths=None):
next_level_needed = collections.OrderedDict()
for needed_name in target.needed_libs: for needed_name in target.needed_libs:
rpaths = self.resolver.get_paths(needed_name, target.rpaths, rpaths = self.resolver.get_paths(needed_name, target.rpaths,
inherited_rpaths, target.runpaths, inherited_rpaths, target.runpaths,
...@@ -113,10 +114,15 @@ class LibraryStore(BaseStore): ...@@ -113,10 +114,15 @@ class LibraryStore(BaseStore):
callback(needed, inherited_rpaths=next_rpaths, callback(needed, inherited_rpaths=next_rpaths,
ld_library_paths=ld_library_paths) ld_library_paths=ld_library_paths)
target.all_imported_libs.update(needed.all_imported_libs) # Keep track of the recursively needed libraries
next_level_needed.update(needed.all_imported_libs)
# We found the compatible one, continue with next needed lib # We found the compatible one, continue with next needed lib
break break
# Only add the recursively needed libraries after all directly needed
# libraries have been added, as symbol resolution is breadth-first
# (see ELF specification, Dynamic Linking / Shared Object Dependencies)
target.all_imported_libs.update(next_level_needed)
def _resolve_libs(self, library, path="", callback=None, def _resolve_libs(self, library, path="", callback=None,
inherited_rpaths=None, ld_library_paths=None): inherited_rpaths=None, ld_library_paths=None):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment