aboutsummaryrefslogtreecommitdiff
path: root/tests/test-dladdr.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test-dladdr.c')
-rw-r--r--tests/test-dladdr.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/tests/test-dladdr.c b/tests/test-dladdr.c
index 5568f23..aa815b0 100644
--- a/tests/test-dladdr.c
+++ b/tests/test-dladdr.c
@@ -140,6 +140,7 @@ __declspec(dllexport)
140#endif 140#endif
141int main(int argc, char **argv) 141int main(int argc, char **argv)
142{ 142{
143#ifdef _WIN32
143#if defined(_M_ARM64) || defined(__aarch64__) 144#if defined(_M_ARM64) || defined(__aarch64__)
144 /* points to non reachable address */ 145 /* points to non reachable address */
145 unsigned char zero_thunk_address[12] = { 0x10, 0x00, 0x00, 0x90, 0x10, 0x02, 0x40, 0xF9, 0x00, 0x02, 0x1F, 0xD6 }; 146 unsigned char zero_thunk_address[12] = { 0x10, 0x00, 0x00, 0x90, 0x10, 0x02, 0x40, 0xF9, 0x00, 0x02, 0x1F, 0xD6 };
@@ -147,13 +148,16 @@ int main(int argc, char **argv)
147 unsigned char invalid_thunk_address[12] = { 0x10, 0x00, 0x00, 0xb0, 0x10, 0x06, 0x47, 0xF9, 0x00, 0x02, 0x1F, 0xD6 }; 148 unsigned char invalid_thunk_address[12] = { 0x10, 0x00, 0x00, 0xb0, 0x10, 0x06, 0x47, 0xF9, 0x00, 0x02, 0x1F, 0xD6 };
148 /* no import thunk */ 149 /* no import thunk */
149 unsigned char no_import_thunk[12] = { 0x11, 0x00, 0x00, 0xb0, 0x31, 0x06, 0x47, 0xF9, 0x20, 0x02, 0x1F, 0xD6 }; 150 unsigned char no_import_thunk[12] = { 0x11, 0x00, 0x00, 0xb0, 0x31, 0x06, 0x47, 0xF9, 0x20, 0x02, 0x1F, 0xD6 };
150#else 151#elif defined(_M_AMD64) || defined(_M_IX86) || defined(__x86_64__) || defined(__i386__)
151 /* points to non reachable address */ 152 /* points to non reachable address */
152 unsigned char zero_thunk_address[6] = { 0xFF, 0x25, 0x00, 0x00, 0x00, 0x00 }; 153 unsigned char zero_thunk_address[6] = { 0xFF, 0x25, 0x00, 0x00, 0x00, 0x00 };
153 /* points to executable base */ 154 /* points to executable base */
154 unsigned char invalid_thunk_address[6] = { 0xFF, 0x25, 0x00, 0x00, 0x40, 0x00 }; 155 unsigned char invalid_thunk_address[6] = { 0xFF, 0x25, 0x00, 0x00, 0x40, 0x00 };
155 /* no import thunk */ 156 /* no import thunk */
156 unsigned char no_import_thunk[6] = { 0xFF, 0x26, 0x00, 0x00, 0x40, 0x00 }; 157 unsigned char no_import_thunk[6] = { 0xFF, 0x26, 0x00, 0x00, 0x40, 0x00 };
158#else
159#error "thunk test cases are not defined for this architecture"
160#endif
157#endif 161#endif
158 int result = 0; 162 int result = 0;
159 UNUSED(argv); 163 UNUSED(argv);
@@ -169,11 +173,12 @@ int main(int argc, char **argv)
169 result |= check_dladdr( "function from executable", (void*)main, "main", Pass ); 173 result |= check_dladdr( "function from executable", (void*)main, "main", Pass );
170 result |= check_dladdr( "static function from executable", (void*)print_dl_info, "print_dl_info", Fail ); 174 result |= check_dladdr( "static function from executable", (void*)print_dl_info, "print_dl_info", Fail );
171 result |= check_dladdr( "address with positive offset", ((char*)atoi)+1, "atoi", PassWithDifferentAddress ); 175 result |= check_dladdr( "address with positive offset", ((char*)atoi)+1, "atoi", PassWithDifferentAddress );
176
177#ifdef _WIN32
172 result |= check_dladdr( "zero address from import thunk", zero_thunk_address, "", NoInfo ); 178 result |= check_dladdr( "zero address from import thunk", zero_thunk_address, "", NoInfo );
173 result |= check_dladdr( "invalid address from import thunk", invalid_thunk_address, "", NoInfo ); 179 result |= check_dladdr( "invalid address from import thunk", invalid_thunk_address, "", NoInfo );
174 result |= check_dladdr( "no import thunk", no_import_thunk, "", NoInfo ); 180 result |= check_dladdr( "no import thunk", no_import_thunk, "", NoInfo );
175 181
176#ifdef _WIN32
177 result |= check_dladdr( "last entry in iat", (void*)VirtualQuery, "VirtualQuery", PassWithDifferentAddress ); 182 result |= check_dladdr( "last entry in iat", (void*)VirtualQuery, "VirtualQuery", PassWithDifferentAddress );
178 183
179 result |= check_dladdr ( "address through import thunk", (void*)GetModuleHandleA, "GetModuleHandleA", PassWithDifferentAddress ); 184 result |= check_dladdr ( "address through import thunk", (void*)GetModuleHandleA, "GetModuleHandleA", PassWithDifferentAddress );