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

Side by Side Diff: src/untrusted/irt/check_tls.py

Issue 12386091: Simplify check_tls on ARM, now that llvm emits mapping symbols. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: Created 7 years, 9 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 | « src/untrusted/irt/check_tls.gypi ('k') | src/untrusted/irt/nacl.scons » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 The Native Client Authors. All rights reserved. 1 # Copyright (c) 2012 The Native Client 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 # A simple program to run objdump on a file and assert that the ABI TLS 5 # A simple program to run objdump on a file and assert that the ABI TLS
6 # register appears nowhere in it. This ensures that the direct register access 6 # register appears nowhere in it. This ensures that the direct register access
7 # style of TLS is not being used in the IRT blob. 7 # style of TLS is not being used in the IRT blob.
8 8
9 import subprocess 9 import subprocess
10 import sys 10 import sys
(...skipping 13 matching lines...) Expand all
24 whitelist_regex = None 24 whitelist_regex = None
25 if arch == 'x86-32': 25 if arch == 'x86-32':
26 objdump_args = [objdump, '-d', obj_file] 26 objdump_args = [objdump, '-d', obj_file]
27 # "%gs:4" is allowed but all other uses of %gs are suspect. 27 # "%gs:4" is allowed but all other uses of %gs are suspect.
28 register = '%gs' 28 register = '%gs'
29 regex = re.compile(register + r'(?!:0x4\b)') 29 regex = re.compile(register + r'(?!:0x4\b)')
30 elif arch == 'x86-64': 30 elif arch == 'x86-64':
31 # Nothing to check. 31 # Nothing to check.
32 regex = None 32 regex = None
33 elif arch.startswith('arm'): 33 elif arch.startswith('arm'):
34 if arch == 'arm-gcc': 34 objdump_flags = ['-d']
35 objdump_flags = ['-d']
36 elif arch == 'arm-pnacl':
37 # TODO(mcgrathr): Just use -d when PNaCl compiler is fixed so it works.
38 # See http://code.google.com/p/nativeclient/issues/detail?id=2818
39 objdump_flags = ['-D', '--section=.text']
40 objdump_args = [objdump] + objdump_flags + [obj_file] 35 objdump_args = [objdump] + objdump_flags + [obj_file]
41 # A real reference to r9 should probably be preceded by some character 36 # A real reference to r9 should probably be preceded by some character
42 # that is not legal for an identifier (e.g., spaces, commas, brackets). 37 # that is not legal for an identifier (e.g., spaces, commas, brackets).
43 register = 'r9' 38 register = 'r9'
44 regex = re.compile('[^_\w]' + register) 39 regex = re.compile('[^_\w]' + register)
45 whitelist_regex = re.compile(r'ldr\s+r0,\s*\[r9,\s*#4\]\s*$') 40 whitelist_regex = re.compile(r'ldr\s+r0,\s*\[r9,\s*#4\]\s*$')
46 else: 41 else:
47 print 'Unknown architecture: %s' % arch 42 print 'Unknown architecture: %s' % arch
48 sys.exit(1) 43 sys.exit(1)
49 44
50 if regex is not None: 45 if regex is not None:
51 proc = subprocess.Popen(objdump_args, 46 proc = subprocess.Popen(objdump_args,
Roland McGrath 2013/03/04 23:15:41 objdump_flags and objdump_args are now set uncondi
jvoung (off chromium) 2013/03/05 00:34:40 Done.
52 stdout=subprocess.PIPE, 47 stdout=subprocess.PIPE,
53 bufsize=-1) 48 bufsize=-1)
54 for line in proc.stdout: 49 for line in proc.stdout:
55 if regex.search(line) and not (whitelist_regex is not None and 50 if regex.search(line) and not (whitelist_regex is not None and
56 whitelist_regex.search(line)): 51 whitelist_regex.search(line)):
57 print '%s use found: %s' % (register, line) 52 print '%s use found: %s' % (register, line)
58 print 'This looks like an %s direct TLS use.' % arch 53 print 'This looks like an %s direct TLS use.' % arch
59 print 'Such uses are disallowed by the IRT context constraints.' 54 print 'Such uses are disallowed by the IRT context constraints.'
60 print 'These never happen if -mtls-use-call is used in the compilation.' 55 print 'These never happen if -mtls-use-call is used in the compilation.'
61 print 'Check that all libraries used in the IRT were compiled that way.' 56 print 'Check that all libraries used in the IRT were compiled that way.'
62 sys.exit(1) 57 sys.exit(1)
63 if proc.wait() != 0: 58 if proc.wait() != 0:
64 print 'Command failed: %s' % objdump_args 59 print 'Command failed: %s' % objdump_args
65 sys.exit(1) 60 sys.exit(1)
66 61
67 if outfile is not None: 62 if outfile is not None:
68 outf = open(outfile, 'w') 63 outf = open(outfile, 'w')
69 outf.write('TLS in %s OK\n' % obj_file) 64 outf.write('TLS in %s OK\n' % obj_file)
70 outf.close() 65 outf.close()
71 66
72 67
73 if __name__ == '__main__': 68 if __name__ == '__main__':
74 Main(sys.argv[1:]) 69 Main(sys.argv[1:])
OLDNEW
« no previous file with comments | « src/untrusted/irt/check_tls.gypi ('k') | src/untrusted/irt/nacl.scons » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698