llvm-project/llvm/lib/Target/X86/MCTargetDesc
Martin Storsjo 489993db94 [MinGW] [X86] Add stubs for references to data variables that might end up imported from a dll
Variables declared with the dllimport attribute are accessed via a
stub variable named __imp_<var>. In MinGW configurations, variables that
aren't declared with a dllimport attribute might still end up imported
from another DLL with runtime pseudo relocs.

For x86_64, this avoids the risk that the target is out of range
for a 32 bit PC relative reference, in case the target DLL is loaded
further than 4 GB from the reference. It also avoids having to make the
text section writable at runtime when doing the runtime fixups, which
makes it worthwhile to do for i386 as well.

Add stub variables for all dso local data references where a definition
of the variable isn't visible within the module, since the DLL data
autoimporting might make them imported even though they are marked as
dso local within LLVM.

Don't do this for variables that actually are defined within the same
module, since we then know for sure that it actually is dso local.

Don't do this for references to functions, since there's no need for
runtime pseudo relocations for autoimporting them; if a function from
a different DLL is called without the appropriate dllimport attribute,
the call just gets routed via a thunk instead.

GCC does something similar since 4.9 (when compiling with -mcmodel=medium
or large; from that version, medium is the default code model for x86_64
mingw), but only for x86_64.

Differential Revision: https://reviews.llvm.org/D51288

llvm-svn: 340942
2018-08-29 17:28:34 +00:00
..
CMakeLists.txt [codeview] Implement FPO data assembler directives 2017-10-11 21:24:33 +00:00
LLVMBuild.txt
X86AsmBackend.cpp [MC] Pass MCSubtargetInfo to fixupNeedsRelaxation and applyFixup 2018-06-06 09:40:06 +00:00
X86BaseInfo.h [MinGW] [X86] Add stubs for references to data variables that might end up imported from a dll 2018-08-29 17:28:34 +00:00
X86ELFObjectWriter.cpp MC: Separate creating a generic object writer from creating a target object writer. NFCI. 2018-05-21 19:20:29 +00:00
X86FixupKinds.h [llvm-mc] - Produce R_X86_64_PLT32 for "call/jmp foo". 2018-02-20 10:17:57 +00:00
X86MCAsmInfo.cpp Remove redundant includes from lib/Target/X86. 2017-12-13 21:31:19 +00:00
X86MCAsmInfo.h
X86MCCodeEmitter.cpp [X86] Make %eiz usage in 64-bit mode, force a 0x67 address size prefix. Fix some test CHECK lines. 2018-06-23 06:15:04 +00:00
X86MCExpr.h [MC][X86] Enhance X86 Register expression handling to more closely match GCC. 2018-08-16 16:31:14 +00:00
X86MCTargetDesc.cpp Add missing override keyword (NFC) 2018-08-24 16:15:44 +00:00
X86MCTargetDesc.h [X86][BtVer2] correctly model the latency/throughput of LEA instructions. 2018-07-19 16:42:15 +00:00
X86MachObjectWriter.cpp MC: Separate creating a generic object writer from creating a target object writer. NFCI. 2018-05-21 19:20:29 +00:00
X86TargetStreamer.h [codeview] Implement FPO data assembler directives 2017-10-11 21:24:33 +00:00
X86WinCOFFObjectWriter.cpp MC: Separate creating a generic object writer from creating a target object writer. NFCI. 2018-05-21 19:20:29 +00:00
X86WinCOFFStreamer.cpp MC: Change the streamer ctors to take an object writer instead of a stream. NFCI. 2018-05-18 18:26:45 +00:00
X86WinCOFFTargetStreamer.cpp [codeview] Implement FPO data assembler directives 2017-10-11 21:24:33 +00:00