Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1276)

Side by Side Diff: native_client_sdk/src/tools/lib/get_shared_deps.py

Issue 1398883004: [NaCl SDK] Fix create_nmf to include arm/glibc ELF loader (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Helper script to close over all transitive dependencies of a given .nexe 5 """Helper script to close over all transitive dependencies of a given .nexe
6 executable. 6 executable.
7 7
8 e.g. Given 8 e.g. Given
9 A -> B 9 A -> B
10 B -> C 10 B -> C
11 B -> D 11 B -> D
12 C -> E 12 C -> E
13 13
14 where "A -> B" means A depends on B, then GetNeeded(A) will return A, B, C, D 14 where "A -> B" means A depends on B, then GetNeeded(A) will return A, B, C, D
15 and E. 15 and E.
16 """ 16 """
17 17
18 import os 18 import os
19 import re 19 import re
20 import subprocess 20 import subprocess
21 21
22 import elf 22 import elf
23 23
24 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) 24 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
25 SDK_DIR = os.path.dirname(os.path.dirname(SCRIPT_DIR)) 25 SDK_DIR = os.path.dirname(os.path.dirname(SCRIPT_DIR))
26 26
27 NeededMatcher = re.compile('^ *NEEDED *([^ ]+)\n$') 27 NeededMatcher = re.compile('^ *NEEDED *([^ ]+)\n$')
28 FormatMatcher = re.compile('^(.+):\\s*file format (.+)\n$') 28 FormatMatcher = re.compile('^(.+):\\s*file format (.+)\n$')
29 29
30 RUNNABLE_LD = 'runnable-ld.so' # Name of the dynamic loader 30 LOADER_X86 = 'runnable-ld.so' # Name of the dynamic loader
31 LOADER_ARM = 'elf_loader_arm.nexe' # Name of the ARM dynamic loader
31 32
32 OBJDUMP_ARCH_MAP = { 33 OBJDUMP_ARCH_MAP = {
33 # Names returned by Linux's objdump: 34 # Names returned by Linux's objdump:
34 'elf64-x86-64': 'x86-64', 35 'elf64-x86-64': 'x86-64',
35 'elf32-i386': 'x86-32', 36 'elf32-i386': 'x86-32',
36 'elf32-little': 'arm', 37 'elf32-little': 'arm',
37 'elf32-littlearm': 'arm', 38 'elf32-littlearm': 'arm',
38 # Names returned by old x86_64-nacl-objdump: 39 # Names returned by old x86_64-nacl-objdump:
39 'elf64-nacl': 'x86-64', 40 'elf64-nacl': 'x86-64',
40 'elf32-nacl': 'x86-32', 41 'elf32-nacl': 'x86-32',
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 if dynamic: 83 if dynamic:
83 return _GetNeededDynamic(main_files, objdump, lib_path) 84 return _GetNeededDynamic(main_files, objdump, lib_path)
84 else: 85 else:
85 return _GetNeededStatic(main_files) 86 return _GetNeededStatic(main_files)
86 87
87 88
88 def _GetNeededDynamic(main_files, objdump, lib_path): 89 def _GetNeededDynamic(main_files, objdump, lib_path):
89 examined = set() 90 examined = set()
90 all_files, unexamined = GleanFromObjdump(main_files, None, objdump, lib_path) 91 all_files, unexamined = GleanFromObjdump(main_files, None, objdump, lib_path)
91 for arch in all_files.itervalues(): 92 for arch in all_files.itervalues():
92 if unexamined and arch != 'arm': 93 if unexamined:
93 unexamined.add((RUNNABLE_LD, arch)) 94 if arch == 'arm':
95 unexamined.add((LOADER_ARM, arch))
96 else:
97 unexamined.add((LOADER_X86, arch))
94 98
95 while unexamined: 99 while unexamined:
96 files_to_examine = {} 100 files_to_examine = {}
97 101
98 # Take all the currently unexamined files and group them 102 # Take all the currently unexamined files and group them
99 # by architecture. 103 # by architecture.
100 for name, arch in unexamined: 104 for name, arch in unexamined:
101 files_to_examine.setdefault(arch, []).append(name) 105 files_to_examine.setdefault(arch, []).append(name)
102 106
103 # Call GleanFromObjdump() for each architecture. 107 # Call GleanFromObjdump() for each architecture.
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 raise Error('cannot find library %s' % name) 228 raise Error('cannot find library %s' % name)
225 return files 229 return files
226 230
227 231
228 def _GetNeededStatic(main_files): 232 def _GetNeededStatic(main_files):
229 needed = {} 233 needed = {}
230 for filename in main_files: 234 for filename in main_files:
231 arch = elf.ParseElfHeader(filename)[0] 235 arch = elf.ParseElfHeader(filename)[0]
232 needed[filename] = arch 236 needed[filename] = arch
233 return needed 237 return needed
OLDNEW
« no previous file with comments | « native_client_sdk/src/tools/create_nmf.py ('k') | native_client_sdk/src/tools/lib/tests/data/test_dynamic_arm.nexe » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698