Add support for hidden visibility
This commit is contained in:
@@ -383,8 +383,9 @@ fn translate_function_linkage(linkage: Linkage) -> faerie::Decl {
|
|||||||
match linkage {
|
match linkage {
|
||||||
Linkage::Import => faerie::Decl::function_import().into(),
|
Linkage::Import => faerie::Decl::function_import().into(),
|
||||||
Linkage::Local => faerie::Decl::function().into(),
|
Linkage::Local => faerie::Decl::function().into(),
|
||||||
Linkage::Export => faerie::Decl::function().global().into(),
|
|
||||||
Linkage::Preemptible => faerie::Decl::function().weak().into(),
|
Linkage::Preemptible => faerie::Decl::function().weak().into(),
|
||||||
|
Linkage::Hidden => faerie::Decl::function().global().hidden().into(),
|
||||||
|
Linkage::Export => faerie::Decl::function().global().into(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -396,13 +397,19 @@ fn translate_data_linkage(linkage: Linkage, writable: bool, align: Option<u8>) -
|
|||||||
.with_writable(writable)
|
.with_writable(writable)
|
||||||
.with_align(align)
|
.with_align(align)
|
||||||
.into(),
|
.into(),
|
||||||
Linkage::Export => faerie::Decl::data()
|
Linkage::Preemptible => faerie::Decl::data()
|
||||||
.global()
|
.weak()
|
||||||
.with_writable(writable)
|
.with_writable(writable)
|
||||||
.with_align(align)
|
.with_align(align)
|
||||||
.into(),
|
.into(),
|
||||||
Linkage::Preemptible => faerie::Decl::data()
|
Linkage::Hidden => faerie::Decl::data()
|
||||||
.weak()
|
.global()
|
||||||
|
.hidden()
|
||||||
|
.with_writable(writable)
|
||||||
|
.with_align(align)
|
||||||
|
.into(),
|
||||||
|
Linkage::Export => faerie::Decl::data()
|
||||||
|
.global()
|
||||||
.with_writable(writable)
|
.with_writable(writable)
|
||||||
.with_align(align)
|
.with_align(align)
|
||||||
.into(),
|
.into(),
|
||||||
|
|||||||
@@ -58,6 +58,11 @@ pub enum Linkage {
|
|||||||
Local,
|
Local,
|
||||||
/// Defined inside the module, visible outside it, and may be preempted.
|
/// Defined inside the module, visible outside it, and may be preempted.
|
||||||
Preemptible,
|
Preemptible,
|
||||||
|
/// Defined inside the module, visible inside the current static linkage unit, but not outside.
|
||||||
|
///
|
||||||
|
/// A static linkage unit is the combination of all object files passed to a linker to create
|
||||||
|
/// an executable or dynamic library.
|
||||||
|
Hidden,
|
||||||
/// Defined inside the module, and visible outside it.
|
/// Defined inside the module, and visible outside it.
|
||||||
Export,
|
Export,
|
||||||
}
|
}
|
||||||
@@ -66,14 +71,20 @@ impl Linkage {
|
|||||||
fn merge(a: Self, b: Self) -> Self {
|
fn merge(a: Self, b: Self) -> Self {
|
||||||
match a {
|
match a {
|
||||||
Self::Export => Self::Export,
|
Self::Export => Self::Export,
|
||||||
|
Self::Hidden => match b {
|
||||||
|
Self::Export => Self::Export,
|
||||||
|
Self::Preemptible => Self::Preemptible,
|
||||||
|
_ => Self::Hidden,
|
||||||
|
},
|
||||||
Self::Preemptible => match b {
|
Self::Preemptible => match b {
|
||||||
Self::Export => Self::Export,
|
Self::Export => Self::Export,
|
||||||
_ => Self::Preemptible,
|
_ => Self::Preemptible,
|
||||||
},
|
},
|
||||||
Self::Local => match b {
|
Self::Local => match b {
|
||||||
Self::Export => Self::Export,
|
Self::Export => Self::Export,
|
||||||
|
Self::Hidden => Self::Hidden,
|
||||||
Self::Preemptible => Self::Preemptible,
|
Self::Preemptible => Self::Preemptible,
|
||||||
_ => Self::Local,
|
Self::Local | Self::Import => Self::Local,
|
||||||
},
|
},
|
||||||
Self::Import => b,
|
Self::Import => b,
|
||||||
}
|
}
|
||||||
@@ -83,7 +94,7 @@ impl Linkage {
|
|||||||
pub fn is_definable(self) -> bool {
|
pub fn is_definable(self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
Self::Import => false,
|
Self::Import => false,
|
||||||
Self::Local | Self::Preemptible | Self::Export => true,
|
Self::Local | Self::Preemptible | Self::Hidden | Self::Export => true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,7 +102,7 @@ impl Linkage {
|
|||||||
pub fn is_final(self) -> bool {
|
pub fn is_final(self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
Self::Import | Self::Preemptible => false,
|
Self::Import | Self::Preemptible => false,
|
||||||
Self::Local | Self::Export => true,
|
Self::Local | Self::Hidden | Self::Export => true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -474,6 +474,7 @@ fn translate_linkage(linkage: Linkage) -> (SymbolScope, bool) {
|
|||||||
let scope = match linkage {
|
let scope = match linkage {
|
||||||
Linkage::Import => SymbolScope::Unknown,
|
Linkage::Import => SymbolScope::Unknown,
|
||||||
Linkage::Local => SymbolScope::Compilation,
|
Linkage::Local => SymbolScope::Compilation,
|
||||||
|
Linkage::Hidden => SymbolScope::Linkage,
|
||||||
Linkage::Export | Linkage::Preemptible => SymbolScope::Dynamic,
|
Linkage::Export | Linkage::Preemptible => SymbolScope::Dynamic,
|
||||||
};
|
};
|
||||||
// TODO: this matches rustc_codegen_cranelift, but may be wrong.
|
// TODO: this matches rustc_codegen_cranelift, but may be wrong.
|
||||||
|
|||||||
Reference in New Issue
Block a user