Make LdrAccessResource Call an Internal Function to Satisfy Shrinker

Robert Shearman rob at codeweavers.com
Tue Nov 1 23:36:30 CST 2005


Dmitry Timoshkov wrote:

>"Robert Shearman" <rob at codeweavers.com> wrote:
>
>  
>
>>-/**********************************************************************
>>- * LdrAccessResource  (NTDLL.@)
>>- */
>>-NTSTATUS WINAPI LdrAccessResource( HMODULE hmod, const IMAGE_RESOURCE_DATA_ENTRY *entry,
>>-                                   void **ptr, ULONG *size )
>>+/* don't penalize other platforms stuff needed on i386 for compatibility */
>>+#ifdef __i386__
>>+NTSTATUS WINAPI access_resource( HMODULE hmod, const IMAGE_RESOURCE_DATA_ENTRY *entry,
>>+                                 void **ptr, ULONG *size )
>>+#else
>>+static inline NTSTATUS access_resource( HMODULE hmod, const IMAGE_RESOURCE_DATA_ENTRY *entry,
>>+                                        void **ptr, ULONG *size )
>>+#endif
>> {
>>     NTSTATUS status;
>> 
>>@@ -355,6 +358,30 @@ NTSTATUS WINAPI LdrAccessResource( HMODU
>>     return status;
>> }
>> 
>>+/**********************************************************************
>>+ * LdrAccessResource  (NTDLL.@)
>>+ */
>>+#ifdef __i386__
>>+/* Shrinker depends on the "call access_resource" instruction being there */
>>+__ASM_GLOBAL_FUNC( LdrAccessResource,
>>+    "pushl %ebp\n"
>>+    "movl %esp, %ebp\n"
>>+    "pushl 24(%ebp)\n"
>>+    "pushl 20(%ebp)\n"
>>+    "pushl 16(%ebp)\n"
>>+    "pushl 12(%ebp)\n"
>>+    "pushl 8(%ebp)\n"
>>+    "call access_resource\n"
>>+    "leave\n"
>>+    "ret\n"
>>+);
>>+#else
>>+NTSTATUS WINAPI LdrAccessResource( HMODULE hmod, const IMAGE_RESOURCE_DATA_ENTRY *entry,
>>+                                   void **ptr, ULONG *size )
>>+{
>>+    return access_resource( hmod, entry, ptr, size );
>>+}
>>+#endif
>>    
>>
>
>Shouldn't be enough for the __i386__ case just omitting 'inline' in access_resource
>definition?
>

No. Marcus already discovered with the previous version of 
EXC_CallHandler using the "-funit-at-a-time" option that the compiler 
can re-order the arguments and generally do whatever it wants if we hint 
that it won't be used outside of the module. The compiler is also free 
to generate LdrAccessResource as a simple jump to access_resource, or 
even to just make access_resource point to the same address as 
LdrAccessResource. In short, the only sure way of generating code that 
Shrinker needs is to do it explicitly.

-- 
Rob Shearman




More information about the wine-devel mailing list