Skip to content

Commit

Permalink
symbol-check: Fix readelf output parsing
Browse files Browse the repository at this point in the history
Github-Pull: bitcoin#14066
Rebased-From: 1228df0
  • Loading branch information
luke-jr committed Oct 22, 2018
1 parent c0029ee commit 3b1ba09
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions contrib/devtools/symbol-check.py
Expand Up @@ -111,12 +111,20 @@ def read_symbols(executable, imports=True):
raise IOError('Could not read symbols for %s: %s' % (executable, stderr.strip()))
syms = []
for line in stdout.splitlines():
line = line.split()
if 'Machine:' in line:
arch = line[-1]
if len(line)>7 and re.match('[0-9]+:$', line[0]):
(sym, _, version) = line[7].partition('@')
is_import = line[6] == 'UND'
words = line.split()
if 'Machine:' in words:
arch = words[-1]

# NOTE: POWER architecture has two different offsets for symbols, which readelf includes in its output as an extra column.
#
# For example:
# 4: 0000000000000000 0 FUNC GLOBAL DEFAULT [<localentry>: 8] UND memcpy@GLIBC_2.17 (2)
#
# Relevant POWER docs: http://openpowerfoundation.org/wp-content/uploads/resources/leabi/content/dbdoclet.50655241_95185.html
m = re.match(r'^\s*\d+:\s*[\da-f]+\s+\d+\s+(?:(?:\S+\s+){3})(?:\[.*\]\s+)?(\S+)\s+(\S+).*$', line)
if m:
(sym, _, version) = m.group(2).partition('@')
is_import = (m.group(1) == 'UND')
if version.startswith('@'):
version = version[1:]
if is_import == imports:
Expand Down

0 comments on commit 3b1ba09

Please sign in to comment.