Skip to content

Commit a048ca9

Browse files
committed
Upgrade to upstream 98f5573 (complete oldnames.lib)
1 parent b307e59 commit a048ca9

File tree

2 files changed

+265
-2
lines changed

2 files changed

+265
-2
lines changed

buildsdk.d

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,12 +393,47 @@ void buildMsvcrt(string outDir)
393393

394394
void buildOldnames(string outDir)
395395
{
396-
const cPrefix = x64 ? "" : "_";
396+
static string prependUnderscore(string symbolName)
397+
{
398+
return symbolName.startsWith("__imp_")
399+
? symbolName[0 .. 6] ~ "_" ~ symbolName[6 .. $] // __imp_name => __imp__name
400+
: "_" ~ symbolName; // name => _name
401+
}
402+
403+
const lines = std.file.readText("oldnames.list").splitLines;
404+
foreach (line; lines)
405+
{
406+
if (line.length == 0)
407+
continue;
408+
409+
string weakName;
410+
string realName;
411+
412+
const equalsIndex = line.indexOf('=');
413+
if (equalsIndex > 0)
414+
{
415+
weakName = line[0 .. equalsIndex];
416+
realName = line[equalsIndex+1 .. $];
417+
}
418+
else // most real names just feature an additional leading underscore
419+
{
420+
weakName = line;
421+
realName = prependUnderscore(weakName);
422+
}
423+
424+
weakSymbols[weakName] = realName;
425+
}
426+
427+
static string getMangledName(string symbolName)
428+
{
429+
return x64 ? symbolName : prependUnderscore(symbolName);
430+
}
431+
397432
const oldnames_c =
398433
// access this __ref_oldnames symbol to drag in the generated linker directives (msvcrt_stub.c)
399434
"int __ref_oldnames;\n" ~
400435
weakSymbols.byKeyValue.map!(pair =>
401-
`__pragma(comment(linker, "/alternatename:` ~ cPrefix ~ pair.key ~ `=` ~ cPrefix ~ pair.value ~ `"));`
436+
`__pragma(comment(linker, "/alternatename:` ~ getMangledName(pair.key) ~ `=` ~ getMangledName(pair.value) ~ `"));`
402437
).join("\n");
403438

404439
version (verbose)

oldnames.list

Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
1+
__imp_utime=__imp__utime32
2+
utime=_utime32
3+
__imp_ftime=__imp__ftime32
4+
ftime=_ftime32
5+
__imp_stat=__imp__stat32
6+
stat=_stat32
7+
__imp_fstat=__imp__fstat32
8+
fstat=_fstat32
9+
__imp_fcloseall
10+
fcloseall
11+
__imp_control87
12+
control87
13+
__imp_sys_errlist
14+
sys_errlist
15+
__imp_filelength
16+
filelength
17+
__imp_strcmpi=__imp__stricmp
18+
strcmpi=_stricmp
19+
__imp_wcsicoll
20+
__imp_wcsupr
21+
__imp_wcslwr
22+
__imp_wcsset
23+
__imp_wcsrev
24+
__imp_wcsnset
25+
__imp_wcsnicmp
26+
__imp_wcsicmp
27+
__imp_wcsdup
28+
__imp_dup
29+
__imp_tzset
30+
__imp_tzname
31+
__imp_timezone
32+
__imp_strupr
33+
__imp_strset
34+
__imp_strrev
35+
__imp_strnset
36+
__imp_strnicmp
37+
__imp_strlwr
38+
__imp_strdup
39+
__imp_stricmp
40+
__imp_tempnam
41+
__imp_rmtmp
42+
__imp_putw
43+
__imp_getw
44+
__imp_fputchar
45+
__imp_flushall
46+
__imp_fileno
47+
__imp_fgetchar
48+
__imp_fdopen
49+
__imp_ultoa
50+
__imp_swab
51+
__imp_putenv
52+
__imp_onexit
53+
__imp_ltoa
54+
__imp_itoa
55+
__imp_yn
56+
__imp_y1
57+
__imp_y0
58+
__imp_jn
59+
__imp_j1
60+
__imp_j0
61+
__imp_cabs
62+
__imp_HUGE
63+
__imp_gcvt
64+
__imp_fcvt
65+
__imp_ecvt
66+
__imp_lsearch
67+
__imp_lfind
68+
__imp_spawnvpe
69+
__imp_spawnvp
70+
__imp_spawnve
71+
__imp_spawnv
72+
__imp_spawnlpe
73+
__imp_spawnlp
74+
__imp_spawnle
75+
__imp_spawnl
76+
__imp_getpid
77+
__imp_execvpe
78+
__imp_execvp
79+
__imp_execve
80+
__imp_execv
81+
__imp_execlpe
82+
__imp_execlp
83+
__imp_execle
84+
__imp_execl
85+
__imp_cwait
86+
__imp_memicmp
87+
__imp_memccpy
88+
__imp_write
89+
__imp_unlink
90+
__imp_umask
91+
__imp_tell
92+
__imp_sys_nerr
93+
__imp_sopen
94+
__imp_setmode
95+
__imp_read
96+
__imp_open
97+
__imp_mktemp
98+
__imp_lseek
99+
__imp_locking
100+
__imp_isatty
101+
__imp_eof
102+
__imp_dup2
103+
__imp_creat
104+
__imp_close
105+
__imp_chsize
106+
__imp_chmod
107+
__imp_access
108+
__imp_rmdir
109+
__imp_mkdir
110+
__imp_getcwd
111+
__imp_chdir
112+
__imp_ungetch
113+
__imp_putch
114+
__imp_kbhit
115+
__imp_getche
116+
__imp_fpreset
117+
__imp_getch
118+
__imp_environ
119+
__imp_daylight
120+
__imp_cscanf
121+
__imp_cputs
122+
__imp_cprintf
123+
__imp_cgets
124+
wcsicoll
125+
wcsupr
126+
wcslwr
127+
wcsset
128+
wcsrev
129+
wcsnset
130+
wcsnicmp
131+
wcsicmp
132+
wcsdup
133+
dup
134+
tzset
135+
tzname
136+
timezone
137+
strupr
138+
strset
139+
strrev
140+
strnset
141+
strnicmp
142+
strlwr
143+
strdup
144+
stricmp
145+
tempnam
146+
rmtmp
147+
putw
148+
getw
149+
fputchar
150+
flushall
151+
fileno
152+
fgetchar
153+
fdopen
154+
ultoa
155+
swab
156+
putenv
157+
onexit
158+
ltoa
159+
itoa
160+
yn
161+
y1
162+
y0
163+
jn
164+
j1
165+
j0
166+
cabs
167+
HUGE
168+
gcvt
169+
fcvt
170+
ecvt
171+
lsearch
172+
lfind
173+
spawnvpe
174+
spawnvp
175+
spawnve
176+
spawnv
177+
spawnlpe
178+
spawnlp
179+
spawnle
180+
spawnl
181+
getpid
182+
execvpe
183+
execvp
184+
execve
185+
execv
186+
execlpe
187+
execlp
188+
execle
189+
execl
190+
cwait
191+
memicmp
192+
memccpy
193+
write
194+
unlink
195+
umask
196+
tell
197+
sys_nerr
198+
sopen
199+
setmode
200+
read
201+
open
202+
mktemp
203+
lseek
204+
locking
205+
isatty
206+
eof
207+
dup2
208+
creat
209+
close
210+
chsize
211+
chmod
212+
access
213+
rmdir
214+
mkdir
215+
getcwd
216+
chdir
217+
ungetch
218+
putch
219+
kbhit
220+
getche
221+
fpreset
222+
getch
223+
environ
224+
daylight
225+
cscanf
226+
cputs
227+
cprintf
228+
cgets

0 commit comments

Comments
 (0)