Skip to content

Commit

Permalink
order rework (#7)
Browse files Browse the repository at this point in the history
* order rework

* remove testing print

* fix formatting and debug print
  • Loading branch information
trws authored Apr 16, 2022
1 parent 5fe6e27 commit 7a55c6c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
8 changes: 4 additions & 4 deletions shrinkwrap/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ def shrinkwrap(file: str, output: Optional[str], link_strategy: str):

strategy = LinkStrategy.select_by_name(link_strategy)
resolution = strategy.explore(binary, file)
needed = binary.libraries
needed = list(binary.libraries)
for name in needed:
binary.remove_library(name)

for soname, lib in resolution.items():
if soname in needed:
binary.remove_library(soname)
for soname, lib in reversed(resolution.items()):
binary.add_library(lib)

# we need to update the VERNEED entries now to match
Expand Down
5 changes: 3 additions & 2 deletions shrinkwrap/elf.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
import re
from abc import ABC, abstractmethod
from collections import OrderedDict
from typing import Dict, Iterable, Optional

import lief # type: ignore
Expand Down Expand Up @@ -35,7 +36,7 @@ class NativeLinkStrategy(LinkStrategy):
def explore(self, binary: lief.Binary, filename: str) -> Dict[str, str]:
interpreter = Command(binary.interpreter)
resolution = interpreter("--list", filename)
result = {}
result = OrderedDict()
# TODO: Figure out why `--list` and `ldd` produce different outcomes
# specifically for the interpreter.
# https://gist.github.com/fzakaria/3dc42a039401598d8e0fdbc57f5e7eae
Expand Down Expand Up @@ -91,7 +92,7 @@ def explore(self, binary: lief.Binary, filename: str) -> Dict[str, str]:
Determine the linking for all needed objects
"""

result = {}
result = OrderedDict()
queue = [binary]
rpaths = []
ld_library_path = os.environ.get("LD_LIBRARY_PATH", "").split(":")
Expand Down

0 comments on commit 7a55c6c

Please sign in to comment.