mirror of
https://github.com/encounter/object.git
synced 2026-07-10 12:18:39 -07:00
write/elf: set flags for StandardSection::EhFrame (#877)
This commit is contained in:
@@ -119,7 +119,9 @@ impl<'a> Object<'a> {
|
||||
} else {
|
||||
SectionKind::ReadOnlyData
|
||||
},
|
||||
SectionFlags::None,
|
||||
SectionFlags::Elf {
|
||||
sh_flags: u64::from(elf::SHF_ALLOC),
|
||||
},
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
+29
-1
@@ -4,7 +4,7 @@ use object::read::{Object, ObjectSection, ObjectSymbol};
|
||||
use object::{read, write, SectionIndex, SubArchitecture};
|
||||
use object::{
|
||||
Architecture, BinaryFormat, Endianness, RelocationEncoding, RelocationFlags, RelocationKind,
|
||||
SectionKind, SymbolFlags, SymbolKind, SymbolScope, SymbolSection,
|
||||
SectionFlags, SectionKind, SymbolFlags, SymbolKind, SymbolScope, SymbolSection,
|
||||
};
|
||||
|
||||
mod bss;
|
||||
@@ -196,6 +196,9 @@ fn elf_x86_64() {
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let eh_frame = object.section_id(write::StandardSection::EhFrame);
|
||||
object.append_section_data(eh_frame, &[1; 30], 4);
|
||||
|
||||
let bytes = object.write().unwrap();
|
||||
let object = read::File::parse(&*bytes).unwrap();
|
||||
assert_eq!(object.format(), BinaryFormat::Elf);
|
||||
@@ -211,9 +214,34 @@ fn elf_x86_64() {
|
||||
assert_eq!(text.kind(), SectionKind::Text);
|
||||
assert_eq!(text.address(), 0);
|
||||
assert_eq!(text.size(), 62);
|
||||
assert_eq!(
|
||||
text.flags(),
|
||||
SectionFlags::Elf {
|
||||
sh_flags: (object::elf::SHF_ALLOC | object::elf::SHF_EXECINSTR).into()
|
||||
}
|
||||
);
|
||||
assert_eq!(&text.data().unwrap()[..30], &[1; 30]);
|
||||
assert_eq!(&text.data().unwrap()[32..62], &[1; 30]);
|
||||
|
||||
let section = sections.next().unwrap();
|
||||
println!("{:?}", section);
|
||||
assert_eq!(section.name(), Ok(".rela.text"));
|
||||
assert_eq!(section.kind(), SectionKind::Metadata);
|
||||
|
||||
let section = sections.next().unwrap();
|
||||
println!("{:?}", section);
|
||||
assert_eq!(section.name(), Ok(".eh_frame"));
|
||||
assert_eq!(
|
||||
section.kind(),
|
||||
SectionKind::Elf(object::elf::SHT_X86_64_UNWIND)
|
||||
);
|
||||
assert_eq!(
|
||||
section.flags(),
|
||||
SectionFlags::Elf {
|
||||
sh_flags: object::elf::SHF_ALLOC.into()
|
||||
}
|
||||
);
|
||||
|
||||
let mut symbols = object.symbols();
|
||||
|
||||
let symbol = symbols.next().unwrap();
|
||||
|
||||
Reference in New Issue
Block a user