userspace/file/format/elf/section/header/
special.rs1extern crate alloc;
2
3pub enum SpecialName {
4 Fixed(&'static str),
5 RelPrefix, RelaPrefix, }
8
9impl SpecialName {
10 pub fn generate(&self, target: &str) -> alloc::string::String {
12 match self {
13 SpecialName::Fixed(s) => (*s).into(),
14 SpecialName::RelPrefix => [".rel", target].concat().into(),
15 SpecialName::RelaPrefix => [".rela", target].concat().into(),
16 }
17 }
18}
19
20pub struct Special {
21 pub name: SpecialName,
22 pub types: &'static [super::Type],
23 pub flags: &'static [super::Flag],
24}
25
26#[rustfmt::skip]
27pub const SPECIALS: &'static [Special] = &[
28 Special { name: SpecialName::Fixed(".bss"), types : &[super::Type::Nobits], flags : &[super::Flag::Alloc, super::Flag::Write]},
29 Special { name: SpecialName::Fixed(".comment"), types : &[super::Type::Progbits], flags : &[] },
30 Special { name: SpecialName::Fixed(".data"), types : &[super::Type::Progbits], flags : &[super::Flag::Alloc, super::Flag::Write] },
31 Special { name: SpecialName::Fixed(".data1"), types : &[super::Type::Progbits], flags : &[super::Flag::Alloc, super::Flag::Write] },
32 Special { name: SpecialName::Fixed(".debug"), types : &[super::Type::Progbits], flags : &[] },
33 Special { name: SpecialName::Fixed(".dynamic"), types : &[super::Type::Dynamic], flags : &[] }, Special { name: SpecialName::Fixed(".dynstr"), types : &[super::Type::Strtab], flags : &[super::Flag::Alloc] },
35 Special { name: SpecialName::Fixed(".dynsym"), types : &[super::Type::Dynsym], flags : &[super::Flag::Alloc] },
36 Special { name: SpecialName::Fixed(".fini"), types : &[super::Type::Progbits], flags : &[super::Flag::Alloc, super::Flag::Execinstr] },
37 Special { name: SpecialName::Fixed(".fini_array"), types : &[super::Type::FiniArray], flags : &[super::Flag::Alloc, super::Flag::Write] },
38 Special { name: SpecialName::Fixed(".got"), types : &[super::Type::Progbits], flags : &[] }, Special { name: SpecialName::Fixed(".hash"), types : &[super::Type::Hash], flags : &[super::Flag::Alloc] },
40 Special { name: SpecialName::Fixed(".init"), types : &[super::Type::Progbits], flags : &[super::Flag::Alloc, super::Flag::Execinstr] },
41 Special { name: SpecialName::Fixed(".init_array"), types : &[super::Type::InitArray], flags : &[super::Flag::Alloc, super::Flag::Write] },
42 Special { name: SpecialName::Fixed(".interp"), types : &[super::Type::Progbits], flags : &[] }, Special { name: SpecialName::Fixed(".line"), types : &[super::Type::Progbits], flags : &[] },
44 Special { name: SpecialName::Fixed(".note"), types : &[super::Type::Note], flags : &[] },
45 Special { name: SpecialName::Fixed(".plt"), types : &[super::Type::Progbits], flags : &[] }, Special { name: SpecialName::Fixed(".preinit_array"), types : &[super::Type::PreinitArray], flags : &[super::Flag::Alloc, super::Flag::Write] },
47 Special { name: SpecialName::RelPrefix, types : &[super::Type::Rel], flags : &[] }, Special { name: SpecialName::RelaPrefix, types : &[super::Type::Rela], flags : &[] }, Special { name: SpecialName::Fixed(".relr.dyn"), types : &[super::Type::Relr], flags : &[super::Flag::Alloc] },
50 Special { name: SpecialName::Fixed(".rodata"), types : &[super::Type::Progbits], flags : &[super::Flag::Alloc] },
51 Special { name: SpecialName::Fixed(".rodata1"), types : &[super::Type::Progbits], flags : &[super::Flag::Alloc] },
52 Special { name: SpecialName::Fixed(".shstrtab"), types : &[super::Type::Strtab], flags : &[] },
53 Special { name: SpecialName::Fixed(".strtab"), types : &[super::Type::Strtab], flags : &[] }, Special { name: SpecialName::Fixed(".symtab"), types : &[super::Type::Symtab], flags : &[] }, Special { name: SpecialName::Fixed(".symtab_shndx"), types : &[super::Type::SymtabShndx], flags : &[] }, Special { name: SpecialName::Fixed(".tbss"), types : &[super::Type::Nobits], flags : &[super::Flag::Alloc, super::Flag::Write, super::Flag::Tls] },
57 Special { name: SpecialName::Fixed(".tdata"), types : &[super::Type::Progbits], flags : &[super::Flag::Alloc, super::Flag::Write, super::Flag::Tls] },
58 Special { name: SpecialName::Fixed(".tdata1"), types : &[super::Type::Progbits], flags : &[super::Flag::Alloc, super::Flag::Write, super::Flag::Tls] },
59 Special { name: SpecialName::Fixed(".text"), types : &[super::Type::Progbits], flags : &[super::Flag::Alloc, super::Flag::Execinstr] },
60];
61
62