@@ -436,28 +436,38 @@ Sections:
436
436
# NOBITS-NEXT: Flags: [ PF_W, PF_R ]
437
437
# NOBITS-NEXT: FirstSec: .bss
438
438
# NOBITS-NEXT: LastSec: .bss
439
- # NOBITS-NEXT: Offset: 0x159
439
+ # NOBITS-NEXT: VAddr: 0x1001
440
+ # NOBITS-NEXT: Offset: 0x191
440
441
# NOBITS-NEXT: - Type: PT_LOAD
441
442
# NOBITS-NEXT: Flags: [ PF_W, PF_R ]
442
443
# NOBITS-NEXT: FirstSec: .data.1
443
444
# NOBITS-NEXT: LastSec: .bss
444
- # NOBITS-NEXT: Offset: 0x158
445
+ # NOBITS-NEXT: VAddr: 0x1000
446
+ # NOBITS-NEXT: Offset: 0x190
445
447
# NOBITS-NEXT: - Type: PT_LOAD
446
448
# NOBITS-NEXT: Flags: [ PF_W, PF_R ]
447
449
# NOBITS-NEXT: FirstSec: .data.1
448
450
# NOBITS-NEXT: LastSec: .data.2
449
- # NOBITS-NEXT: Offset: 0x158
451
+ # NOBITS-NEXT: VAddr: 0x1000
452
+ # NOBITS-NEXT: Offset: 0x190
450
453
# NOBITS-NEXT: - Type: PT_LOAD
451
454
# NOBITS-NEXT: Flags: [ PF_W, PF_R ]
452
455
# NOBITS-NEXT: FirstSec: .bss
453
456
# NOBITS-NEXT: LastSec: .data.2
454
- # NOBITS-NEXT: Offset: 0x159
457
+ # NOBITS-NEXT: VAddr: 0x1001
458
+ # NOBITS-NEXT: Offset: 0x191
455
459
# NOBITS-NEXT: - Type: PT_LOAD
456
460
# NOBITS-NEXT: Flags: [ PF_W, PF_R ]
457
461
# NOBITS-NEXT: FirstSec: .foo.bss
458
462
# NOBITS-NEXT: LastSec: .bar.bss
459
463
# NOBITS-NEXT: VAddr: 0x200000000
460
- # NOBITS-NEXT: Offset: 0x15A
464
+ # NOBITS-NEXT: Offset: 0x193
465
+ # NOBITS-NEXT: - Type: PT_LOAD
466
+ # NOBITS-NEXT: Flags: [ PF_W, PF_R ]
467
+ # NOBITS-NEXT: FirstSec: .data.3
468
+ # NOBITS-NEXT: LastSec: .bss.large
469
+ # NOBITS-NEXT: VAddr: 0x200000030
470
+ # NOBITS-NEXT: Offset: 0x193
461
471
# NOBITS-NEXT: Sections:
462
472
463
473
--- !ELF
@@ -471,27 +481,37 @@ ProgramHeaders:
471
481
Flags : [ PF_W, PF_R ]
472
482
FirstSec : .bss
473
483
LastSec : .bss
484
+ VAddr : 0x1001
474
485
# # Case 2: the SHT_NOBITS section is the last section in the segment.
475
486
- Type : PT_LOAD
476
487
Flags : [ PF_W, PF_R ]
477
488
FirstSec : .data.1
478
489
LastSec : .bss
490
+ VAddr : 0x1000
479
491
# # Case 3: the SHT_NOBITS section is in the middle of the segment.
480
492
- Type : PT_LOAD
481
493
Flags : [ PF_W, PF_R ]
482
494
FirstSec : .data.1
483
495
LastSec : .data.2
496
+ VAddr : 0x1000
484
497
# # Case 4: the SHT_NOBITS section is the first section in the segment.
485
498
- Type : PT_LOAD
486
499
Flags : [ PF_W, PF_R ]
487
500
FirstSec : .bss
488
501
LastSec : .data.2
502
+ VAddr : 0x1001
489
503
# # Case 5: another two SHT_NOBITS sections in a different segment.
490
504
- Type : PT_LOAD
491
505
Flags : [ PF_W, PF_R ]
492
506
FirstSec : .foo.bss
493
507
LastSec : .bar.bss
494
508
VAddr : 0x200000000
509
+ # # Case 6: a SHT_NOBITS section following a normal section, where the SHT_NOBITS size points past the end of the program header.
510
+ - Type : PT_LOAD
511
+ Flags : [ PF_W, PF_R ]
512
+ FirstSec : .data.3
513
+ LastSec : .bss.large
514
+ VAddr : 0x200000030
495
515
Sections :
496
516
- Name : .data.1
497
517
Type : SHT_PROGBITS
@@ -502,13 +522,13 @@ Sections:
502
522
- Name : .bss
503
523
Type : SHT_NOBITS
504
524
Flags : [ SHF_WRITE, SHF_ALLOC ]
505
- # # Use a size that is larger than the file size.
506
- ShSize : 0x00000000FFFFFFFF
507
- - Name : .data.2
508
- Type : SHT_PROGBITS
509
- Flags : [ SHF_WRITE, SHF_ALLOC ]
525
+ # # Use an arbitrary non-zero size.
526
+ Size : 0x1
527
+ - Name : .data.2
528
+ Type : SHT_PROGBITS
529
+ Flags : [ SHF_WRITE, SHF_ALLOC ]
510
530
# # Use an arbitrary size.
511
- Size : 0x1
531
+ Size : 0x1
512
532
- Name : .foo.bss
513
533
Type : SHT_NOBITS
514
534
Flags : [ SHF_WRITE, SHF_ALLOC ]
@@ -523,14 +543,26 @@ Sections:
523
543
# # Use an arbitrary size that is different to the size of
524
544
# # the previous section.
525
545
Size : 0x20
546
+ - Name : .data.3
547
+ Type : SHT_PROGBITS
548
+ Flags : [ SHF_WRITE, SHF_ALLOC ]
549
+ # Use an abitrary size. Also use an address that is larger than the previous
550
+ # section, because the tools expect segment addresses to be in order.
551
+ Size : 0x1
552
+ Address : 0x200000030
553
+ - Name : .bss.large
554
+ Type : SHT_NOBITS
555
+ Flags : [ SHF_WRITE, SHF_ALLOC ]
556
+ # # Use a size that is larger than the file size.
557
+ Size : 0x00000000FFFFFFFF
558
+ Address : 0x200000031
526
559
527
560
# # Check that we require sections in a program header
528
561
# # declaration to be sorted by their offsets.
529
562
# RUN: not yaml2obj --docnum=6 %s -o %t6 2>&1 | \
530
563
# RUN: FileCheck %s --check-prefix=UNSORTED --implicit-check-not="error:"
531
564
532
565
# UNSORTED: error: program header with index 0: the section index of .bar is greater than the index of .foo
533
- # UNSORTED-NEXT: error: sections in the program header with index 3 are not sorted by their file offset
534
566
535
567
--- !ELF
536
568
FileHeader :
@@ -552,15 +584,6 @@ ProgramHeaders:
552
584
FirstSec : .foo
553
585
LastSec : .bar
554
586
VAddr : 0x1000
555
- # # Case 2: the .bar section is placed before the .zed section in the file,
556
- # # but the sh_offset of .zed is less than the sh_offset of
557
- # # the .bar section because of the "ShOffset" property.
558
- # # Document we report an error for such a case.
559
- - Type : PT_LOAD
560
- Flags : [ PF_R ]
561
- FirstSec : .bar
562
- LastSec : .zed
563
- VAddr : 0x1001
564
587
Sections :
565
588
- Name : .foo
566
589
Type : SHT_PROGBITS
@@ -571,11 +594,6 @@ Sections:
571
594
Type : SHT_PROGBITS
572
595
Flags : [ SHF_ALLOC ]
573
596
Size : 0x1
574
- - Name : .zed
575
- Type : SHT_PROGBITS
576
- Flags : [ SHF_ALLOC ]
577
- Size : 0x1
578
- ShOffset : 0x0
579
597
580
598
# # Check how we dump segments which contain empty sections.
581
599
# RUN: yaml2obj --docnum=7 %s -o %t7
0 commit comments