Zig 0.17.0-dev (Split by item)
This is an example of documentation generated by
ZigDoc , an alternative to Zig's built-in
Auto Doc feature. See also
examples in other modes/formats . The project being documented here (as the example) is the Zig library itself.
Zig › compiler/ › aro/ › backend/ › Object/ › Elf.zig › getSection
getSection
Elf.getSection
pub fn getSection (elf : *Elf , section_kind : Object .Section ) !*std .ArrayList (u8 )
File
Code
pub fn getSection (elf : *Elf , section_kind : Object .Section ) !*std .ArrayList (u8 ) {
const section_name = sectionString (section_kind );
const section = elf .sections .get (section_name ) orelse blk : {
const section = try elf .arena .allocator ().create (Section );
section .* = .{
.data = std .ArrayList (u8 ).init (elf .arena .child_allocator ),
.type = std .elf .SHT_PROGBITS ,
.flags = switch (section_kind ) {
.func , .custom => std .elf .SHF_ALLOC + std .elf .SHF_EXECINSTR ,
.strings => std .elf .SHF_ALLOC + std .elf .SHF_MERGE + std .elf .SHF_STRINGS ,
.read_only_data => std .elf .SHF_ALLOC ,
.data => std .elf .SHF_ALLOC + std .elf .SHF_WRITE ,
.undefined => unreachable ,
},
};
try elf .sections .putNoClobber (elf .arena .child_allocator , section_name , section );
elf .strtab_len += section_name .len + ".\x00" .len ;
break :blk section ;
};
return §ion .data ;
}