浏览代码

Allow users to read elf section alignment

Ben Alderson 6 年之前
父节点
当前提交
e5034a1f3b
共有 1 个文件被更改,包括 14 次插入0 次删除
  1. 14 0
      src/elf_sections.rs

+ 14 - 0
src/elf_sections.rs

@@ -169,6 +169,10 @@ impl ElfSection {
         self.get().size()
     }
 
+    pub fn addralign(&self) -> u64 {
+        self.get().addralign()
+    }
+
     pub fn flags(&self) -> ElfSectionFlags {
         ElfSectionFlags::from_bits_truncate(self.get().flags())
     }
@@ -204,6 +208,8 @@ trait ElfSectionInner {
     fn addr(&self) -> u64;
 
     fn size(&self) -> u64;
+
+    fn addralign(&self) -> u64;
 }
 
 impl ElfSectionInner for ElfSectionInner32 {
@@ -226,6 +232,10 @@ impl ElfSectionInner for ElfSectionInner32 {
     fn size(&self) -> u64 {
         self.size.into()
     }
+
+    fn addralign(&self) -> u64 {
+        self.addralign.into()
+    }
 }
 
 impl ElfSectionInner for ElfSectionInner64 {
@@ -248,6 +258,10 @@ impl ElfSectionInner for ElfSectionInner64 {
     fn size(&self) -> u64 {
         self.size
     }
+
+    fn addralign(&self) -> u64 {
+        self.addralign.into()
+    }
 }
 
 #[derive(PartialEq, Eq, Debug, Copy, Clone)]