E:\DJGPP\C>gcc -Wall -fstack-protector -o pokus.exe pokus.c
e:/djgpp/bin/ld.exe: cannot find -lssp_nonshared
collect2: ld returned 1 exit status
Obviously, you need the libssp_noshared.a library to be available to
the linker, for this to work.
I don't have 4.4.1 installed on this computer, but it *seems* to be
present. But I don't know if it actually works or not.
http://www.delorie.com/djgpp/dl/ofc/current/v2gnu/gcc441b.zip/
8,002 07-25-09 11:00 lib/libssp.a
908 07-25-09 09:43 lib/libssp.la
610 07-25-09 11:00 lib/libssp_nonshared.a
939 07-25-09 09:43 lib/libssp_nonshared.la
It is not difficult to compile it together with GCC. I do not however know whether
it works.
Andris
Here's result with standard compiling:
Exiting due to signal SIGSEGV
Stack Fault at eip=000016d9
eax=00000000 ebx=0000029e ecx=30580000 edx=00000035 esi=00000054
edi=0001266c
ebp=266c0009 esp=3057fffc program=C:\DJGPP\C\HEAD.EXE
cs: sel=01a7 base=029e0000 limit=0009ffff
ds: sel=01af base=029e0000 limit=0009ffff
es: sel=01af base=029e0000 limit=0009ffff
fs: sel=017f base=00005c20 limit=0000ffff
gs: sel=01bf base=00000000 limit=0010ffff
ss: sel=01af base=029e0000 limit=0009ffff
App stack: [00092668..0001266c] Exceptn stack: [000125ac..0001066c]
Call frame traceback EIPs:
0x000016d9
and here with SSP enabled:
*** stack smashing detected ***: terminated
Exiting due to signal SIGILL
Invalid Opcode at eip=000017a4
eax=00000000 ebx=00000000 ecx=0001505c edx=0009a8a8 esi=00099970
edi=00000005
ebp=000999e8 esp=00099970 program=C:\DJGPP\C\HEAD.EXE
cs: sel=01a7 base=029e0000 limit=0009ffff
ds: sel=01af base=029e0000 limit=0009ffff
es: sel=01af base=029e0000 limit=0009ffff
fs: sel=017f base=00005c20 limit=0000ffff
gs: sel=01bf base=00000000 limit=0010ffff
ss: sel=01af base=029e0000 limit=0009ffff
App stack: [00099a68..00019a68] Exceptn stack: [00019978..00017a38]
Call frame traceback EIPs:
0x000017a4
0x00001617
0x000016e9
0x0000332f
Now in this simple case it seems that standard memory protection is
enough to detect a problem..
int pokus(int x)
{
char buffer[10];
int moo=0x55AA;
buffer[10]='J';
return(x+moo);
}
int main()
{
pokus(1);
return(0);
}