Chromium Code Reviews| Index: build/android/gyp/pack_arm_relocations.py |
| diff --git a/build/android/gyp/pack_arm_relocations.py b/build/android/gyp/pack_arm_relocations.py |
| index d650927ac858ffbd8b115efe787b8a48b5538b32..c6457e7eb20130b1db122200e1249e89b2792828 100755 |
| --- a/build/android/gyp/pack_arm_relocations.py |
| +++ b/build/android/gyp/pack_arm_relocations.py |
| @@ -7,10 +7,10 @@ |
| """Pack ARM relative relocations in a library (or copy unchanged). |
| If --enable-packing and --configuration-name=='Release', invoke the |
| -relocation_packer tool to pack the .rel.dyn section in the given library |
| -files. This step is inserted after the libraries are stripped. Packing |
| -adds a new .android.rel.dyn section to the file and reduces the size of |
| -.rel.dyn accordingly. |
| +relocation_packer tool to pack the .rel.dyn or .rela.dyn section in the given |
| +library files. This step is inserted after the libraries are stripped. |
| +Packing adds a new .android.rel.dyn or .android.rela.dyn section to the file |
| +and reduces the size of .rel.dyn or .rela.dyn accordingly. |
| Currently packing only understands ARM32 shared libraries. For all other |
| architectures --enable-packing should be set to zero. In this case the |
| @@ -37,12 +37,22 @@ def PackArmLibraryRelocations(android_pack_relocations, |
| if not build_utils.IsTimeStale(output_path, [library_path]): |
| return |
| - # Copy and add a 'NULL' .android.rel.dyn section for the packing tool. |
| + # 32-bit libraries will contain .rel.dyn, and 64-bit ones .rela.dyn. |
| + # Select an appropriate name for the section we add. |
| + # From elf.h, e_ident[EI_CLASS (4)] == ELFCLASS32 (1) or ELFCLASS64 (2). |
| + with open(library_path) as stream: |
| + elfclass = ord(stream.read(5)[-1]) |
| + if elfclass == 2: |
| + new_section = '.android.rela.dyn' |
| + else: |
| + 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
|
| + |
| + # Copy and add a 'NULL' packed relocations section for the packing tool. |
| with tempfile.NamedTemporaryFile() as stream: |
| stream.write('NULL') |
| stream.flush() |
| objcopy_command = [android_objcopy, |
| - '--add-section', '.android.rel.dyn=%s' % stream.name, |
| + '--add-section', '%s=%s' % (new_section, stream.name), |
| library_path, output_path] |
| build_utils.CheckOutput(objcopy_command) |