| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium 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 #include "elf_file.h" | 5 #include "elf_file.h" |
| 6 | 6 |
| 7 #include <stdlib.h> | 7 #include <stdlib.h> |
| 8 #include <sys/types.h> | 8 #include <sys/types.h> |
| 9 #include <unistd.h> | 9 #include <unistd.h> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "debug.h" | 13 #include "debug.h" |
| 14 #include "elf_traits.h" | 14 #include "elf_traits.h" |
| 15 #include "libelf.h" | 15 #include "libelf.h" |
| 16 #include "packer.h" | 16 #include "packer.h" |
| 17 | 17 |
| 18 namespace relocation_packer { | 18 namespace relocation_packer { |
| 19 | 19 |
| 20 // Stub identifier written to 'null out' packed data, "NULL". | 20 // Stub identifier written to 'null out' packed data, "NULL". |
| 21 static const uint32_t kStubIdentifier = 0x4c4c554eu; | 21 static const uint32_t kStubIdentifier = 0x4c4c554eu; |
| 22 | 22 |
| 23 // Out-of-band dynamic tags used to indicate the offset and size of the | 23 // Out-of-band dynamic tags used to indicate the offset and size of the |
| 24 // .android.rel.dyn section. | 24 // .android.rel.dyn section. |
| 25 static const ELF::Sword DT_ANDROID_REL_OFFSET = DT_LOPROC; | 25 static const ELF::Sword DT_ANDROID_REL_OFFSET = DT_LOOS; |
| 26 static const ELF::Sword DT_ANDROID_REL_SIZE = DT_LOPROC + 1; | 26 static const ELF::Sword DT_ANDROID_REL_SIZE = DT_LOOS + 1; |
| 27 | 27 |
| 28 // Alignment to preserve, in bytes. This must be at least as large as the | 28 // Alignment to preserve, in bytes. This must be at least as large as the |
| 29 // largest d_align and sh_addralign values found in the loaded file. | 29 // largest d_align and sh_addralign values found in the loaded file. |
| 30 static const size_t kPreserveAlignment = 256; | 30 static const size_t kPreserveAlignment = 256; |
| 31 | 31 |
| 32 namespace { | 32 namespace { |
| 33 | 33 |
| 34 // Get section data. Checks that the section has exactly one data entry, | 34 // Get section data. Checks that the section has exactly one data entry, |
| 35 // so that the section size and the data size are the same. True in | 35 // so that the section size and the data size are the same. True in |
| 36 // practice for all sections we resize when packing or unpacking. Done | 36 // practice for all sections we resize when packing or unpacking. Done |
| (...skipping 986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1023 | 1023 |
| 1024 // Clean up libelf, and truncate the output file to the number of bytes | 1024 // Clean up libelf, and truncate the output file to the number of bytes |
| 1025 // written by elf_update(). | 1025 // written by elf_update(). |
| 1026 elf_end(elf_); | 1026 elf_end(elf_); |
| 1027 elf_ = NULL; | 1027 elf_ = NULL; |
| 1028 const int truncate = ftruncate(fd_, file_bytes); | 1028 const int truncate = ftruncate(fd_, file_bytes); |
| 1029 CHECK(truncate == 0); | 1029 CHECK(truncate == 0); |
| 1030 } | 1030 } |
| 1031 | 1031 |
| 1032 } // namespace relocation_packer | 1032 } // namespace relocation_packer |
| OLD | NEW |