delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2017/09/08/19:22:42

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:mime-version:in-reply-to:references:from:date
:message-id:subject:to:content-type; q=dns; s=default; b=jeuydpw
nTHn4ck1T7AfH/unNRqE3A23oiaRfMq+ye8mgeIZ50A105CCHXMMr5iGaHWEo8hs
rWI/VRWZCY9mmjr99e+jCQbHqfJlphgbV9SC3PgVwc4GmccpzMTzmOxc7N2dCHUO
bWqn2Zfj+dszeGL/BOvNm8FQuQp3B8HWd8K4=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:mime-version:in-reply-to:references:from:date
:message-id:subject:to:content-type; s=default; bh=m85nwJF2Lfup/
zaGtQba2zjScRQ=; b=nVbMXTU7oESDNqXi+7B1KBggbqsAonaTr0xMdMqEtOwoe
KCvWLK6cpAApxlfsd6etI/brwYnxwhIKjICKX09by5Fy2Tsq/0Z2ItXlK4zdtJwa
/3+l5cbB0BtyG8Xrtr1n3rW3H54mxq1UV0Ch8X/73Ij0KtgAdFQ6JUHcrvNW6o=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-5.6 required=5.0 tests=AWL,BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,GIT_PATCH_2,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:2353
X-HELO: mail-it0-f41.google.com
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=YXAMlreUBcfp4KEszlsW5lvTTS5uhrSdAQ61ee6Sp3o=; b=W0khILyrBJuNdD1e8THCTHri749MZYHsE6fGAO25tgzgvz88qX/nm8+xsmSqx+SXn4 EYpCHHCy7SGW/iLMvPUlbhUhhLhGVTB33cMCRHLxr4Rtf8ciBcZ+azuAUONBEpRGaIJv gRCLQje7Uy9KzPx0aoYbFWidDG19s3uVz2jO/u1qoxIqCFhvX+ld5DjcV7uiDHk0xmn6 E9nyC/HcvLdvoHziX9mJmC7Uz6b8+kZIkA843RfUnyik6jg4aNuiSXhKgXDU8lE4c1T9 5SzYayINHDaiXxGqZP2oo/sSQmrFThVfeAXzJOEGd8/8/r7d847Hb6nqdNqNTVkOEyG0 WV5w==
X-Gm-Message-State: AHPjjUhYTLr3WASqwmiIfi4GRyHyjdWiP3KiUEeAIrCRy2nhp3UUvVvU oyCLdwCiyRbNRxe523cBw2pe71nKtKC19xHFypU=
X-Google-Smtp-Source: AOwi7QBpf90MRahLuefZdR8VkBlncN0ssVb2dZ3laeQxeALPaiouZXW/awKdGPwOfpWtYOXaX/mn0TdeV4BV7TuAbNo=
X-Received: by 10.36.121.85 with SMTP id z82mr3110722itc.87.1504912947912; Fri, 08 Sep 2017 16:22:27 -0700 (PDT)
MIME-Version: 1.0
In-Reply-To: <59b3214a.d049ca0a.cd021.98bd@mx.google.com>
References: <CAD8GWsusnJQk_Z42o966BUwaFHedZ4xnEvBC7AcEtWe=K0ioKg AT mail DOT gmail DOT com> <59b3214a DOT d049ca0a DOT cd021 DOT 98bd AT mx DOT google DOT com>
From: Lee <ler762 AT gmail DOT com>
Date: Fri, 8 Sep 2017 19:22:27 -0400
Message-ID: <CAD8GWsuHD6XaXwe6u5KRa4771Siizo_L+wB30oHyHYEurqrJpQ@mail.gmail.com>
Subject: Re: i686-w64-mingw32-gcc -fstack-protector-strong
To: cygwin AT cygwin DOT com
X-IsSubscribed: yes

On 9/8/17, Steven Penny <svnpenn AT gmail DOT 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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019