cranelift: Add COFF TLS Support (#4546)

* cranelift: Implement COFF TLS Relocations

* cranelift: Emit SecRel relocations

* cranelift: Handle _tls_index symbol in backend
This commit is contained in:
Afonso Bordado
2022-08-11 17:33:40 +01:00
committed by GitHub
parent a40b253792
commit c5bc368cfe
10 changed files with 153 additions and 29 deletions

View File

@@ -9,6 +9,9 @@ use serde::{Deserialize, Serialize};
pub enum KnownSymbol {
/// ELF well-known linker symbol _GLOBAL_OFFSET_TABLE_
ElfGlobalOffsetTable,
/// TLS index symbol for the current thread.
/// Used in COFF/PE file formats.
CoffTlsIndex,
}
impl fmt::Display for KnownSymbol {
@@ -23,6 +26,7 @@ impl FromStr for KnownSymbol {
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"ElfGlobalOffsetTable" => Ok(Self::ElfGlobalOffsetTable),
"CoffTlsIndex" => Ok(Self::CoffTlsIndex),
_ => Err(()),
}
}
@@ -38,5 +42,6 @@ mod tests {
"ElfGlobalOffsetTable".parse(),
Ok(KnownSymbol::ElfGlobalOffsetTable)
);
assert_eq!("CoffTlsIndex".parse(), Ok(KnownSymbol::CoffTlsIndex));
}
}