diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c index b8500b5772c..6890a08428b 100644 --- a/dlls/ntdll/unix/loader.c +++ b/dlls/ntdll/unix/loader.c @@ -1438,24 +1438,12 @@ found: static void load_ntdll(void) { NTSTATUS status; + SECTION_IMAGE_INFORMATION info; void *module; - int fd; - char *name = build_path( dll_dir, "ntdll.dll" ); + char *name = build_path( dll_dir, "ntdll.dll.so" ); - if ((fd = open( name, O_RDONLY )) != -1) - { - struct stat st; - fstat( fd, &st ); - if (!(status = virtual_map_ntdll( fd, &module ))) - add_builtin_module( module, NULL, &st ); - close( fd ); - } - else - { - free( name ); - name = build_path( dll_dir, "ntdll.dll.so" ); - status = dlopen_dll( name, &module ); - } + name[strlen(name) - 3] = 0; /* remove .so */ + status = open_builtin_file( name, &module, &info ); if (status) fatal_error( "failed to load %s error %x\n", name, status ); free( name ); load_ntdll_functions( module ); diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h index 88a726d2445..f99c13fe2ad 100644 --- a/dlls/ntdll/unix/unix_private.h +++ b/dlls/ntdll/unix/unix_private.h @@ -177,7 +177,6 @@ extern NTSTATUS alloc_object_attributes( const OBJECT_ATTRIBUTES *attr, struct o extern void *anon_mmap_fixed( void *start, size_t size, int prot, int flags ) DECLSPEC_HIDDEN; extern void *anon_mmap_alloc( size_t size, int prot ) DECLSPEC_HIDDEN; extern void virtual_init(void) DECLSPEC_HIDDEN; -extern NTSTATUS virtual_map_ntdll( int fd, void **module ) DECLSPEC_HIDDEN; extern ULONG_PTR get_system_affinity_mask(void) DECLSPEC_HIDDEN; extern void virtual_get_system_info( SYSTEM_BASIC_INFORMATION *info ) DECLSPEC_HIDDEN; extern NTSTATUS virtual_create_builtin_view( void *module ) DECLSPEC_HIDDEN; diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c index 336666c3582..d79e3de662e 100644 --- a/dlls/ntdll/unix/virtual.c +++ b/dlls/ntdll/unix/virtual.c @@ -2436,56 +2436,6 @@ void virtual_init(void) } -/*********************************************************************** - * virtual_map_ntdll - * - * Map ntdll, used instead of virtual_map_section() because some things are not initialized yet. - */ -NTSTATUS virtual_map_ntdll( int fd, void **module ) -{ - IMAGE_DOS_HEADER dos; - IMAGE_NT_HEADERS nt; - NTSTATUS status; - SIZE_T size; - void *base; - unsigned int vprot; - struct file_view *view; - - /* load the headers */ - - size = pread( fd, &dos, sizeof(dos), 0 ); - if (size < sizeof(dos)) return STATUS_INVALID_IMAGE_FORMAT; - if (dos.e_magic != IMAGE_DOS_SIGNATURE) return STATUS_INVALID_IMAGE_FORMAT; - - size = pread( fd, &nt, sizeof(nt), dos.e_lfanew ); - if (size < sizeof(nt)) return STATUS_INVALID_IMAGE_PROTECT; - if (nt.Signature != IMAGE_NT_SIGNATURE) return STATUS_INVALID_IMAGE_FORMAT; - if (nt.OptionalHeader.Magic != IMAGE_NT_OPTIONAL_HDR_MAGIC) return STATUS_INVALID_IMAGE_FORMAT; -#ifdef __i386__ - if (nt.FileHeader.Machine != IMAGE_FILE_MACHINE_I386) return STATUS_INVALID_IMAGE_FORMAT; -#elif defined(__x86_64__) - if (nt.FileHeader.Machine != IMAGE_FILE_MACHINE_AMD64) return STATUS_INVALID_IMAGE_FORMAT; -#elif defined(__arm__) - if (nt.FileHeader.Machine != IMAGE_FILE_MACHINE_ARM && - nt.FileHeader.Machine != IMAGE_FILE_MACHINE_THUMB && - nt.FileHeader.Machine != IMAGE_FILE_MACHINE_ARMNT) return STATUS_INVALID_IMAGE_FORMAT; -#elif defined(__aarch64__) - if (nt.FileHeader.Machine != IMAGE_FILE_MACHINE_ARM64) return STATUS_INVALID_IMAGE_FORMAT; -#endif - - base = (void *)nt.OptionalHeader.ImageBase; - size = ROUND_SIZE( 0, nt.OptionalHeader.SizeOfImage ); - vprot = SEC_IMAGE | SEC_FILE | VPROT_COMMITTED | VPROT_READ | VPROT_EXEC | VPROT_WRITECOPY; - - status = map_view( &view, base, size, FALSE, vprot, 0 ); - if (status == STATUS_CONFLICTING_ADDRESSES) - ERR( "couldn't load ntdll at preferred address %p\n", base ); - if (status) return status; - *module = view->base; - return map_image_into_view( view, fd, base, nt.OptionalHeader.SizeOfHeaders, 0, -1, FALSE ); -} - - /*********************************************************************** * get_system_affinity_mask */