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

Side by Side Diff: build/android/gyp/pack_arm_relocations.py

Issue 635863002: Name packed relocations section appropriately for arm64. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
« no previous file with comments | « no previous file | no next file » | 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/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright 2014 The Chromium Authors. All rights reserved. 3 # Copyright 2014 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """Pack ARM relative relocations in a library (or copy unchanged). 7 """Pack ARM relative relocations in a library (or copy unchanged).
8 8
9 If --enable-packing and --configuration-name=='Release', invoke the 9 If --enable-packing and --configuration-name=='Release', invoke the
10 relocation_packer tool to pack the .rel.dyn section in the given library 10 relocation_packer tool to pack the .rel.dyn or .rela.dyn section in the given
11 files. This step is inserted after the libraries are stripped. Packing 11 library files. This step is inserted after the libraries are stripped.
12 adds a new .android.rel.dyn section to the file and reduces the size of 12 Packing adds a new .android.rel.dyn or .android.rela.dyn section to the file
13 .rel.dyn accordingly. 13 and reduces the size of .rel.dyn or .rela.dyn accordingly.
14 14
15 Currently packing only understands ARM32 shared libraries. For all other 15 Currently packing only understands ARM32 shared libraries. For all other
16 architectures --enable-packing should be set to zero. In this case the 16 architectures --enable-packing should be set to zero. In this case the
17 script copies files verbatim, with no attempt to pack relative relocations. 17 script copies files verbatim, with no attempt to pack relative relocations.
18 18
19 Any library listed in --exclude-packing-list is also copied verbatim, 19 Any library listed in --exclude-packing-list is also copied verbatim,
20 irrespective of any --enable-packing setting. Typically this would be 20 irrespective of any --enable-packing setting. Typically this would be
21 'libchromium_android_linker.so'. 21 'libchromium_android_linker.so'.
22 """ 22 """
23 23
24 import optparse 24 import optparse
25 import os 25 import os
26 import shlex 26 import shlex
27 import shutil 27 import shutil
28 import sys 28 import sys
29 import tempfile 29 import tempfile
30 30
31 from util import build_utils 31 from util import build_utils
32 32
33 def PackArmLibraryRelocations(android_pack_relocations, 33 def PackArmLibraryRelocations(android_pack_relocations,
34 android_objcopy, 34 android_objcopy,
35 library_path, 35 library_path,
36 output_path): 36 output_path):
37 if not build_utils.IsTimeStale(output_path, [library_path]): 37 if not build_utils.IsTimeStale(output_path, [library_path]):
38 return 38 return
39 39
40 # Copy and add a 'NULL' .android.rel.dyn section for the packing tool. 40 # 32-bit libraries will contain .rel.dyn, and 64-bit ones .rela.dyn.
41 # Select an appropriate name for the section we add.
42 # From elf.h, e_ident[EI_CLASS (4)] == ELFCLASS32 (1) or ELFCLASS64 (2).
43 with open(library_path) as stream:
44 elfclass = ord(stream.read(5)[-1])
45 if elfclass == 2:
46 new_section = '.android.rela.dyn'
47 else:
48 new_section = '.android.rel.dyn'
rmcilroy 2014/10/07 14:02:39 This seems a bit hacky to work out if it's 32 or 6
simonb (inactive) 2014/10/07 15:34:20 Done. Updated version in patch set 2. PTAL, than
49
50 # Copy and add a 'NULL' packed relocations section for the packing tool.
41 with tempfile.NamedTemporaryFile() as stream: 51 with tempfile.NamedTemporaryFile() as stream:
42 stream.write('NULL') 52 stream.write('NULL')
43 stream.flush() 53 stream.flush()
44 objcopy_command = [android_objcopy, 54 objcopy_command = [android_objcopy,
45 '--add-section', '.android.rel.dyn=%s' % stream.name, 55 '--add-section', '%s=%s' % (new_section, stream.name),
46 library_path, output_path] 56 library_path, output_path]
47 build_utils.CheckOutput(objcopy_command) 57 build_utils.CheckOutput(objcopy_command)
48 58
49 # Pack R_ARM_RELATIVE relocations. 59 # Pack R_ARM_RELATIVE relocations.
50 pack_command = [android_pack_relocations, output_path] 60 pack_command = [android_pack_relocations, output_path]
51 build_utils.CheckOutput(pack_command) 61 build_utils.CheckOutput(pack_command)
52 62
53 63
54 def CopyArmLibraryUnchanged(library_path, output_path): 64 def CopyArmLibraryUnchanged(library_path, output_path):
55 if not build_utils.IsTimeStale(output_path, [library_path]): 65 if not build_utils.IsTimeStale(output_path, [library_path]):
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 CopyArmLibraryUnchanged(library_path, output_path) 116 CopyArmLibraryUnchanged(library_path, output_path)
107 117
108 if options.stamp: 118 if options.stamp:
109 build_utils.Touch(options.stamp) 119 build_utils.Touch(options.stamp)
110 120
111 return 0 121 return 0
112 122
113 123
114 if __name__ == '__main__': 124 if __name__ == '__main__':
115 sys.exit(main(sys.argv[1:])) 125 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698