aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/dtc
diff options
context:
space:
mode:
authorGrant Likely <grant.likely@linaro.org>2013-06-13 07:57:44 -0400
committerGrant Likely <grant.likely@linaro.org>2013-06-13 17:12:15 -0400
commit706b78f37fbed8d81b6061359f28a315fb9b1d73 (patch)
tree1a68c4b3a1e6ebb3f5bb2a3da87a07c80cba6354 /scripts/dtc
parent2a6a08ca5e3561e17346f8f87ce8dc88c0a8e42d (diff)
dtc: ensure #line directives don't consume data from the next line
Previously, the #line parsing regex ended with ({WS}+[0-9]+)?. The {WS} could match line-break characters. If the #line directive did not contain the optional flags field at the end, this could cause any integer data on the next line to be consumed as part of the #line directive parsing. This could cause syntax errors (i.e. #line parsing consuming the leading 0 from a hex literal 0x1234, leaving x1234 to be parsed as cell data, which is a syntax error), or invalid compilation results (i.e. simply consuming literal 1234 as part of the #line processing, thus removing it from the cell data). Fix this by replacing {WS} with [ \t] so that it can't match line-breaks. Convert all instances of {WS}, even though the other instances should be irrelevant for any well-formed #line directive. This is done for consistency and ultimate safety. [Cherry picked from DTC commit a1ee6f068e1c8dbc62873645037a353d7852d5cc] Reported-by: Ian Campbell <Ian.Campbell@citrix.com> Signed-off-by: Stephen Warren <swarren@nvidia.com> Acked-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'scripts/dtc')
-rw-r--r--scripts/dtc/dtc-lexer.l2
-rw-r--r--scripts/dtc/dtc-lexer.lex.c_shipped232
2 files changed, 117 insertions, 117 deletions
diff --git a/scripts/dtc/dtc-lexer.l b/scripts/dtc/dtc-lexer.l
index 254d5af88956..3b41bfca636c 100644
--- a/scripts/dtc/dtc-lexer.l
+++ b/scripts/dtc/dtc-lexer.l
@@ -71,7 +71,7 @@ static int pop_input_file(void);
71 push_input_file(name); 71 push_input_file(name);
72 } 72 }
73 73
74<*>^"#"(line)?{WS}+[0-9]+{WS}+{STRING}({WS}+[0-9]+)? { 74<*>^"#"(line)?[ \t]+[0-9]+[ \t]+{STRING}([ \t]+[0-9]+)? {
75 char *line, *tmp, *fn; 75 char *line, *tmp, *fn;
76 /* skip text before line # */ 76 /* skip text before line # */
77 line = yytext; 77 line = yytext;
diff --git a/scripts/dtc/dtc-lexer.lex.c_shipped b/scripts/dtc/dtc-lexer.lex.c_shipped
index a6c5fcdfc032..2d30f41778b7 100644
--- a/scripts/dtc/dtc-lexer.lex.c_shipped
+++ b/scripts/dtc/dtc-lexer.lex.c_shipped
@@ -405,19 +405,19 @@ static yyconst flex_int16_t yy_accept[161] =
405static yyconst flex_int32_t yy_ec[256] = 405static yyconst flex_int32_t yy_ec[256] =
406 { 0, 406 { 0,
407 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 407 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
408 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 408 4, 4, 4, 1, 1, 1, 1, 1, 1, 1,
409 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 409 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
410 1, 2, 4, 5, 6, 1, 1, 7, 8, 1, 410 1, 2, 5, 6, 7, 1, 1, 8, 9, 1,
411 1, 9, 10, 10, 11, 10, 12, 13, 14, 15, 411 1, 10, 11, 11, 12, 11, 13, 14, 15, 16,
412 15, 15, 15, 15, 15, 15, 15, 16, 1, 17, 412 16, 16, 16, 16, 16, 16, 16, 17, 1, 18,
413 18, 19, 10, 10, 20, 20, 20, 20, 20, 20, 413 19, 20, 11, 11, 21, 21, 21, 21, 21, 21,
414 21, 21, 21, 21, 21, 22, 21, 21, 21, 21, 414 22, 22, 22, 22, 22, 23, 22, 22, 22, 22,
415 21, 21, 21, 21, 23, 21, 21, 24, 21, 21, 415 22, 22, 22, 22, 24, 22, 22, 25, 22, 22,
416 1, 25, 26, 1, 21, 1, 20, 27, 28, 29, 416 1, 26, 27, 1, 22, 1, 21, 28, 29, 30,
417 417
418 30, 20, 21, 21, 31, 21, 21, 32, 33, 34, 418 31, 21, 22, 22, 32, 22, 22, 33, 34, 35,
419 35, 36, 21, 37, 38, 39, 40, 41, 21, 24, 419 36, 37, 22, 38, 39, 40, 41, 42, 22, 25,
420 42, 21, 43, 44, 45, 1, 1, 1, 1, 1, 420 43, 22, 44, 45, 46, 1, 1, 1, 1, 1,
421 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 421 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
422 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 422 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
423 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 423 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@@ -434,36 +434,36 @@ static yyconst flex_int32_t yy_ec[256] =
434 1, 1, 1, 1, 1 434 1, 1, 1, 1, 1
435 } ; 435 } ;
436 436
437static yyconst flex_int32_t yy_meta[46] = 437static yyconst flex_int32_t yy_meta[47] =
438 { 0, 438 { 0,
439 1, 1, 1, 1, 1, 2, 3, 1, 2, 2, 439 1, 1, 1, 1, 1, 1, 2, 3, 1, 2,
440 2, 4, 5, 5, 5, 6, 1, 1, 1, 7, 440 2, 2, 4, 5, 5, 5, 6, 1, 1, 1,
441 8, 8, 8, 8, 1, 1, 7, 7, 7, 7, 441 7, 8, 8, 8, 8, 1, 1, 7, 7, 7,
442 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 442 7, 8, 8, 8, 8, 8, 8, 8, 8, 8,
443 8, 8, 3, 1, 1 443 8, 8, 8, 3, 1, 1
444 } ; 444 } ;
445 445
446static yyconst flex_int16_t yy_base[175] = 446static yyconst flex_int16_t yy_base[175] =
447 { 0, 447 { 0,
448 0, 388, 381, 40, 41, 386, 71, 385, 34, 44, 448 0, 385, 378, 40, 41, 383, 72, 382, 34, 44,
449 390, 395, 60, 62, 371, 112, 111, 111, 111, 104, 449 388, 393, 61, 117, 368, 116, 115, 115, 115, 48,
450 370, 106, 371, 342, 124, 119, 0, 144, 395, 0, 450 367, 107, 368, 339, 127, 120, 0, 147, 393, 0,
451 123, 0, 159, 153, 165, 167, 395, 130, 395, 382, 451 127, 0, 133, 156, 168, 153, 393, 125, 393, 380,
452 395, 0, 372, 122, 395, 157, 374, 379, 350, 21, 452 393, 0, 369, 127, 393, 160, 371, 377, 347, 21,
453 346, 349, 395, 395, 395, 395, 395, 362, 395, 395, 453 343, 346, 393, 393, 393, 393, 393, 359, 393, 393,
454 181, 346, 342, 395, 359, 0, 191, 343, 190, 351, 454 183, 343, 339, 393, 356, 0, 183, 340, 187, 348,
455 350, 0, 0, 0, 173, 362, 177, 367, 357, 329, 455 347, 0, 0, 0, 178, 359, 195, 365, 354, 326,
456 335, 328, 337, 331, 206, 329, 334, 327, 395, 338, 456 332, 325, 334, 328, 204, 326, 331, 324, 393, 335,
457 170, 314, 346, 345, 318, 325, 343, 158, 316, 212, 457 150, 311, 343, 342, 315, 322, 340, 179, 313, 207,
458 458
459 322, 319, 320, 395, 340, 336, 308, 305, 314, 304, 459 319, 316, 317, 393, 337, 333, 305, 302, 311, 301,
460 295, 138, 208, 220, 395, 292, 305, 265, 264, 254, 460 310, 190, 338, 337, 393, 307, 322, 301, 305, 277,
461 201, 222, 285, 275, 273, 270, 236, 235, 225, 115, 461 208, 311, 307, 278, 271, 270, 248, 246, 213, 130,
462 395, 395, 252, 216, 216, 217, 214, 230, 209, 220, 462 393, 393, 263, 235, 207, 221, 218, 229, 213, 213,
463 213, 239, 211, 217, 216, 209, 229, 395, 240, 225, 463 206, 234, 218, 210, 208, 193, 219, 393, 223, 204,
464 206, 169, 395, 395, 116, 106, 99, 54, 395, 395, 464 176, 157, 393, 393, 120, 106, 97, 119, 393, 393,
465 254, 260, 268, 272, 276, 282, 289, 293, 301, 309, 465 245, 251, 259, 263, 267, 273, 280, 284, 292, 300,
466 313, 319, 327, 335 466 304, 310, 318, 326
467 } ; 467 } ;
468 468
469static yyconst flex_int16_t yy_def[175] = 469static yyconst flex_int16_t yy_def[175] =
@@ -489,108 +489,108 @@ static yyconst flex_int16_t yy_def[175] =
489 160, 160, 160, 160 489 160, 160, 160, 160
490 } ; 490 } ;
491 491
492static yyconst flex_int16_t yy_nxt[441] = 492static yyconst flex_int16_t yy_nxt[440] =
493 { 0, 493 { 0,
494 12, 13, 14, 15, 16, 12, 17, 18, 12, 12, 494 12, 13, 14, 13, 15, 16, 12, 17, 18, 12,
495 12, 19, 12, 12, 12, 12, 20, 21, 22, 23, 495 12, 12, 19, 12, 12, 12, 12, 20, 21, 22,
496 23, 23, 23, 23, 12, 12, 23, 23, 23, 23, 496 23, 23, 23, 23, 23, 12, 12, 23, 23, 23,
497 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 497 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
498 23, 23, 12, 24, 12, 25, 34, 35, 35, 25, 498 23, 23, 23, 12, 24, 12, 25, 34, 35, 35,
499 81, 26, 26, 27, 27, 27, 34, 35, 35, 82, 499 25, 81, 26, 26, 27, 27, 27, 34, 35, 35,
500 28, 36, 36, 36, 36, 159, 29, 28, 28, 28, 500 82, 28, 36, 36, 36, 53, 54, 29, 28, 28,
501 28, 12, 13, 14, 15, 16, 30, 17, 18, 30, 501 28, 28, 12, 13, 14, 13, 15, 16, 30, 17,
502 30, 30, 26, 30, 30, 30, 12, 20, 21, 22, 502 18, 30, 30, 30, 26, 30, 30, 30, 12, 20,
503 31, 31, 31, 31, 31, 32, 12, 31, 31, 31, 503 21, 22, 31, 31, 31, 31, 31, 32, 12, 31,
504 504
505 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 505 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
506 31, 31, 31, 12, 24, 12, 39, 41, 45, 47, 506 31, 31, 31, 31, 31, 12, 24, 12, 36, 36,
507 53, 54, 48, 56, 57, 61, 61, 47, 66, 45, 507 36, 39, 41, 45, 47, 56, 57, 48, 61, 47,
508 48, 66, 66, 66, 39, 46, 40, 49, 59, 50, 508 39, 159, 48, 66, 61, 45, 66, 66, 66, 158,
509 158, 51, 122, 52, 157, 49, 46, 50, 136, 63, 509 46, 40, 49, 59, 50, 157, 51, 49, 52, 50,
510 137, 52, 156, 43, 40, 62, 65, 65, 65, 59, 510 40, 63, 46, 52, 36, 36, 36, 156, 43, 62,
511 61, 61, 123, 65, 75, 69, 69, 69, 36, 36, 511 65, 65, 65, 59, 136, 68, 137, 65, 75, 69,
512 65, 65, 65, 65, 70, 71, 72, 69, 69, 69, 512 69, 69, 70, 71, 65, 65, 65, 65, 70, 71,
513 45, 46, 61, 61, 109, 77, 70, 71, 93, 110, 513 72, 69, 69, 69, 61, 46, 45, 155, 154, 66,
514 68, 70, 71, 85, 85, 85, 66, 46, 155, 66, 514 70, 71, 66, 66, 66, 122, 85, 85, 85, 59,
515 515
516 66, 66, 69, 69, 69, 122, 59, 100, 100, 61, 516 69, 69, 69, 46, 77, 100, 109, 93, 100, 70,
517 61, 70, 71, 100, 100, 148, 112, 154, 85, 85, 517 71, 110, 112, 122, 129, 123, 153, 85, 85, 85,
518 85, 61, 61, 129, 129, 123, 129, 129, 135, 135, 518 135, 135, 135, 148, 148, 160, 135, 135, 135, 152,
519 135, 142, 142, 148, 143, 149, 153, 135, 135, 135, 519 142, 142, 142, 123, 143, 142, 142, 142, 151, 143,
520 142, 142, 160, 143, 152, 151, 150, 146, 145, 144, 520 150, 146, 145, 149, 149, 38, 38, 38, 38, 38,
521 141, 140, 139, 149, 38, 38, 38, 38, 38, 38, 521 38, 38, 38, 42, 144, 141, 140, 42, 42, 44,
522 38, 38, 42, 138, 134, 133, 42, 42, 44, 44, 522 44, 44, 44, 44, 44, 44, 44, 58, 58, 58,
523 44, 44, 44, 44, 44, 44, 58, 58, 58, 58, 523 58, 64, 139, 64, 66, 138, 134, 66, 133, 66,
524 64, 132, 64, 66, 131, 130, 66, 160, 66, 66, 524 66, 67, 132, 131, 67, 67, 67, 67, 73, 130,
525 67, 128, 127, 67, 67, 67, 67, 73, 126, 73, 525 73, 73, 76, 76, 76, 76, 76, 76, 76, 76,
526 526
527 73, 76, 76, 76, 76, 76, 76, 76, 76, 78, 527 78, 78, 78, 78, 78, 78, 78, 78, 91, 160,
528 78, 78, 78, 78, 78, 78, 78, 91, 125, 91, 528 91, 92, 129, 92, 92, 128, 92, 92, 121, 121,
529 92, 124, 92, 92, 120, 92, 92, 121, 121, 121, 529 121, 121, 121, 121, 121, 121, 147, 147, 147, 147,
530 121, 121, 121, 121, 121, 147, 147, 147, 147, 147, 530 147, 147, 147, 147, 127, 126, 125, 124, 61, 61,
531 147, 147, 147, 119, 118, 117, 116, 115, 47, 114, 531 120, 119, 118, 117, 116, 115, 47, 114, 110, 113,
532 110, 113, 111, 108, 107, 106, 48, 105, 104, 89, 532 111, 108, 107, 106, 48, 105, 104, 89, 103, 102,
533 103, 102, 101, 99, 98, 97, 96, 95, 94, 79, 533 101, 99, 98, 97, 96, 95, 94, 79, 77, 90,
534 77, 90, 89, 88, 59, 87, 86, 59, 84, 83, 534 89, 88, 59, 87, 86, 59, 84, 83, 80, 79,
535 80, 79, 77, 74, 160, 60, 59, 55, 37, 160, 535 77, 74, 160, 60, 59, 55, 37, 160, 33, 25,
536 33, 25, 26, 25, 11, 160, 160, 160, 160, 160, 536 26, 25, 11, 160, 160, 160, 160, 160, 160, 160,
537 537
538 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 538 160, 160, 160, 160, 160, 160, 160, 160, 160, 160,
539 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 539 160, 160, 160, 160, 160, 160, 160, 160, 160, 160,
540 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 540 160, 160, 160, 160, 160, 160, 160, 160, 160, 160,
541 160, 160, 160, 160, 160, 160, 160, 160, 160, 160 541 160, 160, 160, 160, 160, 160, 160, 160, 160
542 } ; 542 } ;
543 543
544static yyconst flex_int16_t yy_chk[441] = 544static yyconst flex_int16_t yy_chk[440] =
545 { 0, 545 { 0,
546 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 546 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
547 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 547 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
548 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 548 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
549 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 549 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
550 1, 1, 1, 1, 1, 4, 9, 9, 9, 10, 550 1, 1, 1, 1, 1, 1, 4, 9, 9, 9,
551 50, 4, 5, 5, 5, 5, 10, 10, 10, 50, 551 10, 50, 4, 5, 5, 5, 5, 10, 10, 10,
552 5, 13, 13, 14, 14, 158, 5, 5, 5, 5, 552 50, 5, 13, 13, 13, 20, 20, 5, 5, 5,
553 5, 7, 7, 7, 7, 7, 7, 7, 7, 7, 553 5, 5, 7, 7, 7, 7, 7, 7, 7, 7,
554 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 554 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
555 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 555 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
556 556
557 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 557 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
558 7, 7, 7, 7, 7, 7, 16, 17, 18, 19, 558 7, 7, 7, 7, 7, 7, 7, 7, 14, 14,
559 20, 20, 19, 22, 22, 25, 25, 26, 31, 44, 559 14, 16, 17, 18, 19, 22, 22, 19, 25, 26,
560 26, 31, 31, 31, 38, 18, 16, 19, 31, 19, 560 38, 158, 26, 31, 33, 44, 31, 31, 31, 157,
561 157, 19, 112, 19, 156, 26, 44, 26, 130, 26, 561 18, 16, 19, 31, 19, 156, 19, 26, 19, 26,
562 130, 26, 155, 17, 38, 25, 28, 28, 28, 28, 562 38, 26, 44, 26, 36, 36, 36, 155, 17, 25,
563 33, 33, 112, 28, 46, 34, 34, 34, 36, 36, 563 28, 28, 28, 28, 130, 33, 130, 28, 46, 34,
564 28, 28, 28, 28, 34, 34, 34, 35, 35, 35, 564 34, 34, 91, 91, 28, 28, 28, 28, 34, 34,
565 75, 46, 61, 61, 98, 77, 35, 35, 77, 98, 565 34, 35, 35, 35, 61, 46, 75, 152, 151, 67,
566 33, 91, 91, 61, 61, 61, 67, 75, 152, 67, 566 35, 35, 67, 67, 67, 112, 61, 61, 61, 67,
567 567
568 67, 67, 69, 69, 69, 121, 67, 85, 85, 113, 568 69, 69, 69, 75, 77, 85, 98, 77, 100, 69,
569 113, 69, 69, 100, 100, 143, 100, 151, 85, 85, 569 69, 98, 100, 121, 129, 112, 150, 85, 85, 85,
570 85, 114, 114, 122, 122, 121, 129, 129, 135, 135, 570 135, 135, 135, 143, 147, 149, 129, 129, 129, 146,
571 135, 138, 138, 147, 138, 143, 150, 129, 129, 129, 571 138, 138, 138, 121, 138, 142, 142, 142, 145, 142,
572 142, 142, 149, 142, 146, 145, 144, 141, 140, 139, 572 144, 141, 140, 143, 147, 161, 161, 161, 161, 161,
573 137, 136, 134, 147, 161, 161, 161, 161, 161, 161, 573 161, 161, 161, 162, 139, 137, 136, 162, 162, 163,
574 161, 161, 162, 133, 128, 127, 162, 162, 163, 163, 574 163, 163, 163, 163, 163, 163, 163, 164, 164, 164,
575 163, 163, 163, 163, 163, 163, 164, 164, 164, 164, 575 164, 165, 134, 165, 166, 133, 128, 166, 127, 166,
576 165, 126, 165, 166, 125, 124, 166, 123, 166, 166, 576 166, 167, 126, 125, 167, 167, 167, 167, 168, 124,
577 167, 120, 119, 167, 167, 167, 167, 168, 118, 168, 577 168, 168, 169, 169, 169, 169, 169, 169, 169, 169,
578 578
579 168, 169, 169, 169, 169, 169, 169, 169, 169, 170, 579 170, 170, 170, 170, 170, 170, 170, 170, 171, 123,
580 170, 170, 170, 170, 170, 170, 170, 171, 117, 171, 580 171, 172, 122, 172, 172, 120, 172, 172, 173, 173,
581 172, 116, 172, 172, 111, 172, 172, 173, 173, 173, 581 173, 173, 173, 173, 173, 173, 174, 174, 174, 174,
582 173, 173, 173, 173, 173, 174, 174, 174, 174, 174, 582 174, 174, 174, 174, 119, 118, 117, 116, 114, 113,
583 174, 174, 174, 110, 109, 108, 107, 106, 105, 103, 583 111, 110, 109, 108, 107, 106, 105, 103, 102, 101,
584 102, 101, 99, 97, 96, 95, 94, 93, 92, 90, 584 99, 97, 96, 95, 94, 93, 92, 90, 88, 87,
585 88, 87, 86, 84, 83, 82, 81, 80, 79, 78, 585 86, 84, 83, 82, 81, 80, 79, 78, 76, 71,
586 76, 71, 70, 68, 65, 63, 62, 58, 52, 51, 586 70, 68, 65, 63, 62, 58, 52, 51, 49, 48,
587 49, 48, 47, 43, 40, 24, 23, 21, 15, 11, 587 47, 43, 40, 24, 23, 21, 15, 11, 8, 6,
588 8, 6, 3, 2, 160, 160, 160, 160, 160, 160, 588 3, 2, 160, 160, 160, 160, 160, 160, 160, 160,
589 589
590 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 590 160, 160, 160, 160, 160, 160, 160, 160, 160, 160,
591 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 591 160, 160, 160, 160, 160, 160, 160, 160, 160, 160,
592 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 592 160, 160, 160, 160, 160, 160, 160, 160, 160, 160,
593 160, 160, 160, 160, 160, 160, 160, 160, 160, 160 593 160, 160, 160, 160, 160, 160, 160, 160, 160
594 } ; 594 } ;
595 595
596static yy_state_type yy_last_accepting_state; 596static yy_state_type yy_last_accepting_state;