Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Does DJGPP GCC support SSP stack protection?

7 views
Skip to first unread message

RayeR

unread,
Oct 2, 2009, 7:10:08 PM10/2/09
to
I mean compiler options:
-fstack-protector
-fstack-protector-all
-fno-stack-protector
It seems to be recognized (currently using 4.4.1) but linker says an
error:

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

Eli Zaretskii

unread,
Oct 3, 2009, 4:41:03 AM10/3/09
to dj...@delorie.com
> From: RayeR <gl...@centrum.cz>
> Date: Fri, 2 Oct 2009 16:10:08 -0700 (PDT)

Obviously, you need the libssp_noshared.a library to be available to
the linker, for this to work.

Rugxulo

unread,
Oct 20, 2009, 1:24:30 PM10/20/09
to
Hi,

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

Andris Pavenis

unread,
Oct 20, 2009, 3:57:37 PM10/20/09
to dj...@delorie.com

It is not difficult to compile it together with GCC. I do not however know whether
it works.

Andris

RayeR

unread,
Dec 4, 2009, 7:03:30 AM12/4/09
to
Yeah,
I just need "-lssp" arg to gcc to link libssp.a
so now compiled with
gcc -Wall -fstack-protector -o head.exe head.c -lssp
is OK. I tried to jamm the stack little bit.

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..

RayeR

unread,
Dec 4, 2009, 7:08:05 AM12/4/09
to
Well here's an example that standard memory protection will not catch
but SSP will.
I think it is a good think for debugging.

int pokus(int x)
{
char buffer[10];
int moo=0x55AA;
buffer[10]='J';
return(x+moo);
}

int main()
{
pokus(1);
return(0);
}

0 new messages