From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 128063 invoked by alias); 10 May 2017 20:23:42 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 128049 invoked by uid 89); 10 May 2017 20:23:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.8 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-qt0-f177.google.com Received: from mail-qt0-f177.google.com (HELO mail-qt0-f177.google.com) (209.85.216.177) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 10 May 2017 20:23:39 +0000 Received: by mail-qt0-f177.google.com with SMTP id n4so2040339qte.2 for ; Wed, 10 May 2017 13:23:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=l2dje5H6geJ3XWazDD8UDyWmMFoGrKs6lgvBgkpJpdQ=; b=s3oie0Apeq5ftnuW0Th1zg6YbtPzjGq188P+Ue11RXg70yzWTjC+uc0PY07DfQ8BRy LeUZlmmq8531T91jD0cCtg9x1hNk6yhxhalTIYqicqpGXB6AAztXR5r7ZYjxvSj2+DdM rYI+2HRpk0YbsIOafYsjRuVV7kEEkpXIo5LjdWmpsOJMvwc/drbRheCq27H+eyAstVJW 3qCInLLGA8iDA+SivcOCv+gVa/VkotEighlb4m3+f7cwBc9oCHgFlJYoQYrdEHhK29Yc K9MW3UWpf25L8jCaOOoIjJgVIGxxTBKuvlD1kq9igdUupVKraRM2xW0hI1bYjOgo03s2 ygUQ== X-Gm-Message-State: AODbwcD+/V43tw47ecQFZ2nu9VGlv6fG8zPIaoKf2YvwyZqiK4qss3FO GD2G7msBMHLDBJEX2ohelw== X-Received: by 10.237.60.77 with SMTP id u13mr403618qte.18.1494447819921; Wed, 10 May 2017 13:23:39 -0700 (PDT) Received: from localhost.localdomain ([179.159.39.92]) by smtp.googlemail.com with ESMTPSA id p89sm6703qkl.34.2017.05.10.13.23.38 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 10 May 2017 13:23:39 -0700 (PDT) From: Adhemerval Zanella To: gcc-patches@gcc.gnu.org Subject: [PATCH] sparc: Set noexecstack on mulsi3, divsi3, and modsi3 Date: Wed, 10 May 2017 20:27:00 -0000 Message-Id: <1494447812-11286-1-git-send-email-adhemerval.zanella@linaro.org> X-IsSubscribed: yes X-SW-Source: 2017-05/txt/msg00825.txt.bz2 A recent GLIBC fix for sparc [1] made some configuration to show an executable stack on ld.so (shown on elf/check-execstack testcase failure). It is because with generated sparc toolchain from build-many-glibcs.py (a GLIBC script to produce cross-compiling toolchains) the minimum supported sparc32 version is pre-v9 and it requires a software implementation of '.udiv'. Since now we are using libgcc.a one instead, it must have the '.note.GNU-stack' so linker can properly set the stack non executable. >From a build using a toolchain from build-many-glibcs.py: elf/librtld.os.map [...] .../sparc64-glibc-linux-gnu/6.2.1/32/libgcc.a(_divsi3.o) .../sparc64-glibc-linux-gnu/6.2.1/32/libgcc.a(_udivdi3.o) (.udiv) .../sparc64-glibc-linux-gnu/6.2.1/32/libgcc.a(_clz.o) .../lib/gcc/sparc64-glibc-linux-gnu/6.2.1/32/libgcc.a(_udivdi3.o) (__clz_tab) [...] And dumping _udivdi3.o section headers: [Nr] Name Type Addr Off Size ES Flg Lk Inf Al [ 0] NULL 00000000 000000 000000 00 0 0 0 [ 1] .text PROGBITS 00000000 000034 0002b0 00 AX 0 0 4 [ 2] .data PROGBITS 00000000 0002e4 000000 00 WA 0 0 1 [ 3] .bss NOBITS 00000000 0002e4 000000 00 WA 0 0 1 [ 4] .debug_line PROGBITS 00000000 0002e4 00010d 00 0 0 1 [ 5] .rela.debug_line RELA 00000000 0007c0 00000c 0c I 12 4 4 [ 6] .debug_info PROGBITS 00000000 0003f1 0000ab 00 0 0 1 [ 7] .rela.debug_info RELA 00000000 0007cc 000030 0c I 12 6 4 [ 8] .debug_abbrev PROGBITS 00000000 00049c 000014 00 0 0 1 [ 9] .debug_aranges PROGBITS 00000000 0004b0 000020 00 0 0 8 [10] .rela.debug_arang RELA 00000000 0007fc 000018 0c I 12 9 4 [11] .shstrtab STRTAB 00000000 000814 000070 00 0 0 1 [12] .symtab SYMTAB 00000000 0004d0 000220 10 13 32 4 [13] .strtab STRTAB 00000000 0006f0 0000cf 00 0 0 1 I am not seeing this on a native gcc build which I configured with: ' --with-arch-directory=sparc64 --enable-multiarch --enable-targets=all --with-cpu-32=ultrasparc --with-long-double-128 --enable-multilib' Both libgcc's __udivdi3 and __umoddi3 do not pull .udiv since for this libgcc build both are using hardware instructions: elf/librtld.os.map /home/azanella/gcc/install/lib/gcc/sparc64-linux-gnu/6.3.1/32/libgcc.a(_udivdi3.o) /home/azanella/glibc/glibc-git-build-sparcv9/elf/dl-allobjs.os (__udivdi3) /home/azanella/gcc/install/lib/gcc/sparc64-linux-gnu/6.3.1/32/libgcc.a(_umoddi3.o) /home/azanella/glibc/glibc-git-build-sparcv9/elf/dl-allobjs.os (__umoddi3) This patch adds them missing noexectack on sparc assembly implementation. I saw no regression on gcc testsuite and it fixes the regression on GLIBC side. libgcc/ * config/sparc/lb1spc.S [__ELF__ && __linux__]: Emit .note.GNU-stack section for a non-executable stack. [1] https://sourceware.org/git/?p=glibc.git;a=commit;h=bdc543e338281da051b3dc06eae96c330a485ce6 --- libgcc/ChangeLog | 5 +++++ libgcc/config/sparc/lb1spc.S | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/libgcc/config/sparc/lb1spc.S b/libgcc/config/sparc/lb1spc.S index b60bd57..e693864 100644 --- a/libgcc/config/sparc/lb1spc.S +++ b/libgcc/config/sparc/lb1spc.S @@ -5,6 +5,12 @@ slightly edited to match the desired calling convention, and also to optimize them for our purposes. */ +/* An executable stack is *not* required for these functions. */ +#if defined(__ELF__) && defined(__linux__) +.section .note.GNU-stack,"",%progbits +.previous +#endif + #ifdef L_mulsi3 .text .align 4 -- 2.7.4