Skip to content

Commit b086197

Browse files
author
John Kleinschmidt
authored
fix: use system installed objcopy to copy debug symbols (electron#23835)
1 parent e8ea007 commit b086197

3 files changed

Lines changed: 13 additions & 31 deletions

File tree

script/add-debug-link.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import sys
66

77
from lib.config import LINUX_BINARIES, PLATFORM
8-
from lib.util import execute, get_objcopy_path, get_out_dir
8+
from lib.util import execute, get_out_dir
99

1010
def add_debug_link_into_binaries(directory, target_cpu, debug_dir):
1111
for binary in LINUX_BINARIES:
@@ -14,18 +14,15 @@ def add_debug_link_into_binaries(directory, target_cpu, debug_dir):
1414
add_debug_link_into_binary(binary_path, target_cpu, debug_dir)
1515

1616
def add_debug_link_into_binary(binary_path, target_cpu, debug_dir):
17-
try:
18-
objcopy = get_objcopy_path(target_cpu)
19-
except:
20-
if PLATFORM == 'linux' and (target_cpu == 'x86' or target_cpu == 'arm' or
21-
target_cpu == 'arm64'):
22-
# Skip because no objcopy binary on the given target.
23-
return
24-
raise
17+
if PLATFORM == 'linux' and (target_cpu == 'x86' or target_cpu == 'arm' or
18+
target_cpu == 'arm64'):
19+
# Skip because no objcopy binary on the given target.
20+
return
21+
2522
debug_name = get_debug_name(binary_path)
2623
# Make sure the path to the binary is not relative because of cwd param.
2724
real_binary_path = os.path.realpath(binary_path)
28-
cmd = [objcopy, '--add-gnu-debuglink=' + debug_name, real_binary_path]
25+
cmd = ['objcopy', '--add-gnu-debuglink=' + debug_name, real_binary_path]
2926
execute(cmd, cwd=debug_dir)
3027

3128
def get_debug_name(binary_path):

script/copy-debug-symbols.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import sys
66

77
from lib.config import LINUX_BINARIES, PLATFORM
8-
from lib.util import execute, get_objcopy_path, get_out_dir, safe_mkdir
8+
from lib.util import execute, get_out_dir, safe_mkdir
99

1010
# It has to be done before stripping the binaries.
1111
def copy_debug_from_binaries(directory, out_dir, target_cpu, compress):
@@ -15,16 +15,12 @@ def copy_debug_from_binaries(directory, out_dir, target_cpu, compress):
1515
copy_debug_from_binary(binary_path, out_dir, target_cpu, compress)
1616

1717
def copy_debug_from_binary(binary_path, out_dir, target_cpu, compress):
18-
try:
19-
objcopy = get_objcopy_path(target_cpu)
20-
except:
21-
if PLATFORM == 'linux' and (target_cpu == 'x86' or target_cpu == 'arm' or
22-
target_cpu == 'arm64'):
23-
# Skip because no objcopy binary on the given target.
24-
return
25-
raise
18+
if PLATFORM == 'linux' and (target_cpu == 'x86' or target_cpu == 'arm' or
19+
target_cpu == 'arm64'):
20+
# Skip because no objcopy binary on the given target.
21+
return
2622
debug_name = get_debug_name(binary_path)
27-
cmd = [objcopy, '--only-keep-debug']
23+
cmd = ['objcopy', '--only-keep-debug']
2824
if compress:
2925
cmd.extend(['--compress-debug-sections'])
3026
cmd.extend([binary_path, os.path.join(out_dir, debug_name)])

script/lib/util.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -268,14 +268,3 @@ def get_buildtools_executable(name):
268268
if sys.platform == 'win32':
269269
path += '.exe'
270270
return path
271-
272-
def get_objcopy_path(target_cpu):
273-
if PLATFORM != 'linux':
274-
raise Exception(
275-
"get_objcopy_path: unexpected platform '{0}'".format(PLATFORM))
276-
277-
if target_cpu != 'x64':
278-
raise Exception(
279-
"get_objcopy_path: unexpected target cpu '{0}'".format(target_cpu))
280-
return os.path.join(SRC_DIR, 'third_party', 'binutils', 'Linux_x64',
281-
'Release', 'bin', 'objcopy')

0 commit comments

Comments
 (0)