pub const Flags = packed struct(u32) SCALE_INDEX: bool = falseunused1: u2 = 0TYPE_NO_PAD: bool = falseThe section should not be padded to the next boundary. This flag is obsolete and is replaced by .ALIGN = .@"1BYTES". This is valid only for object files.
unused4: u1 = 0CNT_CODE: bool = falseThe section contains executable code.
CNT_INITIALIZED_DATA: bool = falseThe section contains initialized data.
CNT_UNINITIALIZED_DATA: bool = falseThe section contains uninitialized data.
LNK_OTHER: bool = falseReserved for future use.
LNK_INFO: bool = falseThe section contains comments or other information. The .drectve section has this type. This is valid for object files only.
unused10: u1 = 0LNK_REMOVE: bool = falseThe section will not become part of the image. This is valid only for object files.
LNK_COMDAT: bool = falseThe section contains COMDAT data. For more information, see COMDAT Sections (Object Only). This is valid only for object files.
unused13: u2 = 0union14: packed union { mask: u1, /// The section contains data referenced through the global pointer (GP). GPREL: bool, MEM_FARDATA: bool, } = .{ .mask = 0 }unused15: u1 = 0union16: packed union { mask: u1, MEM_PURGEABLE: bool, MEM_16BIT: bool, } = .{ .mask = 0 }MEM_LOCKED: bool = falseReserved for future use.
MEM_PRELOAD: bool = falseReserved for future use.
ALIGN: SectionHeader.Flags.Align = .NONELNK_NRELOC_OVFL: bool = falseThe section contains extended relocations.
MEM_DISCARDABLE: bool = falseThe section can be discarded as needed.
MEM_NOT_CACHED: bool = falseThe section cannot be cached.
MEM_NOT_PAGED: bool = falseThe section is not pageable.
MEM_SHARED: bool = falseThe section can be shared in memory.
MEM_EXECUTE: bool = falseThe section can be executed as code.
MEM_READ: bool = falseThe section can be read.
MEM_WRITE: bool = falseThe section can be written to.
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670 pub const Flags = packed struct(u32) {
SCALE_INDEX: bool = false,
unused1: u2 = 0,
/// The section should not be padded to the next boundary.
/// This flag is obsolete and is replaced by `.ALIGN = .@"1BYTES"`.
/// This is valid only for object files.
TYPE_NO_PAD: bool = false,
unused4: u1 = 0,
/// The section contains executable code.
CNT_CODE: bool = false,
/// The section contains initialized data.
CNT_INITIALIZED_DATA: bool = false,
/// The section contains uninitialized data.
CNT_UNINITIALIZED_DATA: bool = false,
/// Reserved for future use.
LNK_OTHER: bool = false,
/// The section contains comments or other information.
/// The .drectve section has this type.
/// This is valid for object files only.
LNK_INFO: bool = false,
unused10: u1 = 0,
/// The section will not become part of the image.
/// This is valid only for object files.
LNK_REMOVE: bool = false,
/// The section contains COMDAT data.
/// For more information, see COMDAT Sections (Object Only).
/// This is valid only for object files.
LNK_COMDAT: bool = false,
unused13: u2 = 0,
union14: packed union {
mask: u1,
/// The section contains data referenced through the global pointer (GP).
GPREL: bool,
MEM_FARDATA: bool,
} = .{ .mask = 0 },
unused15: u1 = 0,
union16: packed union {
mask: u1,
MEM_PURGEABLE: bool,
MEM_16BIT: bool,
} = .{ .mask = 0 },
/// Reserved for future use.
MEM_LOCKED: bool = false,
/// Reserved for future use.
MEM_PRELOAD: bool = false,
ALIGN: SectionHeader.Flags.Align = .NONE,
/// The section contains extended relocations.
LNK_NRELOC_OVFL: bool = false,
/// The section can be discarded as needed.
MEM_DISCARDABLE: bool = false,
/// The section cannot be cached.
MEM_NOT_CACHED: bool = false,
/// The section is not pageable.
MEM_NOT_PAGED: bool = false,
/// The section can be shared in memory.
MEM_SHARED: bool = false,
/// The section can be executed as code.
MEM_EXECUTE: bool = false,
/// The section can be read.
MEM_READ: bool = false,
/// The section can be written to.
MEM_WRITE: bool = false,
pub const Align = enum(u4) {
NONE = 0,
@"1BYTES" = 1,
@"2BYTES" = 2,
@"4BYTES" = 3,
@"8BYTES" = 4,
@"16BYTES" = 5,
@"32BYTES" = 6,
@"64BYTES" = 7,
@"128BYTES" = 8,
@"256BYTES" = 9,
@"512BYTES" = 10,
@"1024BYTES" = 11,
@"2048BYTES" = 12,
@"4096BYTES" = 13,
@"8192BYTES" = 14,
_,
pub fn toByteUnits(a: Align) ?u16 {
if (a == .NONE) return null;
return @as(u16, 1) << (@backingInt(a) - 1);
}
pub fn fromByteUnits(n: u16) Align {
std.debug.assert(std.math.isPowerOfTwo(n));
return @fromBackingInt(@intCast(@ctz(n) + 1));
}
pub fn alignment(a: Align) ?std.mem.Alignment {
return .fromByteUnitsOptional(a.toByteUnits() orelse null);
}
};
}