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

Side by Side Diff: pnacl/driver/pnacl-translate.py

Issue 352213002: PNaCl dynamic loading: Extend pnacl-translate to be able to translate PSOs (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: Cleanup Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « pnacl/build.sh ('k') | site_scons/site_tools/naclsdk.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2012 The Native Client Authors. All rights reserved. 2 # Copyright (c) 2012 The Native Client Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 # 5 #
6 # IMPORTANT NOTE: If you make local mods to this file, you must run: 6 # IMPORTANT NOTE: If you make local mods to this file, you must run:
7 # % pnacl/build.sh driver 7 # % pnacl/build.sh driver
8 # in order for them to take effect in the scons build. This command 8 # in order for them to take effect in the scons build. This command
9 # updates the copy in the toolchain/ tree. 9 # updates the copy in the toolchain/ tree.
10 # 10 #
11 11
12 import driver_tools 12 import driver_tools
13 import filetype 13 import filetype
14 import ldtools 14 import ldtools
15 import multiprocessing 15 import multiprocessing
16 import os 16 import os
17 import pathtools 17 import pathtools
18 from driver_env import env 18 from driver_env import env
19 from driver_log import Log 19 from driver_log import Log
20 from driver_temps import TempFiles 20 from driver_temps import TempFiles
21 21
22 import subprocess 22 import subprocess
23 23
24 EXTRA_ENV = { 24 EXTRA_ENV = {
25 'PIC': '${NONSFI_NACL}', 25 'TRANSLATE_PSO': '0',
26 'PIC': '${NONSFI_NACL || TRANSLATE_PSO ? 1 : 0}',
26 27
27 # Determine if we should build nexes compatible with the IRT 28 # Determine if we should build nexes compatible with the IRT
28 'USE_IRT' : '1', 29 'USE_IRT' : '1',
29 30
30 # Allow zero-cost C++ exception handling in the pexe, which is not 31 # Allow zero-cost C++ exception handling in the pexe, which is not
31 # supported by PNaCl's stable ABI. 32 # supported by PNaCl's stable ABI.
32 'ALLOW_ZEROCOST_CXX_EH' : '0', 33 'ALLOW_ZEROCOST_CXX_EH' : '0',
33 34
34 # Use the IRT shim by default. This can be disabled with an explicit 35 # Use the IRT shim by default. This can be disabled with an explicit
35 # flag (--noirtshim) or via -nostdlib. 36 # flag (--noirtshim) or via -nostdlib.
(...skipping 26 matching lines...) Expand all
62 # and pnacl/driver/nativeld.py that will fall back to 63 # and pnacl/driver/nativeld.py that will fall back to
63 # libpnacl_irt_shim_dummy.a if libpnacl_irt_shim.a does not exist. 64 # libpnacl_irt_shim_dummy.a if libpnacl_irt_shim.a does not exist.
64 'LD_ARGS_IRT_SHIM': '-l:libpnacl_irt_shim.a', 65 'LD_ARGS_IRT_SHIM': '-l:libpnacl_irt_shim.a',
65 'LD_ARGS_IRT_SHIM_DUMMY': '-l:libpnacl_irt_shim_dummy.a', 66 'LD_ARGS_IRT_SHIM_DUMMY': '-l:libpnacl_irt_shim_dummy.a',
66 # In addition to specifying the entry point, we also specify an undefined 67 # In addition to specifying the entry point, we also specify an undefined
67 # reference to _start, which is called by the shim's entry function, 68 # reference to _start, which is called by the shim's entry function,
68 # __pnacl_wrapper_start. _start normally comes from libnacl and will be in 69 # __pnacl_wrapper_start. _start normally comes from libnacl and will be in
69 # the pexe, however for the IRT it comes from irt_entry.c and when linking it 70 # the pexe, however for the IRT it comes from irt_entry.c and when linking it
70 # using native object files, this reference is required to make sure it gets 71 # using native object files, this reference is required to make sure it gets
71 # pulled in from the archive. 72 # pulled in from the archive.
72 'LD_ARGS_ENTRY': '${NONSFI_NACL && !USE_IRT ' 73 'LD_ARGS_ENTRY':
73 ' ? --entry=__pnacl_start_linux : --entry=__pnacl_start} ' 74 '${TRANSLATE_PSO ? --entry=__pnacl_pso_root : '
74 '--undefined=_start', 75 ' ${NONSFI_NACL && !USE_IRT '
76 ' ? --entry=__pnacl_start_linux : --entry=__pnacl_start} '
77 ' --undefined=_start}',
75 78
76 'CRTBEGIN': '${ALLOW_ZEROCOST_CXX_EH ? -l:crtbegin_for_eh.o : -l:crtbegin.o}', 79 'CRTBEGIN': '${ALLOW_ZEROCOST_CXX_EH ? -l:crtbegin_for_eh.o : -l:crtbegin.o}',
77 'CRTEND': '-l:crtend.o', 80 'CRTEND': '-l:crtend.o',
78 81
79 'LD_ARGS_nostdlib': '-nostdlib ${ld_inputs}', 82 'LD_ARGS_nostdlib': '-nostdlib ${ld_inputs}',
80 83
81 # These are just the dependencies in the native link. 84 # These are just the dependencies in the native link.
82 'LD_ARGS_normal': 85 'LD_ARGS_normal':
83 '${CRTBEGIN} ${ld_inputs} ' + 86 '${!TRANSLATE_PSO ? ${CRTBEGIN}} ' +
87 '${ld_inputs} ' +
84 '${USE_IRT_SHIM ? ${LD_ARGS_IRT_SHIM} : ${LD_ARGS_IRT_SHIM_DUMMY}} ' + 88 '${USE_IRT_SHIM ? ${LD_ARGS_IRT_SHIM} : ${LD_ARGS_IRT_SHIM_DUMMY}} ' +
85 '--start-group ' + 89 '--start-group ' +
86 '${USE_DEFAULTLIBS ? ${DEFAULTLIBS}} ' + 90 '${USE_DEFAULTLIBS ? ${DEFAULTLIBS}} ' +
87 '--end-group ' + 91 '--end-group ' +
88 '${CRTEND}', 92 '${CRTEND}',
89 93
90 'DEFAULTLIBS': '${ALLOW_ZEROCOST_CXX_EH ? -l:libgcc_eh.a} ' + 94 'DEFAULTLIBS': '${ALLOW_ZEROCOST_CXX_EH ? -l:libgcc_eh.a} ' +
91 '-l:libgcc.a -l:libcrt_platform.a ', 95 '-l:libgcc.a -l:libcrt_platform.a ',
92 96
93 # BE CAREFUL: anything added here can introduce skew between 97 # BE CAREFUL: anything added here can introduce skew between
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 # use up to 4 modules if there are enough cores. If the user overrides, 142 # use up to 4 modules if there are enough cores. If the user overrides,
139 # use as many modules as specified (which could be only 1). 143 # use as many modules as specified (which could be only 1).
140 'SPLIT_MODULE' : '0', 144 'SPLIT_MODULE' : '0',
141 } 145 }
142 146
143 147
144 TranslatorPatterns = [ 148 TranslatorPatterns = [
145 ( '-o(.+)', "env.set('OUTPUT', pathtools.normalize($0))"), 149 ( '-o(.+)', "env.set('OUTPUT', pathtools.normalize($0))"),
146 ( ('-o', '(.+)'), "env.set('OUTPUT', pathtools.normalize($0))"), 150 ( ('-o', '(.+)'), "env.set('OUTPUT', pathtools.normalize($0))"),
147 151
152 ( '-pso', "env.set('TRANSLATE_PSO', '1')"),
153
148 ( '-S', "env.set('OUTPUT_TYPE', 's')"), # Stop at .s 154 ( '-S', "env.set('OUTPUT_TYPE', 's')"), # Stop at .s
149 ( '-c', "env.set('OUTPUT_TYPE', 'o')"), # Stop at .o 155 ( '-c', "env.set('OUTPUT_TYPE', 'o')"), # Stop at .o
150 156
151 # Expose a very limited set of llc flags. 157 # Expose a very limited set of llc flags.
152 # BE CAREFUL: anything added here can introduce skew between 158 # BE CAREFUL: anything added here can introduce skew between
153 # the pnacl-translate commandline tool and the in-browser translator. 159 # the pnacl-translate commandline tool and the in-browser translator.
154 # See: llvm/tools/pnacl-llc/srpc_main.cpp and 160 # See: llvm/tools/pnacl-llc/srpc_main.cpp and
155 # chromium/src/ppapi/native_client/src/trusted/plugin/pnacl_options.cc 161 # chromium/src/ppapi/native_client/src/trusted/plugin/pnacl_options.cc
156 ( '(-sfi-.+)', "env.append('LLC_FLAGS_EXTRA', $0)"), 162 ( '(-sfi-.+)', "env.append('LLC_FLAGS_EXTRA', $0)"),
157 ( '(-mtls-use-call)', "env.append('LLC_FLAGS_EXTRA', $0)"), 163 ( '(-mtls-use-call)', "env.append('LLC_FLAGS_EXTRA', $0)"),
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 env.set('LLC_FLAGS_ARCH', *llc_flags_map.get(env.getone('ARCH'), [])) 259 env.set('LLC_FLAGS_ARCH', *llc_flags_map.get(env.getone('ARCH'), []))
254 # When linking against a host OS's libc (such as Linux glibc), don't 260 # When linking against a host OS's libc (such as Linux glibc), don't
255 # use %gs:0 to read the thread pointer because that won't be 261 # use %gs:0 to read the thread pointer because that won't be
256 # compatible with the libc's use of %gs:0. Similarly, Non-SFI Mode 262 # compatible with the libc's use of %gs:0. Similarly, Non-SFI Mode
257 # currently offers no optimized path for reading the thread pointer. 263 # currently offers no optimized path for reading the thread pointer.
258 if env.getone('TARGET_OS') != 'nacl' or env.getbool('NONSFI_NACL'): 264 if env.getone('TARGET_OS') != 'nacl' or env.getbool('NONSFI_NACL'):
259 env.append('LLC_FLAGS_ARCH', '-mtls-use-call') 265 env.append('LLC_FLAGS_ARCH', '-mtls-use-call')
260 266
261 267
262 def SetUpLinkOptions(): 268 def SetUpLinkOptions():
269 if env.getbool('TRANSLATE_PSO'):
270 # Using "-pie" rather than "-shared" has the effect of suppressing the
271 # creation of a PLT and R_*_JUMP_SLOT relocations, which come from the
272 # external symbol references that multi-threaded translation produces.
273 env.append('LD_FLAGS', '-pie')
274 return
275
263 if env.getbool('NONSFI_NACL'): 276 if env.getbool('NONSFI_NACL'):
264 # "_begin" allows a PIE to find its load address in order to apply 277 # "_begin" allows a PIE to find its load address in order to apply
265 # dynamic relocations. 278 # dynamic relocations.
266 env.append('LD_FLAGS', '-defsym=_begin=0') 279 env.append('LD_FLAGS', '-defsym=_begin=0')
267 if env.getbool('USE_IRT'): 280 if env.getbool('USE_IRT'):
268 env.append('LD_FLAGS', '-pie') 281 env.append('LD_FLAGS', '-pie')
269 else: 282 else:
270 # Note that we really want to use "-pie" for this case, but it 283 # Note that we really want to use "-pie" for this case, but it
271 # currently adds a PT_INTERP header to the executable that we don't 284 # currently adds a PT_INTERP header to the executable that we don't
272 # want because it stops the executable from being loadable by Linux. 285 # want because it stops the executable from being loadable by Linux.
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 533
521 ADVANCED OPTIONS: 534 ADVANCED OPTIONS:
522 -mattr=<+feat1,-feat2> Toggle specific cpu features on and off. 535 -mattr=<+feat1,-feat2> Toggle specific cpu features on and off.
523 -mcpu=<cpu-name> Target a specific cpu type. Tunes code as well as 536 -mcpu=<cpu-name> Target a specific cpu type. Tunes code as well as
524 turns cpu features on and off. 537 turns cpu features on and off.
525 -S Generate native assembly only. 538 -S Generate native assembly only.
526 -c Generate native object file only. 539 -c Generate native object file only.
527 --pnacl-sb Use the translator which runs inside the NaCl sandbox. 540 --pnacl-sb Use the translator which runs inside the NaCl sandbox.
528 -O[0-3] Change translation-time optimization level. 541 -O[0-3] Change translation-time optimization level.
529 """ 542 """
OLDNEW
« no previous file with comments | « pnacl/build.sh ('k') | site_scons/site_tools/naclsdk.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698