s390x: Implement tls_value (#4616)
Implement the tls_value for s390 in the ELF general-dynamic mode. Notable differences to the x86_64 implementation are: - We use a __tls_get_offset libcall instead of __tls_get_addr. - The current thread pointer (stored in a pair of access registers) needs to be added to the result of __tls_get_offset. - __tls_get_offset has a variant ABI that requires the address of the GOT (global offset table) is passed in %r12. This means we need a new libcall entries for __tls_get_offset. In addition, we also need a way to access _GLOBAL_OFFSET_TABLE_. The latter is a "magic" symbol with a well-known name defined by the ABI and recognized by the linker. This patch introduces a new ExternalName::KnownSymbol variant to support such names (originally due to @afonso360). We also need to emit a relocation on a symbol placed in a constant pool, as well as an extra relocation on the call to __tls_get_offset required for TLS linker optimization. Needed by the cg_clif frontend.
This commit is contained in:
@@ -59,6 +59,11 @@ pub enum Reloc {
|
||||
/// Set the add immediate field to the low 12 bits of the final address. Does not check for overflow.
|
||||
/// This is equivalent to `R_AARCH64_TLSGD_ADD_LO12_NC` in the [aaelf64](https://github.com/ARM-software/abi-aa/blob/2bcab1e3b22d55170c563c3c7940134089176746/aaelf64/aaelf64.rst#relocations-for-thread-local-storage)
|
||||
Aarch64TlsGdAddLo12Nc,
|
||||
|
||||
/// s390x TLS GD64 - 64-bit offset of tls_index for GD symbol in GOT
|
||||
S390xTlsGd64,
|
||||
/// s390x TLS GDCall - marker to enable optimization of TLS calls
|
||||
S390xTlsGdCall,
|
||||
}
|
||||
|
||||
impl fmt::Display for Reloc {
|
||||
@@ -79,6 +84,8 @@ impl fmt::Display for Reloc {
|
||||
Self::MachOX86_64Tlv => write!(f, "MachOX86_64Tlv"),
|
||||
Self::Aarch64TlsGdAdrPage21 => write!(f, "Aarch64TlsGdAdrPage21"),
|
||||
Self::Aarch64TlsGdAddLo12Nc => write!(f, "Aarch64TlsGdAddLo12Nc"),
|
||||
Self::S390xTlsGd64 => write!(f, "TlsGd64"),
|
||||
Self::S390xTlsGdCall => write!(f, "TlsGdCall"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user