symbolextractor: add OpenBSD support

pull/7084/head
Antoine Jacoutot 5 years ago committed by Dylan Baker
parent 6fe68edbf8
commit bf34b97112
  1. 19
      mesonbuild/scripts/symbolextractor.py

@ -142,6 +142,23 @@ def osx_syms(libfilename: str, outfilename: str):
result += [' '.join(x.split()[0:2]) for x in output.split('\n')] result += [' '.join(x.split()[0:2]) for x in output.split('\n')]
write_if_changed('\n'.join(result) + '\n', outfilename) write_if_changed('\n'.join(result) + '\n', outfilename)
def openbsd_syms(libfilename: str, outfilename: str):
# Get the name of the library
output = call_tool('readelf', ['-d', libfilename])
if not output:
dummy_syms(outfilename)
return
result = [x for x in output.split('\n') if 'SONAME' in x]
assert(len(result) <= 1)
# Get a list of all symbols exported
output = call_tool('nm', ['-D', '-P', '-g', libfilename])
if not output:
dummy_syms(outfilename)
return
# U = undefined (cope with the lack of --defined-only option)
result += [' '.join(x.split()[0:2]) for x in output.split('\n') if x and not x.endswith('U ')]
write_if_changed('\n'.join(result) + '\n', outfilename)
def cygwin_syms(impfilename: str, outfilename: str): def cygwin_syms(impfilename: str, outfilename: str):
# Get the name of the library # Get the name of the library
output = call_tool('dlltool', ['-I', impfilename]) output = call_tool('dlltool', ['-I', impfilename])
@ -237,6 +254,8 @@ def gen_symbols(libfilename: str, impfilename: str, outfilename: str, cross_host
gnu_syms(libfilename, outfilename) gnu_syms(libfilename, outfilename)
elif mesonlib.is_osx(): elif mesonlib.is_osx():
osx_syms(libfilename, outfilename) osx_syms(libfilename, outfilename)
elif mesonlib.is_openbsd():
openbsd_syms(libfilename, outfilename)
elif mesonlib.is_windows(): elif mesonlib.is_windows():
if os.path.isfile(impfilename): if os.path.isfile(impfilename):
windows_syms(impfilename, outfilename) windows_syms(impfilename, outfilename)

Loading…
Cancel
Save