OLD | NEW |
1 // Copyright (c) 2010, Google Inc. | 1 // Copyright (c) 2010, Google Inc. |
2 // All rights reserved. | 2 // All rights reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
6 // met: | 6 // met: |
7 // | 7 // |
8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 | 179 |
180 MockCallFrameInfoHandler handler; | 180 MockCallFrameInfoHandler handler; |
181 MockCallFrameErrorReporter reporter; | 181 MockCallFrameErrorReporter reporter; |
182 }; | 182 }; |
183 | 183 |
184 class CFI: public CFIFixture, public Test { }; | 184 class CFI: public CFIFixture, public Test { }; |
185 | 185 |
186 TEST_F(CFI, EmptyRegion) { | 186 TEST_F(CFI, EmptyRegion) { |
187 EXPECT_CALL(handler, Entry(_, _, _, _, _, _)).Times(0); | 187 EXPECT_CALL(handler, Entry(_, _, _, _, _, _)).Times(0); |
188 EXPECT_CALL(handler, End()).Times(0); | 188 EXPECT_CALL(handler, End()).Times(0); |
189 static const char data[1] = { 42 }; | 189 static const uint8_t data[] = { 42 }; |
190 | 190 |
191 ByteReader byte_reader(ENDIANNESS_BIG); | 191 ByteReader byte_reader(ENDIANNESS_BIG); |
192 CallFrameInfo parser(data, 0, &byte_reader, &handler, &reporter); | 192 CallFrameInfo parser(data, 0, &byte_reader, &handler, &reporter); |
193 EXPECT_TRUE(parser.Start()); | 193 EXPECT_TRUE(parser.Start()); |
194 } | 194 } |
195 | 195 |
196 TEST_F(CFI, IncompleteLength32) { | 196 TEST_F(CFI, IncompleteLength32) { |
197 CFISection section(kBigEndian, 8); | 197 CFISection section(kBigEndian, 8); |
198 section | 198 section |
199 // Not even long enough for an initial length. | 199 // Not even long enough for an initial length. |
200 .D16(0xa0f) | 200 .D16(0xa0f) |
201 // Padding to keep valgrind happy. We subtract these off when we | 201 // Padding to keep valgrind happy. We subtract these off when we |
202 // construct the parser. | 202 // construct the parser. |
203 .D16(0); | 203 .D16(0); |
204 | 204 |
205 EXPECT_CALL(handler, Entry(_, _, _, _, _, _)).Times(0); | 205 EXPECT_CALL(handler, Entry(_, _, _, _, _, _)).Times(0); |
206 EXPECT_CALL(handler, End()).Times(0); | 206 EXPECT_CALL(handler, End()).Times(0); |
207 | 207 |
208 EXPECT_CALL(reporter, Incomplete(_, CallFrameInfo::kUnknown)) | 208 EXPECT_CALL(reporter, Incomplete(_, CallFrameInfo::kUnknown)) |
209 .WillOnce(Return()); | 209 .WillOnce(Return()); |
210 | 210 |
211 string contents; | 211 string contents; |
212 ASSERT_TRUE(section.GetContents(&contents)); | 212 ASSERT_TRUE(section.GetContents(&contents)); |
213 | 213 |
214 ByteReader byte_reader(ENDIANNESS_BIG); | 214 ByteReader byte_reader(ENDIANNESS_BIG); |
215 byte_reader.SetAddressSize(8); | 215 byte_reader.SetAddressSize(8); |
216 CallFrameInfo parser(contents.data(), contents.size() - 2, | 216 CallFrameInfo parser(reinterpret_cast<const uint8_t *>(contents.data()), |
| 217 contents.size() - 2, |
217 &byte_reader, &handler, &reporter); | 218 &byte_reader, &handler, &reporter); |
218 EXPECT_FALSE(parser.Start()); | 219 EXPECT_FALSE(parser.Start()); |
219 } | 220 } |
220 | 221 |
221 TEST_F(CFI, IncompleteLength64) { | 222 TEST_F(CFI, IncompleteLength64) { |
222 CFISection section(kLittleEndian, 4); | 223 CFISection section(kLittleEndian, 4); |
223 section | 224 section |
224 // An incomplete 64-bit DWARF initial length. | 225 // An incomplete 64-bit DWARF initial length. |
225 .D32(0xffffffff).D32(0x71fbaec2) | 226 .D32(0xffffffff).D32(0x71fbaec2) |
226 // Padding to keep valgrind happy. We subtract these off when we | 227 // Padding to keep valgrind happy. We subtract these off when we |
227 // construct the parser. | 228 // construct the parser. |
228 .D32(0); | 229 .D32(0); |
229 | 230 |
230 EXPECT_CALL(handler, Entry(_, _, _, _, _, _)).Times(0); | 231 EXPECT_CALL(handler, Entry(_, _, _, _, _, _)).Times(0); |
231 EXPECT_CALL(handler, End()).Times(0); | 232 EXPECT_CALL(handler, End()).Times(0); |
232 | 233 |
233 EXPECT_CALL(reporter, Incomplete(_, CallFrameInfo::kUnknown)) | 234 EXPECT_CALL(reporter, Incomplete(_, CallFrameInfo::kUnknown)) |
234 .WillOnce(Return()); | 235 .WillOnce(Return()); |
235 | 236 |
236 string contents; | 237 string contents; |
237 ASSERT_TRUE(section.GetContents(&contents)); | 238 ASSERT_TRUE(section.GetContents(&contents)); |
238 | 239 |
239 ByteReader byte_reader(ENDIANNESS_LITTLE); | 240 ByteReader byte_reader(ENDIANNESS_LITTLE); |
240 byte_reader.SetAddressSize(4); | 241 byte_reader.SetAddressSize(4); |
241 CallFrameInfo parser(contents.data(), contents.size() - 4, | 242 CallFrameInfo parser(reinterpret_cast<const uint8_t *>(contents.data()), |
| 243 contents.size() - 4, |
242 &byte_reader, &handler, &reporter); | 244 &byte_reader, &handler, &reporter); |
243 EXPECT_FALSE(parser.Start()); | 245 EXPECT_FALSE(parser.Start()); |
244 } | 246 } |
245 | 247 |
246 TEST_F(CFI, IncompleteId32) { | 248 TEST_F(CFI, IncompleteId32) { |
247 CFISection section(kBigEndian, 8); | 249 CFISection section(kBigEndian, 8); |
248 section | 250 section |
249 .D32(3) // Initial length, not long enough for id | 251 .D32(3) // Initial length, not long enough for id |
250 .D8(0xd7).D8(0xe5).D8(0xf1) // incomplete id | 252 .D8(0xd7).D8(0xe5).D8(0xf1) // incomplete id |
251 .CIEHeader(8727, 3983, 8889, 3, "") | 253 .CIEHeader(8727, 3983, 8889, 3, "") |
252 .FinishEntry(); | 254 .FinishEntry(); |
253 | 255 |
254 EXPECT_CALL(handler, Entry(_, _, _, _, _, _)).Times(0); | 256 EXPECT_CALL(handler, Entry(_, _, _, _, _, _)).Times(0); |
255 EXPECT_CALL(handler, End()).Times(0); | 257 EXPECT_CALL(handler, End()).Times(0); |
256 | 258 |
257 EXPECT_CALL(reporter, Incomplete(_, CallFrameInfo::kUnknown)) | 259 EXPECT_CALL(reporter, Incomplete(_, CallFrameInfo::kUnknown)) |
258 .WillOnce(Return()); | 260 .WillOnce(Return()); |
259 | 261 |
260 string contents; | 262 string contents; |
261 ASSERT_TRUE(section.GetContents(&contents)); | 263 ASSERT_TRUE(section.GetContents(&contents)); |
262 | 264 |
263 ByteReader byte_reader(ENDIANNESS_BIG); | 265 ByteReader byte_reader(ENDIANNESS_BIG); |
264 byte_reader.SetAddressSize(8); | 266 byte_reader.SetAddressSize(8); |
265 CallFrameInfo parser(contents.data(), contents.size(), | 267 CallFrameInfo parser(reinterpret_cast<const uint8_t *>(contents.data()), |
| 268 contents.size(), |
266 &byte_reader, &handler, &reporter); | 269 &byte_reader, &handler, &reporter); |
267 EXPECT_FALSE(parser.Start()); | 270 EXPECT_FALSE(parser.Start()); |
268 } | 271 } |
269 | 272 |
270 TEST_F(CFI, BadId32) { | 273 TEST_F(CFI, BadId32) { |
271 CFISection section(kBigEndian, 8); | 274 CFISection section(kBigEndian, 8); |
272 section | 275 section |
273 .D32(0x100) // Initial length | 276 .D32(0x100) // Initial length |
274 .D32(0xe802fade) // bogus ID | 277 .D32(0xe802fade) // bogus ID |
275 .Append(0x100 - 4, 0x42); // make the length true | 278 .Append(0x100 - 4, 0x42); // make the length true |
276 section | 279 section |
277 .CIEHeader(1672, 9872, 8529, 3, "") | 280 .CIEHeader(1672, 9872, 8529, 3, "") |
278 .FinishEntry(); | 281 .FinishEntry(); |
279 | 282 |
280 EXPECT_CALL(handler, Entry(_, _, _, _, _, _)).Times(0); | 283 EXPECT_CALL(handler, Entry(_, _, _, _, _, _)).Times(0); |
281 EXPECT_CALL(handler, End()).Times(0); | 284 EXPECT_CALL(handler, End()).Times(0); |
282 | 285 |
283 EXPECT_CALL(reporter, CIEPointerOutOfRange(_, 0xe802fade)) | 286 EXPECT_CALL(reporter, CIEPointerOutOfRange(_, 0xe802fade)) |
284 .WillOnce(Return()); | 287 .WillOnce(Return()); |
285 | 288 |
286 string contents; | 289 string contents; |
287 ASSERT_TRUE(section.GetContents(&contents)); | 290 ASSERT_TRUE(section.GetContents(&contents)); |
288 | 291 |
289 ByteReader byte_reader(ENDIANNESS_BIG); | 292 ByteReader byte_reader(ENDIANNESS_BIG); |
290 byte_reader.SetAddressSize(8); | 293 byte_reader.SetAddressSize(8); |
291 CallFrameInfo parser(contents.data(), contents.size(), | 294 CallFrameInfo parser(reinterpret_cast<const uint8_t *>(contents.data()), |
| 295 contents.size(), |
292 &byte_reader, &handler, &reporter); | 296 &byte_reader, &handler, &reporter); |
293 EXPECT_FALSE(parser.Start()); | 297 EXPECT_FALSE(parser.Start()); |
294 } | 298 } |
295 | 299 |
296 // A lone CIE shouldn't cause any handler calls. | 300 // A lone CIE shouldn't cause any handler calls. |
297 TEST_F(CFI, SingleCIE) { | 301 TEST_F(CFI, SingleCIE) { |
298 CFISection section(kLittleEndian, 4); | 302 CFISection section(kLittleEndian, 4); |
299 section.CIEHeader(0xffe799a8, 0x3398dcdd, 0x6e9683de, 3, ""); | 303 section.CIEHeader(0xffe799a8, 0x3398dcdd, 0x6e9683de, 3, ""); |
300 section.Append(10, dwarf2reader::DW_CFA_nop); | 304 section.Append(10, dwarf2reader::DW_CFA_nop); |
301 section.FinishEntry(); | 305 section.FinishEntry(); |
302 | 306 |
303 PERHAPS_WRITE_DEBUG_FRAME_FILE("SingleCIE", section); | 307 PERHAPS_WRITE_DEBUG_FRAME_FILE("SingleCIE", section); |
304 | 308 |
305 EXPECT_CALL(handler, Entry(_, _, _, _, _, _)).Times(0); | 309 EXPECT_CALL(handler, Entry(_, _, _, _, _, _)).Times(0); |
306 EXPECT_CALL(handler, End()).Times(0); | 310 EXPECT_CALL(handler, End()).Times(0); |
307 | 311 |
308 string contents; | 312 string contents; |
309 EXPECT_TRUE(section.GetContents(&contents)); | 313 EXPECT_TRUE(section.GetContents(&contents)); |
310 ByteReader byte_reader(ENDIANNESS_LITTLE); | 314 ByteReader byte_reader(ENDIANNESS_LITTLE); |
311 byte_reader.SetAddressSize(4); | 315 byte_reader.SetAddressSize(4); |
312 CallFrameInfo parser(contents.data(), contents.size(), | 316 CallFrameInfo parser(reinterpret_cast<const uint8_t *>(contents.data()), |
| 317 contents.size(), |
313 &byte_reader, &handler, &reporter); | 318 &byte_reader, &handler, &reporter); |
314 EXPECT_TRUE(parser.Start()); | 319 EXPECT_TRUE(parser.Start()); |
315 } | 320 } |
316 | 321 |
317 // One FDE, one CIE. | 322 // One FDE, one CIE. |
318 TEST_F(CFI, OneFDE) { | 323 TEST_F(CFI, OneFDE) { |
319 CFISection section(kBigEndian, 4); | 324 CFISection section(kBigEndian, 4); |
320 Label cie; | 325 Label cie; |
321 section | 326 section |
322 .Mark(&cie) | 327 .Mark(&cie) |
323 .CIEHeader(0x4be22f75, 0x2492236e, 0x6b6efb87, 3, "") | 328 .CIEHeader(0x4be22f75, 0x2492236e, 0x6b6efb87, 3, "") |
324 .FinishEntry() | 329 .FinishEntry() |
325 .FDEHeader(cie, 0x7714740d, 0x3d5a10cd) | 330 .FDEHeader(cie, 0x7714740d, 0x3d5a10cd) |
326 .FinishEntry(); | 331 .FinishEntry(); |
327 | 332 |
328 PERHAPS_WRITE_DEBUG_FRAME_FILE("OneFDE", section); | 333 PERHAPS_WRITE_DEBUG_FRAME_FILE("OneFDE", section); |
329 | 334 |
330 { | 335 { |
331 InSequence s; | 336 InSequence s; |
332 EXPECT_CALL(handler, | 337 EXPECT_CALL(handler, |
333 Entry(_, 0x7714740d, 0x3d5a10cd, 3, "", 0x6b6efb87)) | 338 Entry(_, 0x7714740d, 0x3d5a10cd, 3, "", 0x6b6efb87)) |
334 .WillOnce(Return(true)); | 339 .WillOnce(Return(true)); |
335 EXPECT_CALL(handler, End()).WillOnce(Return(true)); | 340 EXPECT_CALL(handler, End()).WillOnce(Return(true)); |
336 } | 341 } |
337 | 342 |
338 string contents; | 343 string contents; |
339 EXPECT_TRUE(section.GetContents(&contents)); | 344 EXPECT_TRUE(section.GetContents(&contents)); |
340 ByteReader byte_reader(ENDIANNESS_BIG); | 345 ByteReader byte_reader(ENDIANNESS_BIG); |
341 byte_reader.SetAddressSize(4); | 346 byte_reader.SetAddressSize(4); |
342 CallFrameInfo parser(contents.data(), contents.size(), | 347 CallFrameInfo parser(reinterpret_cast<const uint8_t *>(contents.data()), |
| 348 contents.size(), |
343 &byte_reader, &handler, &reporter); | 349 &byte_reader, &handler, &reporter); |
344 EXPECT_TRUE(parser.Start()); | 350 EXPECT_TRUE(parser.Start()); |
345 } | 351 } |
346 | 352 |
347 // Two FDEs share a CIE. | 353 // Two FDEs share a CIE. |
348 TEST_F(CFI, TwoFDEsOneCIE) { | 354 TEST_F(CFI, TwoFDEsOneCIE) { |
349 CFISection section(kBigEndian, 4); | 355 CFISection section(kBigEndian, 4); |
350 Label cie; | 356 Label cie; |
351 section | 357 section |
352 // First FDE. readelf complains about this one because it makes | 358 // First FDE. readelf complains about this one because it makes |
(...skipping 22 matching lines...) Expand all Loading... |
375 EXPECT_CALL(handler, | 381 EXPECT_CALL(handler, |
376 Entry(_, 0x6057d391, 0x700f608d, 3, "", 0xbd43cb59)) | 382 Entry(_, 0x6057d391, 0x700f608d, 3, "", 0xbd43cb59)) |
377 .WillOnce(Return(true)); | 383 .WillOnce(Return(true)); |
378 EXPECT_CALL(handler, End()).WillOnce(Return(true)); | 384 EXPECT_CALL(handler, End()).WillOnce(Return(true)); |
379 } | 385 } |
380 | 386 |
381 string contents; | 387 string contents; |
382 EXPECT_TRUE(section.GetContents(&contents)); | 388 EXPECT_TRUE(section.GetContents(&contents)); |
383 ByteReader byte_reader(ENDIANNESS_BIG); | 389 ByteReader byte_reader(ENDIANNESS_BIG); |
384 byte_reader.SetAddressSize(4); | 390 byte_reader.SetAddressSize(4); |
385 CallFrameInfo parser(contents.data(), contents.size(), | 391 CallFrameInfo parser(reinterpret_cast<const uint8_t *>(contents.data()), |
| 392 contents.size(), |
386 &byte_reader, &handler, &reporter); | 393 &byte_reader, &handler, &reporter); |
387 EXPECT_TRUE(parser.Start()); | 394 EXPECT_TRUE(parser.Start()); |
388 } | 395 } |
389 | 396 |
390 // Two FDEs, two CIEs. | 397 // Two FDEs, two CIEs. |
391 TEST_F(CFI, TwoFDEsTwoCIEs) { | 398 TEST_F(CFI, TwoFDEsTwoCIEs) { |
392 CFISection section(kLittleEndian, 8); | 399 CFISection section(kLittleEndian, 8); |
393 Label cie1, cie2; | 400 Label cie1, cie2; |
394 section | 401 section |
395 // First CIE. | 402 // First CIE. |
(...skipping 28 matching lines...) Expand all Loading... |
424 Entry(_, 0xf6054ca18b10bf5fULL, 0x45fdb970d8bca342ULL, 3, | 431 Entry(_, 0xf6054ca18b10bf5fULL, 0x45fdb970d8bca342ULL, 3, |
425 "", 0xbf45e65a)) | 432 "", 0xbf45e65a)) |
426 .WillOnce(Return(true)); | 433 .WillOnce(Return(true)); |
427 EXPECT_CALL(handler, End()).WillOnce(Return(true)); | 434 EXPECT_CALL(handler, End()).WillOnce(Return(true)); |
428 } | 435 } |
429 | 436 |
430 string contents; | 437 string contents; |
431 EXPECT_TRUE(section.GetContents(&contents)); | 438 EXPECT_TRUE(section.GetContents(&contents)); |
432 ByteReader byte_reader(ENDIANNESS_LITTLE); | 439 ByteReader byte_reader(ENDIANNESS_LITTLE); |
433 byte_reader.SetAddressSize(8); | 440 byte_reader.SetAddressSize(8); |
434 CallFrameInfo parser(contents.data(), contents.size(), | 441 CallFrameInfo parser(reinterpret_cast<const uint8_t *>(contents.data()), |
| 442 contents.size(), |
435 &byte_reader, &handler, &reporter); | 443 &byte_reader, &handler, &reporter); |
436 EXPECT_TRUE(parser.Start()); | 444 EXPECT_TRUE(parser.Start()); |
437 } | 445 } |
438 | 446 |
439 // An FDE whose CIE specifies a version we don't recognize. | 447 // An FDE whose CIE specifies a version we don't recognize. |
440 TEST_F(CFI, BadVersion) { | 448 TEST_F(CFI, BadVersion) { |
441 CFISection section(kBigEndian, 4); | 449 CFISection section(kBigEndian, 4); |
442 Label cie1, cie2; | 450 Label cie1, cie2; |
443 section | 451 section |
444 .Mark(&cie1) | 452 .Mark(&cie1) |
(...skipping 23 matching lines...) Expand all Loading... |
468 0x96cb3264)) | 476 0x96cb3264)) |
469 .WillOnce(Return(true)); | 477 .WillOnce(Return(true)); |
470 EXPECT_CALL(handler, End()) | 478 EXPECT_CALL(handler, End()) |
471 .WillOnce(Return(true)); | 479 .WillOnce(Return(true)); |
472 } | 480 } |
473 | 481 |
474 string contents; | 482 string contents; |
475 EXPECT_TRUE(section.GetContents(&contents)); | 483 EXPECT_TRUE(section.GetContents(&contents)); |
476 ByteReader byte_reader(ENDIANNESS_BIG); | 484 ByteReader byte_reader(ENDIANNESS_BIG); |
477 byte_reader.SetAddressSize(4); | 485 byte_reader.SetAddressSize(4); |
478 CallFrameInfo parser(contents.data(), contents.size(), | 486 CallFrameInfo parser(reinterpret_cast<const uint8_t *>(contents.data()), |
| 487 contents.size(), |
479 &byte_reader, &handler, &reporter); | 488 &byte_reader, &handler, &reporter); |
480 EXPECT_FALSE(parser.Start()); | 489 EXPECT_FALSE(parser.Start()); |
481 } | 490 } |
482 | 491 |
483 // An FDE whose CIE specifies an augmentation we don't recognize. | 492 // An FDE whose CIE specifies an augmentation we don't recognize. |
484 TEST_F(CFI, BadAugmentation) { | 493 TEST_F(CFI, BadAugmentation) { |
485 CFISection section(kBigEndian, 4); | 494 CFISection section(kBigEndian, 4); |
486 Label cie1, cie2; | 495 Label cie1, cie2; |
487 section | 496 section |
488 .Mark(&cie1) | 497 .Mark(&cie1) |
(...skipping 23 matching lines...) Expand all Loading... |
512 0xf2f519b2)) | 521 0xf2f519b2)) |
513 .WillOnce(Return(true)); | 522 .WillOnce(Return(true)); |
514 EXPECT_CALL(handler, End()) | 523 EXPECT_CALL(handler, End()) |
515 .WillOnce(Return(true)); | 524 .WillOnce(Return(true)); |
516 } | 525 } |
517 | 526 |
518 string contents; | 527 string contents; |
519 EXPECT_TRUE(section.GetContents(&contents)); | 528 EXPECT_TRUE(section.GetContents(&contents)); |
520 ByteReader byte_reader(ENDIANNESS_BIG); | 529 ByteReader byte_reader(ENDIANNESS_BIG); |
521 byte_reader.SetAddressSize(4); | 530 byte_reader.SetAddressSize(4); |
522 CallFrameInfo parser(contents.data(), contents.size(), | 531 CallFrameInfo parser(reinterpret_cast<const uint8_t *>(contents.data()), |
| 532 contents.size(), |
523 &byte_reader, &handler, &reporter); | 533 &byte_reader, &handler, &reporter); |
524 EXPECT_FALSE(parser.Start()); | 534 EXPECT_FALSE(parser.Start()); |
525 } | 535 } |
526 | 536 |
527 // The return address column field is a byte in CFI version 1 | 537 // The return address column field is a byte in CFI version 1 |
528 // (DWARF2), but a ULEB128 value in version 3 (DWARF3). | 538 // (DWARF2), but a ULEB128 value in version 3 (DWARF3). |
529 TEST_F(CFI, CIEVersion1ReturnColumn) { | 539 TEST_F(CFI, CIEVersion1ReturnColumn) { |
530 CFISection section(kBigEndian, 4); | 540 CFISection section(kBigEndian, 4); |
531 Label cie; | 541 Label cie; |
532 section | 542 section |
(...skipping 13 matching lines...) Expand all Loading... |
546 InSequence s; | 556 InSequence s; |
547 EXPECT_CALL(handler, Entry(_, 0xb8d347b5, 0x825e55dc, 1, "", 0x9f)) | 557 EXPECT_CALL(handler, Entry(_, 0xb8d347b5, 0x825e55dc, 1, "", 0x9f)) |
548 .WillOnce(Return(true)); | 558 .WillOnce(Return(true)); |
549 EXPECT_CALL(handler, End()).WillOnce(Return(true)); | 559 EXPECT_CALL(handler, End()).WillOnce(Return(true)); |
550 } | 560 } |
551 | 561 |
552 string contents; | 562 string contents; |
553 EXPECT_TRUE(section.GetContents(&contents)); | 563 EXPECT_TRUE(section.GetContents(&contents)); |
554 ByteReader byte_reader(ENDIANNESS_BIG); | 564 ByteReader byte_reader(ENDIANNESS_BIG); |
555 byte_reader.SetAddressSize(4); | 565 byte_reader.SetAddressSize(4); |
556 CallFrameInfo parser(contents.data(), contents.size(), | 566 CallFrameInfo parser(reinterpret_cast<const uint8_t *>(contents.data()), |
| 567 contents.size(), |
557 &byte_reader, &handler, &reporter); | 568 &byte_reader, &handler, &reporter); |
558 EXPECT_TRUE(parser.Start()); | 569 EXPECT_TRUE(parser.Start()); |
559 } | 570 } |
560 | 571 |
561 // The return address column field is a byte in CFI version 1 | 572 // The return address column field is a byte in CFI version 1 |
562 // (DWARF2), but a ULEB128 value in version 3 (DWARF3). | 573 // (DWARF2), but a ULEB128 value in version 3 (DWARF3). |
563 TEST_F(CFI, CIEVersion3ReturnColumn) { | 574 TEST_F(CFI, CIEVersion3ReturnColumn) { |
564 CFISection section(kBigEndian, 4); | 575 CFISection section(kBigEndian, 4); |
565 Label cie; | 576 Label cie; |
566 section | 577 section |
(...skipping 13 matching lines...) Expand all Loading... |
580 InSequence s; | 591 InSequence s; |
581 EXPECT_CALL(handler, Entry(_, 0x86763f2b, 0x2a66dc23, 3, "", 0x89)) | 592 EXPECT_CALL(handler, Entry(_, 0x86763f2b, 0x2a66dc23, 3, "", 0x89)) |
582 .WillOnce(Return(true)); | 593 .WillOnce(Return(true)); |
583 EXPECT_CALL(handler, End()).WillOnce(Return(true)); | 594 EXPECT_CALL(handler, End()).WillOnce(Return(true)); |
584 } | 595 } |
585 | 596 |
586 string contents; | 597 string contents; |
587 EXPECT_TRUE(section.GetContents(&contents)); | 598 EXPECT_TRUE(section.GetContents(&contents)); |
588 ByteReader byte_reader(ENDIANNESS_BIG); | 599 ByteReader byte_reader(ENDIANNESS_BIG); |
589 byte_reader.SetAddressSize(4); | 600 byte_reader.SetAddressSize(4); |
590 CallFrameInfo parser(contents.data(), contents.size(), | 601 CallFrameInfo parser(reinterpret_cast<const uint8_t *>(contents.data()), |
| 602 contents.size(), |
591 &byte_reader, &handler, &reporter); | 603 &byte_reader, &handler, &reporter); |
592 EXPECT_TRUE(parser.Start()); | 604 EXPECT_TRUE(parser.Start()); |
593 } | 605 } |
594 | 606 |
595 struct CFIInsnFixture: public CFIFixture { | 607 struct CFIInsnFixture: public CFIFixture { |
596 CFIInsnFixture() : CFIFixture() { | 608 CFIInsnFixture() : CFIFixture() { |
597 data_factor = 0xb6f; | 609 data_factor = 0xb6f; |
598 return_register = 0x9be1ed9f; | 610 return_register = 0x9be1ed9f; |
599 version = 3; | 611 version = 3; |
600 cfa_base_register = 0x383a3aa; | 612 cfa_base_register = 0x383a3aa; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
661 EXPECT_TRUE(section->GetContents(&contents)); | 673 EXPECT_TRUE(section->GetContents(&contents)); |
662 dwarf2reader::Endianness endianness; | 674 dwarf2reader::Endianness endianness; |
663 if (section->endianness() == kBigEndian) | 675 if (section->endianness() == kBigEndian) |
664 endianness = ENDIANNESS_BIG; | 676 endianness = ENDIANNESS_BIG; |
665 else { | 677 else { |
666 assert(section->endianness() == kLittleEndian); | 678 assert(section->endianness() == kLittleEndian); |
667 endianness = ENDIANNESS_LITTLE; | 679 endianness = ENDIANNESS_LITTLE; |
668 } | 680 } |
669 ByteReader byte_reader(endianness); | 681 ByteReader byte_reader(endianness); |
670 byte_reader.SetAddressSize(section->AddressSize()); | 682 byte_reader.SetAddressSize(section->AddressSize()); |
671 CallFrameInfo parser(contents.data(), contents.size(), | 683 CallFrameInfo parser(reinterpret_cast<const uint8_t *>(contents.data()), |
| 684 contents.size(), |
672 &byte_reader, &handler, &reporter); | 685 &byte_reader, &handler, &reporter); |
673 if (succeeds) | 686 if (succeeds) |
674 EXPECT_TRUE(parser.Start()); | 687 EXPECT_TRUE(parser.Start()); |
675 else | 688 else |
676 EXPECT_FALSE(parser.Start()); | 689 EXPECT_FALSE(parser.Start()); |
677 } | 690 } |
678 | 691 |
679 Label cie_label; | 692 Label cie_label; |
680 Sequence s; | 693 Sequence s; |
681 uint64 code_factor; | 694 uint64 code_factor; |
(...skipping 1300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1982 EXPECT_TRUE(section->GetContents(&contents)); | 1995 EXPECT_TRUE(section->GetContents(&contents)); |
1983 dwarf2reader::Endianness endianness; | 1996 dwarf2reader::Endianness endianness; |
1984 if (section->endianness() == kBigEndian) | 1997 if (section->endianness() == kBigEndian) |
1985 endianness = ENDIANNESS_BIG; | 1998 endianness = ENDIANNESS_BIG; |
1986 else { | 1999 else { |
1987 assert(section->endianness() == kLittleEndian); | 2000 assert(section->endianness() == kLittleEndian); |
1988 endianness = ENDIANNESS_LITTLE; | 2001 endianness = ENDIANNESS_LITTLE; |
1989 } | 2002 } |
1990 ByteReader byte_reader(endianness); | 2003 ByteReader byte_reader(endianness); |
1991 byte_reader.SetAddressSize(section->AddressSize()); | 2004 byte_reader.SetAddressSize(section->AddressSize()); |
1992 byte_reader.SetCFIDataBase(encoded_pointer_bases.cfi, contents.data()); | 2005 byte_reader.SetCFIDataBase(encoded_pointer_bases.cfi, |
| 2006 reinterpret_cast<const uint8_t *>(contents.data()
)); |
1993 byte_reader.SetTextBase(encoded_pointer_bases.text); | 2007 byte_reader.SetTextBase(encoded_pointer_bases.text); |
1994 byte_reader.SetDataBase(encoded_pointer_bases.data); | 2008 byte_reader.SetDataBase(encoded_pointer_bases.data); |
1995 CallFrameInfo parser(contents.data(), contents.size(), | 2009 CallFrameInfo parser(reinterpret_cast<const uint8_t *>(contents.data()), |
| 2010 contents.size(), |
1996 &byte_reader, &handler, &reporter, true); | 2011 &byte_reader, &handler, &reporter, true); |
1997 if (succeeds) | 2012 if (succeeds) |
1998 EXPECT_TRUE(parser.Start()); | 2013 EXPECT_TRUE(parser.Start()); |
1999 else | 2014 else |
2000 EXPECT_FALSE(parser.Start()); | 2015 EXPECT_FALSE(parser.Start()); |
2001 } | 2016 } |
2002 | 2017 |
2003 }; | 2018 }; |
2004 | 2019 |
2005 class EHFrame: public EHFrameFixture, public Test { }; | 2020 class EHFrame: public EHFrameFixture, public Test { }; |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2443 exit(1); | 2458 exit(1); |
2444 } | 2459 } |
2445 | 2460 |
2446 if (fclose(out) == EOF) { | 2461 if (fclose(out) == EOF) { |
2447 fprintf(stderr, "error closing ELF file '%s': %s\n", | 2462 fprintf(stderr, "error closing ELF file '%s': %s\n", |
2448 filename, strerror(errno)); | 2463 filename, strerror(errno)); |
2449 exit(1); | 2464 exit(1); |
2450 } | 2465 } |
2451 } | 2466 } |
2452 #endif | 2467 #endif |
OLD | NEW |