File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -768,6 +768,21 @@ pub const Header = struct {
768768 };
769769 }
770770
771+ pub fn iterateDynamicSectionBuffer (
772+ h : * const Header ,
773+ buf : []const u8 ,
774+ offset : u64 ,
775+ size : u64 ,
776+ ) DynamicSectionBufferIterator {
777+ return .{
778+ .is_64 = h .is_64 ,
779+ .endian = h .endian ,
780+ .offset = offset ,
781+ .end_offset = offset + size ,
782+ .buf = buf ,
783+ };
784+ }
785+
771786 pub const ReadError = Io .Reader .Error || error {
772787 InvalidElfMagic ,
773788 InvalidElfVersion ,
@@ -963,6 +978,23 @@ pub const DynamicSectionIterator = struct {
963978 }
964979};
965980
981+ pub const DynamicSectionBufferIterator = struct {
982+ is_64 : bool ,
983+ endian : Endian ,
984+ offset : u64 ,
985+ end_offset : u64 ,
986+
987+ buf : []const u8 ,
988+
989+ pub fn next (it : * DynamicSectionBufferIterator ) ! ? Elf64_Dyn {
990+ if (it .offset >= it .end_offset ) return null ;
991+ const size : u64 = if (it .is_64 ) @sizeOf (Elf64_Dyn ) else @sizeOf (Elf32_Dyn );
992+ defer it .offset += size ;
993+ var reader : std.Io.Reader = .fixed (it .buf [it .offset .. ]);
994+ return try takeDynamicSection (& reader , it .is_64 , it .endian );
995+ }
996+ };
997+
966998pub fn takeDynamicSection (reader : * Io.Reader , is_64 : bool , endian : Endian ) ! Elf64_Dyn {
967999 if (is_64 ) {
9681000 const dyn = try reader .takeStruct (Elf64_Dyn , endian );
You can’t perform that action at this time.
0 commit comments