llvm.org GIT mirror llvm / 1b1321f
Fix fastcall mangling of dllimported symbols fastcall requires @ as global prefix instead of _ but getNameWithPrefix wrongly assumes the OutName buffer is empty and replaces at index 0. For imported functions this buffer is pre-filled with "__imp_" resulting in broken "@_imp_foo@0" mangling. Instead replace at the proper index. We also never have to prepend the @-prefix because this fastcall mangling is only used on 32-bit Windows targets which have _ has global prefix. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199203 91177308-0d34-0410-b5e6-96231b3b80d8 Nico Rieck 6 years ago
1 changed file(s) with 6 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
8080 PrefixTy = Mangler::Private;
8181 else if (GV->hasLinkerPrivateLinkage() || GV->hasLinkerPrivateWeakLinkage())
8282 PrefixTy = Mangler::LinkerPrivate;
83
83
84 size_t NameBegin = OutName.size();
85
8486 // If this global has a name, handle it simply.
8587 if (GV->hasName()) {
8688 StringRef Name = GV->getName();
105107 if (const Function *F = dyn_cast(GV)) {
106108 CallingConv::ID CC = F->getCallingConv();
107109
108 // fastcall functions need to start with @.
109 // FIXME: This logic seems unlikely to be right.
110 // fastcall functions need to start with @ instead of _.
110111 if (CC == CallingConv::X86_FastCall) {
111 if (OutName[0] == '_')
112 OutName[0] = '@';
113 else
114 OutName.insert(OutName.begin(), '@');
112 assert(OutName[NameBegin] == '_' && DL->getGlobalPrefix() == '_');
113 OutName[NameBegin] = '@';
115114 }
116115
117116 // fastcall and stdcall functions usually need @42 at the end to specify