rust/compiler
Patrick Walton c17b1904a9 Stop emitting the dso_local LLVM attribute for external symbols under the static relocation model on macOS.
This matches Clang's behavior:

973cb2c326/clang/lib/CodeGen/CodeGenModule.cpp (L1038-L1040)

Even if `dso_local` were properly supported in this way on macOS, it seems
incorrect to add this annotation as liberally as we did. The `dso_local`
annotation is for symbols that ultimately end up in the same linkage unit, but
we were adding this annotation even for `static` values inside `extern` blocks
marked with `#[link(type="framework")]`, which should be considered dynamically
linked.  Note that Clang likewise avoids emitting `dso_local` for `dllimport`
symbols:

973cb2c326/clang/lib/CodeGen/CodeGenModule.cpp (L1005-L1007)

This issue caused breakage in the `ring` crate, which links to a symbol defined
in `Security.framework` that ultimately resolves to address `0x0`:

b94d61e044/src/rand.rs (L390)

For this symbol, the use of `dso_local` causes LLVM to emit a relocation of
type `X86_64_RELOC_SIGNED`, which is a 32-bit signed PC-relative offset. If the
binary is large enough, `0x0` might be out of range, and the link will fail.
Avoiding `dso_local` causes LLVM to use the GOT instead, emitting a relocation
of type `X86_64_RELOC_GOT_LOAD`, which will properly handle the large offset
and cause the link to succeed.

As a side note, the static relocation model is effectively deprecated for
security reasons on macOS, as it prohibits PIE. It's also completely
unsupported on Apple Silicon, so I don't think it's worth going to the effort
of properly supporting this model on that platform.
2021-08-20 17:10:41 -07:00
..
rustc rfc3052: Remove authors field from Cargo manifests 2021-07-29 14:56:05 -07:00
rustc_apfloat rfc3052: Remove authors field from Cargo manifests 2021-07-29 14:56:05 -07:00
rustc_arena rfc3052: Remove authors field from Cargo manifests 2021-07-29 14:56:05 -07:00
rustc_ast Remove box syntax from rustc_ast 2021-08-18 09:25:26 +02:00
rustc_ast_lowering Introduce hir::ExprKind::Let - Take 2 2021-08-15 16:18:26 -03:00
rustc_ast_passes Auto merge of #86860 - fee1-dead:stabilize, r=LeSeulArtichaut 2021-08-18 01:00:17 +00:00
rustc_ast_pretty Introduce hir::ExprKind::Let - Take 2 2021-08-15 16:18:26 -03:00
rustc_attr rustc: Fill out remaining parts of C-unwind ABI 2021-08-03 07:06:19 -07:00
rustc_builtin_macros Remove box syntax from rustc_builtin_macros 2021-08-18 09:25:26 +02:00
rustc_codegen_cranelift remove box_syntax uses from cranelift and tools 2021-08-18 09:31:51 +02:00
rustc_codegen_llvm Stop emitting the dso_local LLVM attribute for external symbols under the static relocation model on macOS. 2021-08-20 17:10:41 -07:00
rustc_codegen_ssa Update the backtrace crate in libstd 2021-08-19 07:31:49 -07:00
rustc_data_structures Remove duplicate trait bounds in rustc_data_structures::graph 2021-08-09 08:52:04 -05:00
rustc_driver Reduce verbosity of RUSTC_LOG 2021-08-09 21:39:39 -04:00
rustc_error_codes Auto merge of #86860 - fee1-dead:stabilize, r=LeSeulArtichaut 2021-08-18 01:00:17 +00:00
rustc_errors Modify structured suggestion output 2021-08-11 09:46:24 +00:00
rustc_expand Introduce hir::ExprKind::Let - Take 2 2021-08-15 16:18:26 -03:00
rustc_feature Auto merge of #86860 - fee1-dead:stabilize, r=LeSeulArtichaut 2021-08-18 01:00:17 +00:00
rustc_fs_util rfc3052: Remove authors field from Cargo manifests 2021-07-29 14:56:05 -07:00
rustc_graphviz rfc3052: Remove authors field from Cargo manifests 2021-07-29 14:56:05 -07:00
rustc_hir Introduce hir::ExprKind::Let - Take 2 2021-08-15 16:18:26 -03:00
rustc_hir_pretty Introduce hir::ExprKind::Let - Take 2 2021-08-15 16:18:26 -03:00
rustc_incremental rfc3052: Remove authors field from Cargo manifests 2021-07-29 14:56:05 -07:00
rustc_index rfc3052: Remove authors field from Cargo manifests 2021-07-29 14:56:05 -07:00
rustc_infer Auto merge of #86700 - lqd:matthews-nll-hrtb-errors, r=nikomatsakis 2021-08-18 15:54:59 +00:00
rustc_interface Replace #[plugin_registrar] with exporting __rustc_plugin_registrar 2021-08-10 14:20:48 +02:00
rustc_lexer Renamed variable str -> tail for clarity 2021-08-11 13:57:28 +02:00
rustc_lint Remove box syntax from rustc_lint 2021-08-18 09:31:51 +02:00
rustc_lint_defs Auto merge of #87324 - asquared31415:named-asm-labels, r=Amanieu 2021-08-14 17:33:38 +00:00
rustc_llvm Auto merge of #87798 - durin42:llvm-14, r=nikic 2021-08-08 04:33:22 +00:00
rustc_macros Rollup merge of #86123 - Aaron1011:query-span, r=cjgillot 2021-08-19 19:30:04 +02:00
rustc_metadata Include (potentially remapped) working dir in crate hash 2021-08-15 15:17:37 -05:00
rustc_middle Auto merge of #87781 - est31:remove_box, r=oli-obk 2021-08-18 10:43:27 +00:00
rustc_mir Auto merge of #88176 - erikdesjardins:rezst, r=oli-obk 2021-08-20 16:25:34 +00:00
rustc_mir_build Auto merge of #88039 - sexxi-goose:fix-87987, r=nikomatsakis 2021-08-20 02:19:58 +00:00
rustc_parse Remove box syntax from rustc_parse 2021-08-18 09:25:26 +02:00
rustc_parse_format rfc3052: Remove authors field from Cargo manifests 2021-07-29 14:56:05 -07:00
rustc_passes Rollup merge of #88036 - nbdd0121:const3, r=petrochenkov 2021-08-18 19:54:59 +02:00
rustc_plugin_impl Replace #[plugin_registrar] with exporting __rustc_plugin_registrar 2021-08-10 14:20:48 +02:00
rustc_privacy rustc_privacy: Replace HirIds and DefIds with LocalDefIds where possible 2021-08-19 00:01:12 +03:00
rustc_query_impl Auto merge of #87515 - crlf0710:trait_upcasting_part2, r=bjorn3 2021-08-03 16:58:56 +00:00
rustc_query_system Prevent double panic when handling incremental fingerprint mismatch 2021-08-12 15:11:39 -05:00
rustc_resolve review comment: use newtype to deduplicate logic 2021-08-18 14:05:15 +00:00
rustc_save_analysis Include (potentially remapped) working dir in crate hash 2021-08-15 15:17:37 -05:00
rustc_serialize Remove box syntax from rustc_serialize 2021-08-18 09:25:26 +02:00
rustc_session Include (potentially remapped) working dir in crate hash 2021-08-15 15:17:37 -05:00
rustc_span Rollup merge of #88050 - Aaron1011:filename-hash-stable, r=michaelwoerister 2021-08-19 19:30:07 +02:00
rustc_symbol_mangling Auto merge of #85296 - bjorn3:plugin_cleanup, r=petrochenkov 2021-08-12 04:30:41 +00:00
rustc_target Auto merge of #88023 - devnexen:fbsd_arm64, r=nagisa 2021-08-19 11:54:27 +00:00
rustc_trait_selection Auto merge of #86700 - lqd:matthews-nll-hrtb-errors, r=nikomatsakis 2021-08-18 15:54:59 +00:00
rustc_traits Auto merge of #86700 - lqd:matthews-nll-hrtb-errors, r=nikomatsakis 2021-08-18 15:54:59 +00:00
rustc_ty_utils rfc3052: Remove authors field from Cargo manifests 2021-07-29 14:56:05 -07:00
rustc_type_ir rfc3052: Remove authors field from Cargo manifests 2021-07-29 14:56:05 -07:00
rustc_typeck Auto merge of #87686 - matthiaskrgr:clippy_august_21_perf, r=jackh726 2021-08-20 13:41:42 +00:00