Skip to content

Commit

Permalink
Parse relocations even when not applying them (#426)
Browse files Browse the repository at this point in the history
* Parse relocations even when not applying them

* dangerous territory
  • Loading branch information
rhelmot authored Sep 14, 2023
1 parent 9bf328d commit 664490f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
3 changes: 0 additions & 3 deletions cle/backends/elf/elf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1050,9 +1050,6 @@ def __parse_rpath(self, runpath, rpath):
return parts

def __register_relocs(self, section, dynsym=None, force_jmprel=False):
if not self.loader._perform_relocations:
return

got_min = got_max = 0

if not force_jmprel:
Expand Down
25 changes: 12 additions & 13 deletions cle/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -878,19 +878,18 @@ def visit(obj):
self.tls.register_object(obj)

# link everything
if self._perform_relocations:
for obj in ordered_objects:
log.info("Linking %s", obj.binary)
sibling_objs = list(obj.parent_object.child_objects) if obj.parent_object is not None else []
stripped_deps = [
dep if not self._ignore_import_version_numbers else dep.rstrip(".0123456789") for dep in obj.deps
]
dep_objs = [soname_mapping[dep_name] for dep_name in stripped_deps if dep_name in soname_mapping]
main_objs = [self.main_object] if self.main_object is not obj else []
for reloc in obj.relocs:
reloc.resolve_symbol(
main_objs + preload_objects + sibling_objs + dep_objs + [obj], extern_object=extern_obj
)
for obj in ordered_objects:
log.info("Linking %s", obj.binary)
sibling_objs = list(obj.parent_object.child_objects) if obj.parent_object is not None else []
stripped_deps = [
dep if not self._ignore_import_version_numbers else dep.rstrip(".0123456789") for dep in obj.deps
]
dep_objs = [soname_mapping[dep_name] for dep_name in stripped_deps if dep_name in soname_mapping]
main_objs = [self.main_object] if self.main_object is not obj else []
for reloc in obj.relocs:
reloc.resolve_symbol(
main_objs + preload_objects + sibling_objs + dep_objs + [obj], extern_object=extern_obj
)

# if the extern object was used, add it to the list of objects we're mapping
# also add it to the linked list of extern objects
Expand Down

0 comments on commit 664490f

Please sign in to comment.