[llvm-nm] - Add a test case for case when we dump a symbol that belongs to a section...
[llvm-complete.git] / runtimes / llvm-strip-link.in
bloba7b8c567faf62a9297d570481d5ede53a0574c06
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
4 import os
5 import sys
6 import subprocess
9 ELF_MAGIC = '\x7fELF'
11 with open(sys.argv[1], "rb") as f:
12 buf = f.read(len(ELF_MAGIC))
13 if buf != ELF_MAGIC:
14 sys.exit(0)
16 llvm_objcopy = os.path.join('@LLVM_RUNTIME_OUTPUT_INTDIR@', 'llvm-objcopy')
17 install_dir = os.path.join(os.getenv('DESTDIR', ''), '@CMAKE_INSTALL_PREFIX@')
18 link_dir = os.path.join(install_dir, 'lib', 'debug', '.build-id')
20 sys.exit(subprocess.call([
21 llvm_objcopy,
22 '--strip-all',
23 '--build-id-link-dir=' + link_dir,
24 '--build-id-link-input=.debug',
25 '--build-id-link-output=',
26 sys.argv[1],
27 ]))