Skip to content

Commit

Permalink
Fix issue windelbouwman#102 by better selecting the library objectfil…
Browse files Browse the repository at this point in the history
…e to merge: select only objectfiles defining globally at least one yet unresolved symbol
  • Loading branch information
tstreiff committed Jun 30, 2020
1 parent ca4e910 commit 0fad263
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ppci/binutils/linker.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ def add_missing_symbols_from_libraries(self, libraries):
for library in libraries:
self.logger.debug("scanning library for symbols %s", library)
for obj in library:
has_sym = any(map(obj.has_symbol, undefined_symbols))
has_sym = any(map(obj.is_defined_global, undefined_symbols))
if has_sym:
self.logger.debug(
"Using object file %s from library", obj
Expand Down
10 changes: 10 additions & 0 deletions ppci/binutils/objectfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ def defined(self):
def is_global(self):
return self.binding == "global"

@property
def is_defined_global(self):
""" Test if the symbol in defined and global. """
return self.value is not None and self.binding == "global"

@property
def is_function(self):
""" Test if this symbol is a function. """
Expand Down Expand Up @@ -250,6 +255,11 @@ def has_symbol(self, name):
""" Check if this object file has a symbol with name 'name' """
return name in self.symbol_map

def is_defined_global(self, name):
""" Test if the symbol "name" is defined and global in "self" """
sym = self.symbol_map.get(name)
return sym and sym.is_defined_global

def get_symbol(self, name):
""" Get a symbol """
return self.symbol_map[name]
Expand Down

0 comments on commit 0fad263

Please # to comment.