On 8/25/2013 16:06, dw wrote: > (Hopefully) I've got an easy question this time: Why doesn't feof() > (from stdio.h) use _CRTIMP? > > If there is no _CRTIMP (aka dllimport) on the definition for feof, you > get this when you call it: > > 402cef: call 402b90 <feof> > > Note that this does NOT call the import. Instead it calls this stub > which *then* calls the import: > > 0000000000402b90 <feof>: > 402b90: jmp QWORD PTR [rip+0x57b6] # 40834c <__imp_feof> > > Yes, this will work. But this unnecessary step is a waste of time.
This is how auto-dllimport works, address is not known at link time, so a stub is emitted to fill in that feof symbol. By right, the linker should be emitting a link error, but such workaround is to allow badly ported software to work on Windows. This includes the pseudo reloc hack to modify the IAT at runtime. It gets messier when data is involved, since you cannot put a forwarding stub for it like executable code. > Adding _CRTIMP calls the import directly: > > call QWORD PTR [rip+0x5657] # 40834c <__imp_feof> > The linker is not in the business of modifying instruction streams (or mistakes) emitted by the compiler. Its job is to fix up symbol addresses. Of course, the compiler can't do its job unless you give it all the information it needs. This is a good reason why you should always annotate your dllimport/dllexport code. > Is this intentional? Or a bug? > I'll leave this for Kai to decide whether to put in dllimport.
signature.asc
Description: OpenPGP digital signature
------------------------------------------------------------------------------ Introducing Performance Central, a new site from SourceForge and AppDynamics. Performance Central is your source for news, insights, analysis and resources for efficient Application Performance Management. Visit us today! http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
_______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
