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

Unified Diff: pydir/szbuild.py

Issue 1506653002: Subzero: Add Non-SFI support for x86-32. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fill in part of the lit test Created 5 years 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 side-by-side diff with in-line comments
Download patch
Index: pydir/szbuild.py
diff --git a/pydir/szbuild.py b/pydir/szbuild.py
index 37dbc6eaad8c123df3b6153650b2aa6b47fc1d06..a520d13d6efe68015eda44efd04aded2a2db48ab 100755
--- a/pydir/szbuild.py
+++ b/pydir/szbuild.py
@@ -85,6 +85,8 @@ def AddOptionalArgs(argparser):
help='Output file type. Default %(default)s.')
argparser.add_argument('--sandbox', dest='sandbox', action='store_true',
help='Enable sandboxing in the translator')
+ argparser.add_argument('--nonsfi', dest='nonsfi', action='store_true',
+ help='Enable Non-SFI in the translator')
argparser.add_argument('--enable-block-profile',
dest='enable_block_profile', action='store_true',
help='Enable basic block profiling.')
@@ -183,13 +185,15 @@ def ProcessPexe(args, pexe, exe):
opt_level = args.optlevel
opt_level_map = { 'm1':'0', '-1':'0', '0':'0', '1':'1', '2':'2' }
hybrid = args.include or args.exclude
+ sb_or_nonsfi = args.sandbox or args.nonsfi
if hybrid and (args.force or
NewerThanOrNotThere(pexe, obj_llc) or
NewerThanOrNotThere(llcbin, obj_llc)):
arch = {
'arm32': 'armv7' if args.sandbox else 'arm-nonsfi',
- 'x8632': 'x86-32' if args.sandbox else 'x86-32-linux',
+ 'x8632': 'x86-32' if args.sandbox else
John 2015/12/22 15:44:38 this makes me sad. can something be done about thi
Jim Stichnoth 2015/12/28 07:54:07 What is your specific suggestion? (just to avoid
+ 'x86-32-nonsfi' if args.nonsfi else 'x86-32-linux',
}[args.target]
# Only run pnacl-translate in hybrid mode.
@@ -206,7 +210,7 @@ def ProcessPexe(args, pexe, exe):
args.llc_args +
[pexe],
echo=args.verbose)
- if not args.sandbox:
+ if not sb_or_nonsfi:
shellcmd((
'{objcopy} --redefine-sym _start=_user_start {obj}'
).format(objcopy=objcopy, obj=obj_llc), echo=args.verbose)
@@ -230,6 +234,7 @@ def ProcessPexe(args, pexe, exe):
'-ffunction-sections',
'-fdata-sections'] if hybrid else []) +
(['-sandbox'] if args.sandbox else []) +
+ (['-nonsfi'] if args.nonsfi else []) +
(['-enable-block-profile'] if
args.enable_block_profile and not args.sandbox
else []) +
@@ -247,7 +252,7 @@ def ProcessPexe(args, pexe, exe):
).format(base=path_addition, asm=asm_sz, obj=obj_sz,
triple=triple),
echo=args.verbose)
- if not args.sandbox:
+ if not sb_or_nonsfi:
shellcmd((
'{objcopy} --redefine-sym _start=_user_start {obj}'
).format(objcopy=objcopy, obj=obj_sz), echo=args.verbose)
@@ -313,7 +318,7 @@ def ProcessPexe(args, pexe, exe):
'{objcopy} --globalize-symbol={start} ' +
'--globalize-symbol=__Sz_block_profile_info {partial}'
).format(objcopy=objcopy, partial=obj_partial,
- start='_start' if args.sandbox else '_user_start'),
+ start='_start' if sb_or_nonsfi else '_user_start'),
echo=args.verbose)
# Run the linker regardless of hybrid mode.
@@ -341,6 +346,32 @@ def ProcessPexe(args, pexe, exe):
).format(gold=gold, linklib=linklib, partial=obj_partial, exe=exe,
root=nacl_root, target=args.target),
echo=args.verbose)
+ elif args.nonsfi:
+ # TODO(stichnot): args.nonsfi and args.sandbox branches are nearly
+ # identical; refactor.
+ target_lib_dir = {
+ 'arm32': 'arm-nonsfi',
+ 'x8632': 'x86-32-nonsfi',
+ }[args.target]
+ linklib = ('{root}/toolchain/linux_x86/pnacl_newlib_raw/translator/' +
+ '{target_dir}/lib').format(root=nacl_root,
+ target_dir=target_lib_dir)
+ shellcmd((
+ '{gold} -nostdlib --no-fix-cortex-a8 --eh-frame-hdr -z text ' +
+ '-z noexecstack ' +
+ '--build-id --entry=__pnacl_start -pie ' +
+ '{linklib}/crtbegin.o {partial} ' +
+ '{root}/toolchain_build/src/subzero/build/runtime/' +
+ 'szrt_nonsfi_{target}.o ' +
+ '{linklib}/libpnacl_irt_shim_dummy.a --start-group ' +
+ '{linklib}/libgcc.a {linklib}/libcrt_platform.a ' +
+ '--end-group {linklib}/crtend.o --undefined=_start ' +
+ '--defsym=__Sz_AbsoluteZero=0 ' +
+ '--defsym=_begin=0 ' +
+ '-o {exe}'
+ ).format(gold=gold, linklib=linklib, partial=obj_partial, exe=exe,
+ root=nacl_root, target=args.target),
+ echo=args.verbose)
else:
linker = {
'arm32': '/usr/bin/arm-linux-gnueabihf-g++',

Powered by Google App Engine
This is Rietveld 408576698