Bump version to 19.1.0-rc3
[llvm-project.git] / llvm / unittests / Object / ELFTest.cpp
blobfaf855c09cfe86e03767f987438860f12d84fafe
1 //===- ELFTest.cpp - Tests for ELF.cpp ------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "llvm/Object/ELF.h"
10 #include "llvm/Testing/Support/Error.h"
11 #include "gtest/gtest.h"
13 using namespace llvm;
14 using namespace llvm::object;
15 using namespace llvm::ELF;
17 TEST(ELFTest, getELFRelocationTypeNameForVE) {
18 EXPECT_EQ("R_VE_NONE", getELFRelocationTypeName(EM_VE, R_VE_NONE));
19 EXPECT_EQ("R_VE_REFLONG", getELFRelocationTypeName(EM_VE, R_VE_REFLONG));
20 EXPECT_EQ("R_VE_REFQUAD", getELFRelocationTypeName(EM_VE, R_VE_REFQUAD));
21 EXPECT_EQ("R_VE_SREL32", getELFRelocationTypeName(EM_VE, R_VE_SREL32));
22 EXPECT_EQ("R_VE_HI32", getELFRelocationTypeName(EM_VE, R_VE_HI32));
23 EXPECT_EQ("R_VE_LO32", getELFRelocationTypeName(EM_VE, R_VE_LO32));
24 EXPECT_EQ("R_VE_PC_HI32", getELFRelocationTypeName(EM_VE, R_VE_PC_HI32));
25 EXPECT_EQ("R_VE_PC_LO32", getELFRelocationTypeName(EM_VE, R_VE_PC_LO32));
26 EXPECT_EQ("R_VE_GOT32", getELFRelocationTypeName(EM_VE, R_VE_GOT32));
27 EXPECT_EQ("R_VE_GOT_HI32", getELFRelocationTypeName(EM_VE, R_VE_GOT_HI32));
28 EXPECT_EQ("R_VE_GOT_LO32", getELFRelocationTypeName(EM_VE, R_VE_GOT_LO32));
29 EXPECT_EQ("R_VE_GOTOFF32", getELFRelocationTypeName(EM_VE, R_VE_GOTOFF32));
30 EXPECT_EQ("R_VE_GOTOFF_HI32",
31 getELFRelocationTypeName(EM_VE, R_VE_GOTOFF_HI32));
32 EXPECT_EQ("R_VE_GOTOFF_LO32",
33 getELFRelocationTypeName(EM_VE, R_VE_GOTOFF_LO32));
34 EXPECT_EQ("R_VE_PLT32", getELFRelocationTypeName(EM_VE, R_VE_PLT32));
35 EXPECT_EQ("R_VE_PLT_HI32", getELFRelocationTypeName(EM_VE, R_VE_PLT_HI32));
36 EXPECT_EQ("R_VE_PLT_LO32", getELFRelocationTypeName(EM_VE, R_VE_PLT_LO32));
37 EXPECT_EQ("R_VE_RELATIVE", getELFRelocationTypeName(EM_VE, R_VE_RELATIVE));
38 EXPECT_EQ("R_VE_GLOB_DAT", getELFRelocationTypeName(EM_VE, R_VE_GLOB_DAT));
39 EXPECT_EQ("R_VE_JUMP_SLOT", getELFRelocationTypeName(EM_VE, R_VE_JUMP_SLOT));
40 EXPECT_EQ("R_VE_COPY", getELFRelocationTypeName(EM_VE, R_VE_COPY));
41 EXPECT_EQ("R_VE_DTPMOD64", getELFRelocationTypeName(EM_VE, R_VE_DTPMOD64));
42 EXPECT_EQ("R_VE_DTPOFF64", getELFRelocationTypeName(EM_VE, R_VE_DTPOFF64));
43 EXPECT_EQ("R_VE_TLS_GD_HI32",
44 getELFRelocationTypeName(EM_VE, R_VE_TLS_GD_HI32));
45 EXPECT_EQ("R_VE_TLS_GD_LO32",
46 getELFRelocationTypeName(EM_VE, R_VE_TLS_GD_LO32));
47 EXPECT_EQ("R_VE_TPOFF_HI32",
48 getELFRelocationTypeName(EM_VE, R_VE_TPOFF_HI32));
49 EXPECT_EQ("R_VE_TPOFF_LO32",
50 getELFRelocationTypeName(EM_VE, R_VE_TPOFF_LO32));
51 EXPECT_EQ("R_VE_CALL_HI32", getELFRelocationTypeName(EM_VE, R_VE_CALL_HI32));
52 EXPECT_EQ("R_VE_CALL_LO32", getELFRelocationTypeName(EM_VE, R_VE_CALL_LO32));
55 TEST(ELFTest, getELFRelocationTypeNameForLoongArch) {
56 EXPECT_EQ("R_LARCH_NONE",
57 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_NONE));
58 EXPECT_EQ("R_LARCH_32", getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_32));
59 EXPECT_EQ("R_LARCH_64", getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_64));
60 EXPECT_EQ("R_LARCH_RELATIVE",
61 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_RELATIVE));
62 EXPECT_EQ("R_LARCH_COPY",
63 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_COPY));
64 EXPECT_EQ("R_LARCH_JUMP_SLOT",
65 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_JUMP_SLOT));
66 EXPECT_EQ("R_LARCH_TLS_DTPMOD32",
67 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_TLS_DTPMOD32));
68 EXPECT_EQ("R_LARCH_TLS_DTPMOD64",
69 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_TLS_DTPMOD64));
70 EXPECT_EQ("R_LARCH_TLS_DTPREL32",
71 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_TLS_DTPREL32));
72 EXPECT_EQ("R_LARCH_TLS_DTPREL64",
73 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_TLS_DTPREL64));
74 EXPECT_EQ("R_LARCH_TLS_TPREL32",
75 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_TLS_TPREL32));
76 EXPECT_EQ("R_LARCH_TLS_TPREL64",
77 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_TLS_TPREL64));
78 EXPECT_EQ("R_LARCH_IRELATIVE",
79 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_IRELATIVE));
81 EXPECT_EQ("R_LARCH_MARK_LA",
82 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_MARK_LA));
83 EXPECT_EQ("R_LARCH_MARK_PCREL",
84 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_MARK_PCREL));
85 EXPECT_EQ("R_LARCH_SOP_PUSH_PCREL",
86 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SOP_PUSH_PCREL));
87 EXPECT_EQ("R_LARCH_SOP_PUSH_ABSOLUTE",
88 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SOP_PUSH_ABSOLUTE));
89 EXPECT_EQ("R_LARCH_SOP_PUSH_DUP",
90 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SOP_PUSH_DUP));
91 EXPECT_EQ("R_LARCH_SOP_PUSH_GPREL",
92 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SOP_PUSH_GPREL));
93 EXPECT_EQ("R_LARCH_SOP_PUSH_TLS_TPREL",
94 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SOP_PUSH_TLS_TPREL));
95 EXPECT_EQ("R_LARCH_SOP_PUSH_TLS_GOT",
96 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SOP_PUSH_TLS_GOT));
97 EXPECT_EQ("R_LARCH_SOP_PUSH_TLS_GD",
98 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SOP_PUSH_TLS_GD));
99 EXPECT_EQ("R_LARCH_SOP_PUSH_PLT_PCREL",
100 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SOP_PUSH_PLT_PCREL));
101 EXPECT_EQ("R_LARCH_SOP_ASSERT",
102 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SOP_ASSERT));
103 EXPECT_EQ("R_LARCH_SOP_NOT",
104 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SOP_NOT));
105 EXPECT_EQ("R_LARCH_SOP_SUB",
106 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SOP_SUB));
107 EXPECT_EQ("R_LARCH_SOP_SL",
108 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SOP_SL));
109 EXPECT_EQ("R_LARCH_SOP_SR",
110 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SOP_SR));
111 EXPECT_EQ("R_LARCH_SOP_ADD",
112 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SOP_ADD));
113 EXPECT_EQ("R_LARCH_SOP_AND",
114 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SOP_AND));
115 EXPECT_EQ("R_LARCH_SOP_IF_ELSE",
116 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SOP_IF_ELSE));
117 EXPECT_EQ("R_LARCH_SOP_POP_32_S_10_5",
118 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SOP_POP_32_S_10_5));
119 EXPECT_EQ("R_LARCH_SOP_POP_32_U_10_12",
120 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SOP_POP_32_U_10_12));
121 EXPECT_EQ("R_LARCH_SOP_POP_32_S_10_12",
122 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SOP_POP_32_S_10_12));
123 EXPECT_EQ("R_LARCH_SOP_POP_32_S_10_16",
124 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SOP_POP_32_S_10_16));
125 EXPECT_EQ(
126 "R_LARCH_SOP_POP_32_S_10_16_S2",
127 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SOP_POP_32_S_10_16_S2));
128 EXPECT_EQ("R_LARCH_SOP_POP_32_S_5_20",
129 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SOP_POP_32_S_5_20));
130 EXPECT_EQ("R_LARCH_SOP_POP_32_S_0_5_10_16_S2",
131 getELFRelocationTypeName(EM_LOONGARCH,
132 R_LARCH_SOP_POP_32_S_0_5_10_16_S2));
133 EXPECT_EQ("R_LARCH_SOP_POP_32_S_0_10_10_16_S2",
134 getELFRelocationTypeName(EM_LOONGARCH,
135 R_LARCH_SOP_POP_32_S_0_10_10_16_S2));
136 EXPECT_EQ("R_LARCH_SOP_POP_32_U",
137 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SOP_POP_32_U));
138 EXPECT_EQ("R_LARCH_ADD8",
139 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_ADD8));
140 EXPECT_EQ("R_LARCH_ADD16",
141 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_ADD16));
142 EXPECT_EQ("R_LARCH_ADD24",
143 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_ADD24));
144 EXPECT_EQ("R_LARCH_ADD32",
145 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_ADD32));
146 EXPECT_EQ("R_LARCH_ADD64",
147 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_ADD64));
148 EXPECT_EQ("R_LARCH_SUB8",
149 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SUB8));
150 EXPECT_EQ("R_LARCH_SUB16",
151 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SUB16));
152 EXPECT_EQ("R_LARCH_SUB24",
153 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SUB24));
154 EXPECT_EQ("R_LARCH_SUB32",
155 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SUB32));
156 EXPECT_EQ("R_LARCH_SUB64",
157 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SUB64));
158 EXPECT_EQ("R_LARCH_GNU_VTINHERIT",
159 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_GNU_VTINHERIT));
160 EXPECT_EQ("R_LARCH_GNU_VTENTRY",
161 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_GNU_VTENTRY));
162 EXPECT_EQ("R_LARCH_B16",
163 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_B16));
164 EXPECT_EQ("R_LARCH_B21",
165 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_B21));
166 EXPECT_EQ("R_LARCH_B26",
167 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_B26));
168 EXPECT_EQ("R_LARCH_ABS_HI20",
169 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_ABS_HI20));
170 EXPECT_EQ("R_LARCH_ABS_LO12",
171 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_ABS_LO12));
172 EXPECT_EQ("R_LARCH_ABS64_LO20",
173 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_ABS64_LO20));
174 EXPECT_EQ("R_LARCH_ABS64_HI12",
175 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_ABS64_HI12));
176 EXPECT_EQ("R_LARCH_PCALA_HI20",
177 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_PCALA_HI20));
178 EXPECT_EQ("R_LARCH_PCALA_LO12",
179 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_PCALA_LO12));
180 EXPECT_EQ("R_LARCH_PCALA64_LO20",
181 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_PCALA64_LO20));
182 EXPECT_EQ("R_LARCH_PCALA64_HI12",
183 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_PCALA64_HI12));
184 EXPECT_EQ("R_LARCH_GOT_PC_HI20",
185 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_GOT_PC_HI20));
186 EXPECT_EQ("R_LARCH_GOT_PC_LO12",
187 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_GOT_PC_LO12));
188 EXPECT_EQ("R_LARCH_GOT64_PC_LO20",
189 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_GOT64_PC_LO20));
190 EXPECT_EQ("R_LARCH_GOT64_PC_HI12",
191 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_GOT64_PC_HI12));
192 EXPECT_EQ("R_LARCH_GOT_HI20",
193 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_GOT_HI20));
194 EXPECT_EQ("R_LARCH_GOT_LO12",
195 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_GOT_LO12));
196 EXPECT_EQ("R_LARCH_GOT64_LO20",
197 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_GOT64_LO20));
198 EXPECT_EQ("R_LARCH_GOT64_HI12",
199 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_GOT64_HI12));
200 EXPECT_EQ("R_LARCH_TLS_LE_HI20",
201 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_TLS_LE_HI20));
202 EXPECT_EQ("R_LARCH_TLS_LE_LO12",
203 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_TLS_LE_LO12));
204 EXPECT_EQ("R_LARCH_TLS_LE64_LO20",
205 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_TLS_LE64_LO20));
206 EXPECT_EQ("R_LARCH_TLS_LE64_HI12",
207 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_TLS_LE64_HI12));
208 EXPECT_EQ("R_LARCH_TLS_IE_PC_HI20",
209 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_TLS_IE_PC_HI20));
210 EXPECT_EQ("R_LARCH_TLS_IE_PC_LO12",
211 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_TLS_IE_PC_LO12));
212 EXPECT_EQ("R_LARCH_TLS_IE64_PC_LO20",
213 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_TLS_IE64_PC_LO20));
214 EXPECT_EQ("R_LARCH_TLS_IE64_PC_HI12",
215 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_TLS_IE64_PC_HI12));
216 EXPECT_EQ("R_LARCH_TLS_IE_HI20",
217 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_TLS_IE_HI20));
218 EXPECT_EQ("R_LARCH_TLS_IE_LO12",
219 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_TLS_IE_LO12));
220 EXPECT_EQ("R_LARCH_TLS_IE64_LO20",
221 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_TLS_IE64_LO20));
222 EXPECT_EQ("R_LARCH_TLS_IE64_HI12",
223 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_TLS_IE64_HI12));
224 EXPECT_EQ("R_LARCH_TLS_LD_PC_HI20",
225 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_TLS_LD_PC_HI20));
226 EXPECT_EQ("R_LARCH_TLS_LD_HI20",
227 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_TLS_LD_HI20));
228 EXPECT_EQ("R_LARCH_TLS_GD_PC_HI20",
229 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_TLS_GD_PC_HI20));
230 EXPECT_EQ("R_LARCH_TLS_GD_HI20",
231 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_TLS_GD_HI20));
232 EXPECT_EQ("R_LARCH_32_PCREL",
233 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_32_PCREL));
234 EXPECT_EQ("R_LARCH_RELAX",
235 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_RELAX));
236 EXPECT_EQ("R_LARCH_ALIGN",
237 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_ALIGN));
238 EXPECT_EQ("R_LARCH_PCREL20_S2",
239 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_PCREL20_S2));
240 EXPECT_EQ("R_LARCH_ADD6",
241 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_ADD6));
242 EXPECT_EQ("R_LARCH_SUB6",
243 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SUB6));
244 EXPECT_EQ("R_LARCH_ADD_ULEB128",
245 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_ADD_ULEB128));
246 EXPECT_EQ("R_LARCH_SUB_ULEB128",
247 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_SUB_ULEB128));
248 EXPECT_EQ("R_LARCH_64_PCREL",
249 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_64_PCREL));
250 EXPECT_EQ("R_LARCH_CALL36",
251 getELFRelocationTypeName(EM_LOONGARCH, R_LARCH_CALL36));
254 TEST(ELFTest, getELFRelativeRelocationType) {
255 EXPECT_EQ(ELF::R_VE_RELATIVE, getELFRelativeRelocationType(EM_VE));
256 EXPECT_EQ(ELF::R_LARCH_RELATIVE, getELFRelativeRelocationType(EM_LOONGARCH));
259 // This is a test for the DataRegion helper struct, defined in ELF.h header.
260 TEST(ELFTest, DataRegionTest) {
261 std::vector<uint8_t> Data = {0, 1, 2};
263 // Used to check that the operator[] works properly.
264 auto CheckOperator = [&](DataRegion<uint8_t> &R) {
265 for (size_t I = 0, E = Data.size(); I != E; ++I) {
266 Expected<uint8_t> ValOrErr = R[I];
267 ASSERT_THAT_EXPECTED(ValOrErr, Succeeded());
268 EXPECT_EQ(*ValOrErr, I);
272 // Check we can use the constructor that takes an ArrayRef<T>.
273 DataRegion<uint8_t> Region(Data);
275 CheckOperator(Region);
276 const char *ErrMsg1 =
277 "the index is greater than or equal to the number of entries (3)";
278 EXPECT_THAT_ERROR(Region[3].takeError(), FailedWithMessage(ErrMsg1));
279 EXPECT_THAT_ERROR(Region[4].takeError(), FailedWithMessage(ErrMsg1));
281 // Check we can use the constructor that takes the data begin and the
282 // data end pointers.
283 Region = {Data.data(), Data.data() + Data.size()};
285 CheckOperator(Region);
286 const char *ErrMsg2 = "can't read past the end of the file";
287 EXPECT_THAT_ERROR(Region[3].takeError(), FailedWithMessage(ErrMsg2));
288 EXPECT_THAT_ERROR(Region[4].takeError(), FailedWithMessage(ErrMsg2));
291 // Test the sysV and the gnu hash functions, particularly with UTF-8 unicode.
292 // Use names long enough for the hash's recycling of the high bits to kick in.
293 // Explicitly encode the UTF-8 to avoid encoding transliterations.
294 TEST(ELFTest, Hash) {
295 EXPECT_EQ(hashSysV("FooBarBazToto"), 0x5ec3e8fU);
296 EXPECT_EQ(hashGnu("FooBarBazToto"), 0x5478be61U);
298 // boom💥pants
299 EXPECT_EQ(hashSysV("boom\xf0\x9f\x92\xa5pants"), 0x5a0cf53U);
300 EXPECT_EQ(hashGnu("boom\xf0\x9f\x92\xa5pants"), 0xf5dda2deU);
302 // woot!🧙 💑 🌈
303 EXPECT_EQ(hashSysV("woot!\xf0\x9f\xa7\x99 \xf0\x9f\x92\x91 "
304 "\xf0\x9f\x8c\x88"), 0x3522e38U);
305 EXPECT_EQ(hashGnu("woot!\xf0\x9f\xa7\x99 \xf0\x9f\x92\x91 "
306 "\xf0\x9f\x8c\x88"), 0xf7603f3U);
308 // This string hashes to 0x100000000 in the originally formulated function,
309 // when long is 64 bits -- but that was never the intent. The code was
310 // presuming 32-bit long. Thus make sure that extra bit doesn't appear.
311 EXPECT_EQ(hashSysV("ZZZZZW9p"), 0U);