mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-06 12:18:33 +00:00
rustc_target: Add a target spec option for static-pie support
This commit is contained in:
parent
f182c4af8a
commit
eccaa0186f
@ -1143,9 +1143,10 @@ fn link_output_kind(sess: &Session, crate_type: CrateType) -> LinkOutputKind {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Adjust the output kind to target capabilities.
|
// Adjust the output kind to target capabilities.
|
||||||
let pic_exe_supported = sess.target.target.options.position_independent_executables;
|
let opts = &sess.target.target.options;
|
||||||
let static_pic_exe_supported = false; // FIXME: Add this option to target specs.
|
let pic_exe_supported = opts.position_independent_executables;
|
||||||
let static_dylib_supported = sess.target.target.options.crt_static_allows_dylibs;
|
let static_pic_exe_supported = opts.static_position_independent_executables;
|
||||||
|
let static_dylib_supported = opts.crt_static_allows_dylibs;
|
||||||
match kind {
|
match kind {
|
||||||
LinkOutputKind::DynamicPicExe if !pic_exe_supported => LinkOutputKind::DynamicNoPicExe,
|
LinkOutputKind::DynamicPicExe if !pic_exe_supported => LinkOutputKind::DynamicNoPicExe,
|
||||||
LinkOutputKind::StaticPicExe if !static_pic_exe_supported => LinkOutputKind::StaticNoPicExe,
|
LinkOutputKind::StaticPicExe if !static_pic_exe_supported => LinkOutputKind::StaticNoPicExe,
|
||||||
|
@ -855,6 +855,8 @@ pub struct TargetOptions {
|
|||||||
/// the functions in the executable are not randomized and can be used
|
/// the functions in the executable are not randomized and can be used
|
||||||
/// during an exploit of a vulnerability in any code.
|
/// during an exploit of a vulnerability in any code.
|
||||||
pub position_independent_executables: bool,
|
pub position_independent_executables: bool,
|
||||||
|
/// Executables that are both statically linked and position-independent are supported.
|
||||||
|
pub static_position_independent_executables: bool,
|
||||||
/// Determines if the target always requires using the PLT for indirect
|
/// Determines if the target always requires using the PLT for indirect
|
||||||
/// library calls or not. This controls the default value of the `-Z plt` flag.
|
/// library calls or not. This controls the default value of the `-Z plt` flag.
|
||||||
pub needs_plt: bool,
|
pub needs_plt: bool,
|
||||||
@ -1028,6 +1030,7 @@ impl Default for TargetOptions {
|
|||||||
has_rpath: false,
|
has_rpath: false,
|
||||||
no_default_libraries: true,
|
no_default_libraries: true,
|
||||||
position_independent_executables: false,
|
position_independent_executables: false,
|
||||||
|
static_position_independent_executables: false,
|
||||||
needs_plt: false,
|
needs_plt: false,
|
||||||
relro_level: RelroLevel::None,
|
relro_level: RelroLevel::None,
|
||||||
pre_link_objects: Default::default(),
|
pre_link_objects: Default::default(),
|
||||||
@ -1432,6 +1435,7 @@ impl Target {
|
|||||||
key!(has_rpath, bool);
|
key!(has_rpath, bool);
|
||||||
key!(no_default_libraries, bool);
|
key!(no_default_libraries, bool);
|
||||||
key!(position_independent_executables, bool);
|
key!(position_independent_executables, bool);
|
||||||
|
key!(static_position_independent_executables, bool);
|
||||||
key!(needs_plt, bool);
|
key!(needs_plt, bool);
|
||||||
key!(relro_level, RelroLevel)?;
|
key!(relro_level, RelroLevel)?;
|
||||||
key!(archive_format);
|
key!(archive_format);
|
||||||
@ -1663,6 +1667,7 @@ impl ToJson for Target {
|
|||||||
target_option_val!(has_rpath);
|
target_option_val!(has_rpath);
|
||||||
target_option_val!(no_default_libraries);
|
target_option_val!(no_default_libraries);
|
||||||
target_option_val!(position_independent_executables);
|
target_option_val!(position_independent_executables);
|
||||||
|
target_option_val!(static_position_independent_executables);
|
||||||
target_option_val!(needs_plt);
|
target_option_val!(needs_plt);
|
||||||
target_option_val!(relro_level);
|
target_option_val!(relro_level);
|
||||||
target_option_val!(archive_format);
|
target_option_val!(archive_format);
|
||||||
|
Loading…
Reference in New Issue
Block a user