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

Side by Side Diff: tools/relocation_packer/src/elf_file_unittest.cc

Issue 410933004: Extend relocation packing to cover arm64. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase to master Created 6 years, 4 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 | « tools/relocation_packer/src/elf_file.cc ('k') | tools/relocation_packer/src/elf_traits.h » ('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 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 <limits.h> 7 #include <limits.h>
8 #include <stdio.h> 8 #include <stdio.h>
9 #include <unistd.h> 9 #include <unistd.h>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 #include "debug.h" 12 #include "debug.h"
13 #include "elf_traits.h"
13 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
14 15
15 // Macro stringification. 16 // Macro stringification.
16 // https://gcc.gnu.org/onlinedocs/cpp/Stringification.html 17 // https://gcc.gnu.org/onlinedocs/cpp/Stringification.html
17 #define XSTR(S) STR(S) 18 #define XSTR(S) STR(S)
18 #define STR(S) #S 19 #define STR(S) #S
19 20
20 namespace { 21 namespace {
21 22
22 void GetDataFilePath(const char* name, std::string* path) { 23 void GetDataFilePath(const char* name, std::string* path) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 } while (bytes > 0); 64 } while (bytes > 0);
64 65
65 ASSERT_EQ(0, fclose(testfile)); 66 ASSERT_EQ(0, fclose(testfile));
66 ASSERT_EQ(0, fseek(temporary, 0, SEEK_SET)); 67 ASSERT_EQ(0, fseek(temporary, 0, SEEK_SET));
67 ASSERT_EQ(0, lseek(fileno(temporary), 0, SEEK_SET)); 68 ASSERT_EQ(0, lseek(fileno(temporary), 0, SEEK_SET));
68 69
69 *stream = temporary; 70 *stream = temporary;
70 } 71 }
71 72
72 void OpenRelocsTestFiles(FILE** relocs_so, FILE** packed_relocs_so) { 73 void OpenRelocsTestFiles(FILE** relocs_so, FILE** packed_relocs_so) {
73 OpenRelocsTestFile("elf_file_unittest_relocs.so", relocs_so); 74 const char* arch = NULL;
74 OpenRelocsTestFile("elf_file_unittest_relocs_packed.so", packed_relocs_so); 75 if (ELF::kMachine == EM_ARM) {
76 arch = "arm32";
77 } else if (ELF::kMachine == EM_AARCH64) {
78 arch = "arm64";
79 }
80 ASSERT_FALSE(arch == NULL);
81
82 const std::string base = std::string("elf_file_unittest_relocs_") + arch;
83 const std::string relocs = base + ".so";
84 const std::string packed_relocs = base + "_packed.so";
85
86 OpenRelocsTestFile(relocs.c_str(), relocs_so);
87 OpenRelocsTestFile(packed_relocs.c_str(), packed_relocs_so);
75 } 88 }
76 89
77 void CloseRelocsTestFile(FILE* temporary) { 90 void CloseRelocsTestFile(FILE* temporary) {
78 fclose(temporary); 91 fclose(temporary);
79 } 92 }
80 93
81 void CloseRelocsTestFiles(FILE* relocs_so, FILE* packed_relocs_so) { 94 void CloseRelocsTestFiles(FILE* relocs_so, FILE* packed_relocs_so) {
82 CloseRelocsTestFile(relocs_so); 95 CloseRelocsTestFile(relocs_so);
83 CloseRelocsTestFile(packed_relocs_so); 96 CloseRelocsTestFile(packed_relocs_so);
84 } 97 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 EXPECT_FALSE(elf_file.PackRelocations()); 155 EXPECT_FALSE(elf_file.PackRelocations());
143 156
144 // Unpack golden relocations, and check files are now identical. 157 // Unpack golden relocations, and check files are now identical.
145 EXPECT_TRUE(elf_file.UnpackRelocations()); 158 EXPECT_TRUE(elf_file.UnpackRelocations());
146 CheckFileContentsEqual(packed_relocs_so, relocs_so); 159 CheckFileContentsEqual(packed_relocs_so, relocs_so);
147 160
148 CloseRelocsTestFiles(relocs_so, packed_relocs_so); 161 CloseRelocsTestFiles(relocs_so, packed_relocs_so);
149 } 162 }
150 163
151 } // namespace relocation_packer 164 } // namespace relocation_packer
OLDNEW
« no previous file with comments | « tools/relocation_packer/src/elf_file.cc ('k') | tools/relocation_packer/src/elf_traits.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698