Skip to content

Commit e07e6d8

Browse files
authored
started adding dynamic entries data in the elf sections (#484)
thank you.
1 parent 53ba5c1 commit e07e6d8

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

patterns/elf.hexpat

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,15 @@ struct Elf32_Syminfo {
645645
SYMINFO_FLG si_flags;
646646
};
647647

648+
struct Elf32_Dyn {
649+
DT d_tag;
650+
Elf32_Word d_val;
651+
} [[format("format_elf32_dyn")]];
652+
653+
fn format_elf32_dyn(auto dyn) {
654+
return dyn.d_tag;
655+
};
656+
648657
s64 stringTableIndex;
649658

650659
struct String {
@@ -680,6 +689,8 @@ struct Elf32_Shdr {
680689
Elf32_Rela relaTable[sh_size / sh_entsize] @ sh_offset;
681690
} else if (sh_type == SHT::INIT_ARRAY || sh_type == SHT::FINI_ARRAY) {
682691
u32 pointer[while($ < (sh_offset + sh_size))] @ sh_offset;
692+
} else if (sh_type == SHT::DYNAMIC) {
693+
Elf32_Dyn dynamic_entries[sh_size / sh_entsize] @ sh_offset;
683694
} else {
684695
u8 data[sh_size] @ sh_offset [[sealed]];
685696
}
@@ -716,6 +727,16 @@ struct Elf64_Syminfo {
716727
u16 si_boundto;
717728
SYMINFO_FLG si_flags;
718729
};
730+
731+
struct Elf64_Dyn {
732+
DT d_tag;
733+
padding[4];
734+
Elf64_Xword d_val;
735+
} [[format("format_elf64_dyn")]];
736+
737+
fn format_elf64_dyn(auto dyn) {
738+
return dyn.d_tag;
739+
};
719740

720741
struct Elf64_Shdr {
721742
u32 sh_name;
@@ -743,6 +764,8 @@ struct Elf64_Shdr {
743764
Elf64_Rela relaTable[sh_size / sh_entsize] @ sh_offset;
744765
} else if (sh_type == SHT::INIT_ARRAY || sh_type == SHT::FINI_ARRAY) {
745766
u32 pointer[while($ < (sh_offset + sh_size))] @ sh_offset;
767+
} else if (sh_type == SHT::DYNAMIC) {
768+
Elf64_Dyn dynamic_entries[sh_size / sh_entsize] @ sh_offset;
746769
} else {
747770
u8 data[sh_size] @ sh_offset [[sealed]];
748771
}

0 commit comments

Comments
 (0)