rust/compiler/rustc_codegen_llvm/src
bors 558553272d Auto merge of #88200 - pcwalton:no-dso-local-on-mach-o, r=nagisa
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-22 23:44:48 +00:00
..
back Handle SrcMgr diagnostics 2021-08-16 18:28:17 +02:00
coverageinfo Auto merge of #85178 - cjgillot:local-crate, r=oli-obk 2021-05-17 01:42:03 +00:00
debuginfo Include (potentially remapped) working dir in crate hash 2021-08-15 15:17:37 -05:00
llvm Handle SrcMgr diagnostics 2021-08-16 18:28:17 +02:00
abi.rs Remove the decl arg from FnAbi::llvm_type 2021-08-05 10:58:55 -07:00
allocator.rs Prepare call/invoke for opaque pointers 2021-08-05 10:58:55 -07:00
asm.rs Auto merge of #87581 - Amanieu:asm_clobber_abi, r=nagisa 2021-08-14 22:29:27 +00:00
attributes.rs Add support for leaf fn frame pointer elimination 2021-06-30 19:45:17 +03:00
base.rs Always use llvm.used for coverage symbols 2021-08-21 10:08:05 +02:00
builder.rs Prepare call/invoke for opaque pointers 2021-08-05 10:58:55 -07:00
callee.rs Fix static relocation model for PowerPC64 2021-05-28 03:48:39 +02:00
common.rs Replace LLVMConstInBoundsGEP with LLVMConstInBoundsGEP2* 2021-08-04 15:51:30 +02:00
consts.rs Always use llvm.used for coverage symbols 2021-08-21 10:08:05 +02:00
context.rs Always use llvm.used for coverage symbols 2021-08-21 10:08:05 +02:00
declare.rs Remove the decl arg from FnAbi::llvm_type 2021-08-05 10:58:55 -07:00
intrinsic.rs Implement black_box using intrinsic 2021-08-12 16:16:57 +01:00
lib.rs Dispose LLVM context after TargetMachine 2021-08-16 18:28:18 +02:00
llvm_util.rs clippy::single_char_pattern 2021-07-25 12:25:26 +02:00
mono_item.rs 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
type_.rs Auto merge of #87254 - rusticstuff:rustc_codegen_llvm_dont_emit_zero_sized_padding, r=eddyb 2021-08-11 01:36:23 +00:00
type_of.rs Test: Use smallvec directly instead of boxed. 2021-08-09 15:42:37 +00:00
va_arg.rs Replace hard-coded field indexes with lookup on aarch64 non-macos. 2021-08-05 22:40:32 +00:00
value.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00