digitalmars.D.bugs - [Issue 12085] New: PIC code on X86 should use thunk to get PC
- d-bugmail puremagic.com (35/35) Feb 05 2014 https://d.puremagic.com/issues/show_bug.cgi?id=12085
https://d.puremagic.com/issues/show_bug.cgi?id=12085 Summary: PIC code on X86 should use thunk to get PC Product: D Version: unspecified Platform: x86 OS/Version: Linux Status: NEW Keywords: dll Severity: enhancement Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: code dawg.eu If one looks at GCC output of PIC code they use a small function to obtain the PC, like so. __x86.get_pc_thunk.bx LABEL NEAR mov ebx, dword ptr [esp] ; 0430 _ 8B. 1C 24 ret ; 0433 _ C3 Then the thunk is called to get the PC into EBX. call __x86.get_pc_thunk.bx ; 0444 _ E8, FFFFFFE7 What we currently do looks like this. push ebx ; 0564 _ 53 call ?_014 ; 0565 _ E8, 00000000 ?_014 LABEL NEAR pop ebx ; 056A _ 5B This is suboptimal for two reasons, first we're wasting 2 bytes per call for the push and pop of ebx, second we invalidate the return stack buffer for each of these calls, because there is no matching return. I suggest to switch to the same technique that GCC is using. We could even use the exact same naming so that the thunks produced by GCC for C code and dmd for D code could be merged at link time. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 05 2014