From patchwork Wed May 10 20:23:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 99020 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp409369qge; Wed, 10 May 2017 13:23:59 -0700 (PDT) X-Received: by 10.99.102.7 with SMTP id a7mr8250819pgc.216.1494447839917; Wed, 10 May 2017 13:23:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1494447839; cv=none; d=google.com; s=arc-20160816; b=O4QAS5ssVnOPYg+zrZXbLa6QJUdEXn+SMdEMc9NoBCd+CVvoO/lpaezNEmusabrReU 5o1kGWlVY7Pqvz8Kerzl8tmU4Xb6VDO9K6vqQ+/H1WeASQBMuxBScLQlt9JNJzzV6uur /k817sJR8x/EGxFQWw3zXnktXAofXlc4uwm5XC50f9yVW8vFtLr7lzDU01CspO/wvFoK ec0Ru52stkiapmxrcwpLsz+prjiUOwfhZ2/1gNj/Le8Xr2jj0Bd4YTcz5vrkzE+b35fS Td4ZpVHcXnG64gpyTJ+r55vKhH0Fi+ZI6QDio+ZTxbzUyYTbKrp4DztEHngFTHnlq1om 6riw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:to:from:delivered-to:sender:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=l2dje5H6geJ3XWazDD8UDyWmMFoGrKs6lgvBgkpJpdQ=; b=bEEqyxAHF37vev2L/y4aW60790cky9xNG8MyTViQOvsmCu1shlc+5RZjjqdbkL4Pje TmnrkyvO2+q1a2/9RTZOkq7AWB/seVaMPKRPzwsOf6njk3mQM1IYrXtxyasau7o/UdFx NTNxcN23y8S0ylqMChh+j3CsfXvh1syu9Tqhu9V0EYcstQSLpFmiMRwlwtWH0QyBJnj4 huE/Lw4iQdRba0AyUx374rxPWErChVyxMpjlSXpkbk62G2b7QxPwlJ+qnTehcBL2HEGM M9BTZRt9rp0kQbukYi4EzRTiQ8AOeE4J6wwQDYHjwgPxKxvs3khM5RiRe3MdaWqn3fzM /RRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-453315-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-453315-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id e9si4027569pfj.365.2017.05.10.13.23.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 May 2017 13:23:59 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-453315-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-453315-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-453315-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id; q=dns; s=default; b=V1frudeIquw+P+S a7Nd0SciTaVbJXhVwbRhGVJeTdxsPAx53spF3jcUhZpHEESjhZ+iDt/9VWHMJY5g yrMjSse9SNQ8NbeDcSy+hsvVIZ7ZmO9VS0M6BjPbdyKDMdkrZ+yoPypMWC8mpXzs LrTrJr/TW09ND6xKGMDI+Jf1OOK4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id; s=default; bh=iaCRXyrc7AOKjc5Haepge nSF4Wc=; b=c4VulRdnOxTbly5qIdiXQIUBklDEuhhHgNkATwV81Lk2M9YIVbFzG UUdm/tLjCrK137hD3qF3WGLW+hsut/fdGDmcR9WzvUa73kVDqZ8q4kuRyi7X/xLN sQDfm7PWTdiwF3RLQGl0oteqCTLxlv7fLLXhxRmoDnkknoA34fMpnI= 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-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@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 17:23:32 -0300 Message-Id: <1494447812-11286-1-git-send-email-adhemerval.zanella@linaro.org> X-IsSubscribed: yes 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(+) -- 2.7.4 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