POLINK errors and vs2005

Everything else that doesn't fall into one of the other PB categories.
jack
Addict
Addict
Posts: 1358
Joined: Fri Apr 25, 2003 11:10 pm

POLINK errors and vs2005

Post by jack »

I just started to explore Visual studio 2005 by compiling a lib and then trying to use the lib in PB, but got some unresolved symbols
POLINK: error: Unresolved external symbol '__security_cookie'
POLINK: error: Unresolved external symbol '@__security_check_cookie'
POLINK: error: Unresolved external symbol '__alloca_probe_16'
the first two unresolved symbols can be solved by linking to bufferoverflowU.lib see http://blogs.msdn.com/nikolad/archive/2 ... 62214.aspx

__alloca_probe_16 seems a bit more difficult, but found the answer here

http://www.interopsystems.com/tools/tm.aspx?m=7904
jerker_back wrote: my mistake - there is some magic about _alloca. It's there as is _alloca__probe, but not

_alloca_probe_8 and _alloca_probe_16.

So I made a new source file as this from alloca16.asm:
alloca_probe.cpp

Code: Select all

extern "C" void _chkstk();

//_alloca_probe_16 : 16 byte aligned alloca
extern "C" void _alloca_probe_16()
{
	__asm 
	{
		push    ecx
		lea     ecx, [esp] + 8          ; TOS before entering this function
		sub     ecx, eax                ; New TOS
		and     ecx, (16 - 1)           ; Distance from 16 bit align (align down)
		add     eax, ecx                ; Increase allocation size
		sbb     ecx, ecx                ; ecx = 0xFFFFFFFF if size wrapped around
		or      eax, ecx                ; cap allocation size on wraparound
		pop     ecx                     ; Restore ecx
		jmp     _chkstk
	}
}

//alloca_8: 8 byte aligned alloca
extern "C" void _alloca_probe_8()
{
	__asm 
	{
		push    ecx
		lea     ecx, [esp] + 8          ; TOS before entering this function
		sub     ecx, eax                ; New TOS
		and     ecx, (8 - 1)            ; Distance from 8 bit align (align down)
		add     eax, ecx                ; Increase allocation Size
		sbb     ecx, ecx                ; ecx = 0xFFFFFFFF if size wrapped around
		or      eax, ecx                ; cap allocation size on wraparound
		pop     ecx                     ; Restore ecx
		jmp     _chkstk
	}
}
I had to remove the "C" but after that everything worked, however there's about 40k size increase by linking-in with the bufferoverflowU.lib

I am posting this just in case someone else runs into the same problems.
inc.
Enthusiast
Enthusiast
Posts: 406
Joined: Thu May 06, 2004 4:28 pm
Location: Cologne/GER

Post by inc. »

When generating libs using VS2005 also just try linking with the msvcrt.lib "coming with VS2005" and the unres.symbols do disappear.

BUT youll prpably end up in C runtime linking- or manifest- errors when using XP.
I also tried VS2005 some time ago, final PB compiles worked fine on Win2000 SP4 but on WinXP Sp2 the Problems mentioned above did occur.

Look at this thread: http://www.purebasic.fr/english/viewtop ... c&start=15
My quintessence: If building libs for PB purposes, VS2005 is out of my list, but in case of building dlls its very good.
If you wanna build libs for PB purposes using free C++ Environments then you should go for DevC++ or if your code needs a microsoft compiler then the older free VC++2003 Toolkit CLI compiler is a nice choice.
Check out OOP support for PB here!
Post Reply