Skip to content

Commit 9bae569

Browse files
committed
add test which assert that import list for executable not changed silently
1 parent dda102c commit 9bae569

File tree

6 files changed

+214
-0
lines changed

6 files changed

+214
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# only-x86_64-pc-windows-msvc
2+
3+
include ../tools.mk
4+
5+
# assert that import list for simple executable not changed silently
6+
# FIXME: remove "File:" from diff by making path reproducible: now it's broken
7+
8+
all:
9+
$(RUSTC) empty.rs
10+
"$(LLVM_BIN_DIR)"/llvm-readobj --coff-imports $(TMPDIR)/empty.exe > "$(TMPDIR)/actual.empty.txt"
11+
diff -u -I "File:" -I "ImportLookupTableRVA:" -I "ImportAddressTableRVA:" expected.empty.txt "$(TMPDIR)/actual.empty.txt"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
2+
File: empty.exe
3+
Format: COFF-x86-64
4+
Arch: x86_64
5+
AddressSize: 64bit
6+
Import {
7+
Name: KERNEL32.dll
8+
ImportLookupTableRVA: 0x207C0
9+
ImportAddressTableRVA: 0x19000
10+
Symbol: GetLastError (619)
11+
Symbol: AddVectoredExceptionHandler (19)
12+
Symbol: SetThreadStackGuarantee (1408)
13+
Symbol: WaitForSingleObject (1528)
14+
Symbol: QueryPerformanceCounter (1115)
15+
Symbol: AcquireSRWLockExclusive (0)
16+
Symbol: RtlCaptureContext (1247)
17+
Symbol: RtlVirtualUnwind (1262)
18+
Symbol: RtlLookupFunctionEntry (1255)
19+
Symbol: SetLastError (1357)
20+
Symbol: GetCurrentDirectoryW (539)
21+
Symbol: GetEnvironmentVariableW (580)
22+
Symbol: GetCurrentProcess (545)
23+
Symbol: GetStdHandle (737)
24+
Symbol: GetCurrentProcessId (546)
25+
Symbol: TryAcquireSRWLockExclusive (1477)
26+
Symbol: HeapFree (862)
27+
Symbol: HeapReAlloc (865)
28+
Symbol: AcquireSRWLockShared (1)
29+
Symbol: ReleaseSRWLockShared (1219)
30+
Symbol: ReleaseMutex (1216)
31+
Symbol: GetModuleHandleA (639)
32+
Symbol: GetProcAddress (700)
33+
Symbol: GetProcessHeap (707)
34+
Symbol: GetConsoleMode (518)
35+
Symbol: GetModuleHandleW (642)
36+
Symbol: MultiByteToWideChar (1023)
37+
Symbol: WriteConsoleW (1586)
38+
Symbol: GetCurrentThread (549)
39+
Symbol: GetSystemTimeAsFileTime (760)
40+
Symbol: WaitForSingleObjectEx (1529)
41+
Symbol: LoadLibraryA (977)
42+
Symbol: CreateMutexA (218)
43+
Symbol: ReleaseSRWLockExclusive (1218)
44+
Symbol: HeapAlloc (858)
45+
Symbol: CloseHandle (137)
46+
Symbol: SetUnhandledExceptionFilter (1421)
47+
Symbol: UnhandledExceptionFilter (1486)
48+
Symbol: IsDebuggerPresent (910)
49+
Symbol: InitializeSListHead (888)
50+
Symbol: GetCurrentThreadId (550)
51+
Symbol: IsProcessorFeaturePresent (917)
52+
}
53+
Import {
54+
Name: ntdll.dll
55+
ImportLookupTableRVA: 0x20A50
56+
ImportAddressTableRVA: 0x19290
57+
Symbol: RtlNtStatusToDosError (1294)
58+
Symbol: NtWriteFile (665)
59+
}
60+
Import {
61+
Name: VCRUNTIME140.dll
62+
ImportLookupTableRVA: 0x20918
63+
ImportAddressTableRVA: 0x19158
64+
Symbol: __current_exception_context (28)
65+
Symbol: __current_exception (27)
66+
Symbol: __C_specific_handler (8)
67+
Symbol: _CxxThrowException (1)
68+
Symbol: memcmp (59)
69+
Symbol: memmove (61)
70+
Symbol: memset (62)
71+
Symbol: memcpy (60)
72+
Symbol: __CxxFrameHandler3 (14)
73+
}
74+
Import {
75+
Name: api-ms-win-crt-runtime-l1-1-0.dll
76+
ImportLookupTableRVA: 0x209A0
77+
ImportAddressTableRVA: 0x191E0
78+
Symbol: _initterm_e (55)
79+
Symbol: exit (85)
80+
Symbol: _exit (35)
81+
Symbol: _initterm (54)
82+
Symbol: _get_initial_narrow_environment (40)
83+
Symbol: __p___argc (4)
84+
Symbol: __p___argv (5)
85+
Symbol: _cexit (22)
86+
Symbol: _c_exit (21)
87+
Symbol: _register_thread_local_exe_atexit_callback (61)
88+
Symbol: _configure_narrow_argv (24)
89+
Symbol: _set_app_type (66)
90+
Symbol: _initialize_narrow_environment (51)
91+
Symbol: _initialize_onexit_table (52)
92+
Symbol: _register_onexit_function (60)
93+
Symbol: _crt_atexit (30)
94+
Symbol: terminate (103)
95+
Symbol: _seh_filter_exe (64)
96+
}
97+
Import {
98+
Name: api-ms-win-crt-math-l1-1-0.dll
99+
ImportLookupTableRVA: 0x20990
100+
ImportAddressTableRVA: 0x191D0
101+
Symbol: __setusermatherr (9)
102+
}
103+
Import {
104+
Name: api-ms-win-crt-stdio-l1-1-0.dll
105+
ImportLookupTableRVA: 0x20A38
106+
ImportAddressTableRVA: 0x19278
107+
Symbol: _set_fmode (84)
108+
Symbol: __p__commode (1)
109+
}
110+
Import {
111+
Name: api-ms-win-crt-locale-l1-1-0.dll
112+
ImportLookupTableRVA: 0x20980
113+
ImportAddressTableRVA: 0x191C0
114+
Symbol: _configthreadlocale (8)
115+
}
116+
Import {
117+
Name: api-ms-win-crt-heap-l1-1-0.dll
118+
ImportLookupTableRVA: 0x20968
119+
ImportAddressTableRVA: 0x191A8
120+
Symbol: free (24)
121+
Symbol: _set_new_mode (22)
122+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# only-x86_64-unknown-linux-gnu
2+
3+
include ../tools.mk
4+
5+
# assert that import list for simple executable not changed silently
6+
# requires binutils
7+
8+
all:
9+
$(RUSTC) empty.rs
10+
readelf --dyn-syms -W $(TMPDIR)/empty > "$(TMPDIR)/actual.empty.txt"
11+
diff -u expected.empty.txt "$(TMPDIR)/actual.empty.txt"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
2+
Symbol table '.dynsym' contains 65 entries:
3+
Num: Value Size Type Bind Vis Ndx Name
4+
0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
5+
1: 0000000000000000 0 FUNC GLOBAL DEFAULT UND getenv@GLIBC_2.2.5 (2)
6+
2: 0000000000000000 0 FUNC GLOBAL DEFAULT UND dl_iterate_phdr@GLIBC_2.2.5 (2)
7+
3: 0000000000000000 0 FUNC GLOBAL DEFAULT UND free@GLIBC_2.2.5 (2)
8+
4: 0000000000000000 0 FUNC GLOBAL DEFAULT UND __libc_start_main@GLIBC_2.34 (3)
9+
5: 0000000000000000 0 FUNC GLOBAL DEFAULT UND abort@GLIBC_2.2.5 (2)
10+
6: 0000000000000000 0 FUNC GLOBAL DEFAULT UND _Unwind_Backtrace@GCC_3.3 (4)
11+
7: 0000000000000000 0 FUNC GLOBAL DEFAULT UND __errno_location@GLIBC_2.2.5 (2)
12+
8: 0000000000000000 0 NOTYPE WEAK DEFAULT UND _ITM_deregisterTMCloneTable
13+
9: 0000000000000000 0 FUNC GLOBAL DEFAULT UND writev@GLIBC_2.2.5 (2)
14+
10: 0000000000000000 0 FUNC GLOBAL DEFAULT UND pthread_getattr_np@GLIBC_2.32 (5)
15+
11: 0000000000000000 0 FUNC GLOBAL DEFAULT UND sigaction@GLIBC_2.2.5 (2)
16+
12: 0000000000000000 0 FUNC WEAK DEFAULT UND __cxa_thread_atexit_impl@GLIBC_2.18 (6)
17+
13: 0000000000000000 0 FUNC GLOBAL DEFAULT UND __xpg_strerror_r@GLIBC_2.3.4 (7)
18+
14: 0000000000000000 0 FUNC GLOBAL DEFAULT UND pthread_getspecific@GLIBC_2.34 (3)
19+
15: 0000000000000000 0 FUNC GLOBAL DEFAULT UND readlink@GLIBC_2.2.5 (2)
20+
16: 0000000000000000 0 FUNC GLOBAL DEFAULT UND fcntl@GLIBC_2.2.5 (2)
21+
17: 0000000000000000 0 FUNC GLOBAL DEFAULT UND _Unwind_GetRegionStart@GCC_3.0 (8)
22+
18: 0000000000000000 0 FUNC GLOBAL DEFAULT UND write@GLIBC_2.2.5 (2)
23+
19: 0000000000000000 0 FUNC GLOBAL DEFAULT UND _Unwind_GetTextRelBase@GCC_3.0 (8)
24+
20: 0000000000000000 0 FUNC GLOBAL DEFAULT UND _Unwind_RaiseException@GCC_3.0 (8)
25+
21: 0000000000000000 0 FUNC GLOBAL DEFAULT UND strlen@GLIBC_2.2.5 (2)
26+
22: 0000000000000000 0 FUNC GLOBAL DEFAULT UND stat64@GLIBC_2.33 (9)
27+
23: 0000000000000000 0 FUNC GLOBAL DEFAULT UND pthread_key_create@GLIBC_2.34 (3)
28+
24: 0000000000000000 0 FUNC GLOBAL DEFAULT UND memset@GLIBC_2.2.5 (2)
29+
25: 0000000000000000 0 FUNC GLOBAL DEFAULT UND getcwd@GLIBC_2.2.5 (2)
30+
26: 0000000000000000 0 FUNC GLOBAL DEFAULT UND _Unwind_GetIPInfo@GCC_4.2.0 (10)
31+
27: 0000000000000000 0 FUNC GLOBAL DEFAULT UND close@GLIBC_2.2.5 (2)
32+
28: 0000000000000000 0 FUNC GLOBAL DEFAULT UND _Unwind_GetLanguageSpecificData@GCC_3.0 (8)
33+
29: 0000000000000000 0 FUNC GLOBAL DEFAULT UND pthread_key_delete@GLIBC_2.34 (3)
34+
30: 0000000000000000 0 FUNC GLOBAL DEFAULT UND read@GLIBC_2.2.5 (2)
35+
31: 0000000000000000 0 FUNC GLOBAL DEFAULT UND __tls_get_addr@GLIBC_2.3 (11)
36+
32: 0000000000000000 0 FUNC GLOBAL DEFAULT UND calloc@GLIBC_2.2.5 (2)
37+
33: 0000000000000000 0 FUNC GLOBAL DEFAULT UND signal@GLIBC_2.2.5 (2)
38+
34: 0000000000000000 0 FUNC GLOBAL DEFAULT UND syscall@GLIBC_2.2.5 (2)
39+
35: 0000000000000000 0 FUNC GLOBAL DEFAULT UND pthread_attr_getstack@GLIBC_2.34 (3)
40+
36: 0000000000000000 0 NOTYPE WEAK DEFAULT UND __gmon_start__
41+
37: 0000000000000000 0 FUNC GLOBAL DEFAULT UND realpath@GLIBC_2.3 (12)
42+
38: 0000000000000000 0 FUNC GLOBAL DEFAULT UND memcpy@GLIBC_2.14 (13)
43+
39: 0000000000000000 0 FUNC GLOBAL DEFAULT UND _Unwind_GetIP@GCC_3.0 (8)
44+
40: 0000000000000000 0 FUNC GLOBAL DEFAULT UND mmap64@GLIBC_2.2.5 (2)
45+
41: 0000000000000000 0 FUNC GLOBAL DEFAULT UND malloc@GLIBC_2.2.5 (2)
46+
42: 0000000000000000 0 FUNC GLOBAL DEFAULT UND bcmp@GLIBC_2.2.5 (2)
47+
43: 0000000000000000 0 FUNC GLOBAL DEFAULT UND realloc@GLIBC_2.2.5 (2)
48+
44: 0000000000000000 0 FUNC GLOBAL DEFAULT UND munmap@GLIBC_2.2.5 (2)
49+
45: 0000000000000000 0 FUNC WEAK DEFAULT UND statx@GLIBC_2.28 (14)
50+
46: 0000000000000000 0 FUNC GLOBAL DEFAULT UND _Unwind_GetDataRelBase@GCC_3.0 (8)
51+
47: 0000000000000000 0 FUNC GLOBAL DEFAULT UND poll@GLIBC_2.2.5 (2)
52+
48: 0000000000000000 0 FUNC GLOBAL DEFAULT UND _Unwind_SetGR@GCC_3.0 (8)
53+
49: 0000000000000000 0 FUNC GLOBAL DEFAULT UND open64@GLIBC_2.2.5 (2)
54+
50: 0000000000000000 0 FUNC GLOBAL DEFAULT UND memmove@GLIBC_2.2.5 (2)
55+
51: 0000000000000000 0 FUNC GLOBAL DEFAULT UND pthread_self@GLIBC_2.2.5 (2)
56+
52: 0000000000000000 0 FUNC GLOBAL DEFAULT UND mprotect@GLIBC_2.2.5 (2)
57+
53: 0000000000000000 0 FUNC GLOBAL DEFAULT UND sysconf@GLIBC_2.2.5 (2)
58+
54: 0000000000000000 0 FUNC GLOBAL DEFAULT UND pthread_attr_destroy@GLIBC_2.2.5 (2)
59+
55: 0000000000000000 0 FUNC GLOBAL DEFAULT UND lseek64@GLIBC_2.2.5 (2)
60+
56: 0000000000000000 0 FUNC GLOBAL DEFAULT UND fstat64@GLIBC_2.33 (9)
61+
57: 0000000000000000 0 FUNC GLOBAL DEFAULT UND posix_memalign@GLIBC_2.2.5 (2)
62+
58: 0000000000000000 0 NOTYPE WEAK DEFAULT UND _ITM_registerTMCloneTable
63+
59: 0000000000000000 0 FUNC GLOBAL DEFAULT UND _Unwind_DeleteException@GCC_3.0 (8)
64+
60: 0000000000000000 0 FUNC GLOBAL DEFAULT UND sigaltstack@GLIBC_2.2.5 (2)
65+
61: 0000000000000000 0 FUNC GLOBAL DEFAULT UND _Unwind_Resume@GCC_3.0 (8)
66+
62: 0000000000000000 0 FUNC GLOBAL DEFAULT UND pthread_setspecific@GLIBC_2.34 (3)
67+
63: 0000000000000000 0 FUNC GLOBAL DEFAULT UND _Unwind_SetIP@GCC_3.0 (8)
68+
64: 0000000000000000 0 FUNC WEAK DEFAULT UND __cxa_finalize@GLIBC_2.2.5 (2)

0 commit comments

Comments
 (0)