This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: i686-w64-mingw32-gcc -fstack-protector-strong
- From: Lee <ler762 at gmail dot com>
- To: cygwin at cygwin dot com
- Date: Fri, 8 Sep 2017 19:22:27 -0400
- Subject: Re: i686-w64-mingw32-gcc -fstack-protector-strong
- Authentication-results: sourceware.org; auth=none
- References: <CAD8GWsusnJQk_Z42o966BUwaFHedZ4xnEvBC7AcEtWe=K0ioKg@mail.gmail.com> <59b3214a.d049ca0a.cd021.98bd@mx.google.com>
On 9/8/17, Steven Penny <svnpenn@gmail.com> wrote:
> On Fri, 8 Sep 2017 10:14:54, Lee wrote:
>> $ i686-w64-mingw32-gcc -o div.exe div.c
>> $ ./div
>> works
>>
>> $ i686-w64-mingw32-gcc -fstack-protector-strong -o div.exe div.c
>> $ ./div
>> C:/cygwin/home/Lee/t/div.exe: error while loading shared libraries: ?:
>> cannot open shared object file: No such file or directory
>>
>> $ ldd div.exe
>> ntdll.dll => /cygdrive/c/WINDOWS/SYSTEM32/ntdll.dll
>> (0x7ffef5c50000)
>> ??? => ??? (0x778f0000)
>> wow64.dll => /cygdrive/c/WINDOWS/System32/wow64.dll (0x50e50000)
>> wow64win.dll => /cygdrive/c/WINDOWS/System32/wow64win.dll
>> (0x50dd0000)
>>
>> $ i686-w64-mingw32-gcc --version
>> i686-w64-mingw32-gcc (GCC) 5.4.0
>
> You need to paste or link to div.c, otherwise this seems a pointless
> exercise.
> See, I cannot repro:
>
> $ cat div.c
> #include <stdio.h>
> int main() {
> puts("hello world");
> }
man gcc
-fstack-protector
Emit extra code to check for buffer overflows, such as
stack smashing attacks. This is done by adding a guard
variable to functions with vulnerable objects. This
includes functions that call "alloca", and functions with
buffers larger than 8 bytes. The guards are initialized
when a function is entered and then checked when the
function exits. If a guard check fails, an error message
is printed and the program exits.
-fstack-protector-all
Like -fstack-protector except that all functions are protected.
-fstack-protector-strong
Like -fstack-protector but includes additional functions to
be protected --- those that have local array definitions,
or have references to local frame addresses.
I maybe should have used -fstack-protector-all, but I'm still learning :)
> $ x86_64-w64-mingw32-gcc -o div div.c
> $ ./div
> hello world
>
> $ x86_64-w64-mingw32-gcc -fstack-protector-strong -o div div.c
> $ ./div
> hello world
>
> $ ldd div
> ntdll.dll => /cygdrive/c/Windows/SYSTEM32/ntdll.dll (0x773a0000)
> kernel32.dll => /cygdrive/c/Windows/system32/kernel32.dll (0x77180000)
> KERNELBASE.dll => /cygdrive/c/Windows/system32/KERNELBASE.dll
> (0x7fefd1a0000)
> msvcrt.dll => /cygdrive/c/Windows/system32/msvcrt.dll (0x7fefde00000)
note libssp-0 (or ???) isn't mentioned
you don't have any user defined functions, so it got optimized
out/never called??
Thanks
Lee
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple