Skip to content

Commit

Permalink
wafsamba/symbols: change regex to match both rpath and runpath for di…
Browse files Browse the repository at this point in the history
…fferent readelf output

In `wafsamba.dumplicate_symbols` test, it will use Popen to call:

    readelf --dynamic bin/default/source3/lib/netapi/examples/netlogon/netlogon_control2

then try to find rpath lib lines from output with regex:

    re_rpath     = re.compile(b'Library rpath: \[(.*)\]')

In ubuntu 14.04 docker image, which current CI is using, the actual output
from `readelf` is `runpath` instead of 'rpath':

    ...
    Library runpath: [/home/gitlab-runner/samba/bin/shared:/home/gitlab-runner/samba/bin/shared/private]\n'
    ...

So the regex never matched, and hide a bug.

In Ubuntu 1604 docker image, the output changes to `rpath` and matched the
regex, which expose the error in previous commit.

Improve the regex to match both `rpath` and `runpath`.

Signed-off-by: Joe Guo <[email protected]>
Reviewed-by: Alexander Bokovoy <[email protected]>
Reviewed-by: Andrew Bartlett <[email protected]>
  • Loading branch information
catalyst-joe-guo authored and abartlet committed Feb 18, 2019
1 parent 4843a27 commit 9fa698b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions buildtools/wafsamba/symbols.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ def find_ldd_path(bld, libname, binary):

# some regular expressions for parsing readelf output
re_sharedlib = re.compile(b'Shared library: \[(.*)\]')
re_rpath = re.compile(b'Library rpath: \[(.*)\]')
# output from readelf could be `Library rpath` or `Libray runpath`
re_rpath = re.compile(b'Library (rpath|runpath): \[(.*)\]')

def get_libs(bld, binname):
'''find the list of linked libraries for any binary or library
Expand All @@ -147,7 +148,7 @@ def get_libs(bld, binname):
m = re_rpath.search(line)
if m:
# output from Popen is always bytestr even in py3
rpath.extend(m.group(1).split(b":"))
rpath.extend(m.group(2).split(b":"))

ret = set()
for lib in libs:
Expand Down

0 comments on commit 9fa698b

Please sign in to comment.