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

Unified Diff: tools/set_abi_version.py

Issue 4181005: Fixes some bugs with memory setup and halt-sled allocation and... (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: '' Created 10 years, 1 month 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
« no previous file with comments | « tools/nacl_elf_constants.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/set_abi_version.py
===================================================================
--- tools/set_abi_version.py (revision 3633)
+++ tools/set_abi_version.py (working copy)
@@ -32,7 +32,9 @@
import getopt
import sys
+import nacl_elf_constants
+
"""Changes the OS ABI number of Native Client executables.
This module contains code for updating the OS ABI version number of
@@ -44,10 +46,13 @@
"""
+ELF_OSABI_OFFSET = 7
ELF_ABIVERSION_OFFSET = 8
+OS_NUMBER_NACL = 123
-def SetOsAbiVersion(elf_file_data, version):
+
+def SetOsAbiVersion(elf_file_data, os_number, abi_version):
"""Change the OS ABI number of a string, interpreted as an NaCl executable.
Args:
@@ -57,12 +62,17 @@
Returns:
Updated ELF NaCl executable.
"""
- return (elf_file_data[:ELF_ABIVERSION_OFFSET]
- + chr(version) + elf_file_data[ELF_ABIVERSION_OFFSET + 1:])
+ data = elf_file_data
+
+ data = (data[:ELF_OSABI_OFFSET]
+ + chr(os_number) + data[ELF_OSABI_OFFSET + 1:])
+ data = (data[:ELF_ABIVERSION_OFFSET]
+ + chr(abi_version) + data[ELF_ABIVERSION_OFFSET + 1:])
+ return data
#enddef
-def ModifyFileOsAbiVersion(filename, version):
+def ModifyFileOsAbiVersion(filename, os_number, abi_version):
"""Changes the OS ABI number of the named file.
No sanity checking is done on the file's contents to verify that it
@@ -78,7 +88,8 @@
"""
file_data = open(filename, 'rb').read()
- open(filename, 'wb').write(SetOsAbiVersion(file_data, version))
+ open(filename, 'wb').write(SetOsAbiVersion(file_data,
+ os_number, abi_version))
# enddef
@@ -98,14 +109,21 @@
def main(argv):
abi_version = -1
try:
- (opts, args) = getopt.getopt(argv[1:], 'v:')
+ (opts, args) = getopt.getopt(argv[1:], 'c:v:')
except getopt.error, e:
print >>sys.stderr, str(e)
print >>sys.stderr, 'Usage: set_abi_version [-v version_num] filename...'
return 1
# endtry
+
+ os_number = OS_NUMBER_NACL # default
+
for opt, val in opts:
- if opt == '-v':
+ if opt == '-c':
+ const_dict = nacl_elf_constants.GetNaClElfConstants(val)
+ os_number = const_dict['ELFOSABI_NACL']
+ abi_version = const_dict['EF_NACL_ABIVERSION']
+ elif opt == '-v':
abi_version = int(val)
# endif
# endfor
@@ -117,7 +135,7 @@
new_abi = abi_version
# endif
- ModifyFileOsAbiVersion(filename, new_abi)
+ ModifyFileOsAbiVersion(filename, os_number, new_abi)
# endfor
return 0
« no previous file with comments | « tools/nacl_elf_constants.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698