From patchwork Thu Nov 21 02:10:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sandra Loosemore X-Patchwork-Id: 36081 Received: (qmail 103145 invoked by alias); 21 Nov 2019 02:11:09 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 103132 invoked by uid 89); 21 Nov 2019 02:11:09 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy=sk:fasynch, handwritten X-HELO: esa1.mentor.iphmx.com IronPort-SDR: u4z/sQ5oroirgIpuIagKdtvgif2dGb8yhdopA32YB5ppJCIXeR6GT8NuXxbS6XrXhxCr2AvoUf WV39ovkuLwtEmB++mS4518pUwl2y0gvfyJBEkHK6br/ge6OYrJC/b2dxLbvSOu5tfujZSFudSy DLNE0Gvk1rRsvrlfOkYE3avaVZO9uKRGiPT+zdnjXmXjbXCtYrjhqNCUl8dQcGJ5UlfBM7BAXd TBZC5aVOZBH5U8yx2jFG6USakJVkasO8YTCIx6QzC11Iha5F1AsJF3uHzQSezqQzVmxgNr8yBV ndk= IronPort-SDR: tjw5GjVndHsNHWnnbxpZaK4cKhd4n6uyMSDtdtZVw7iaSmImOTlgXNvXCeZfOxe26RrGRMz5yy 3MNSwbase4CiuUYE3Xg+4DUMylnRM5G7c/jO9hvf6KbmIizMc7z2uhnGzovL5wvBxBIT1LTFXF HgJkJXzdXINYYPeeudMLHUk3ouudAwQTxa36Kewu0FAdue+UrS+j6ZyCRo7YRj5BKm82h0S4ky +FCqjY4boGi5XgihgZtnJCCaiTxFtmnn5XOCTn4X4B6Ip1xEZIfNf9zWjkNraX+j/YzfBpyU02 qUg= From: Sandra Loosemore To: Subject: [PATCH] Compile elf/rtld.c with -fno-tree-loop-distribute-patterns. Date: Wed, 20 Nov 2019 19:10:40 -0700 Message-ID: <20191121021040.14554-1-sandra@codesourcery.com> MIME-Version: 1.0 Return-Path: sandra@codesourcery.com In GCC 10, the default at -O2 is now -ftree-loop-distribute-patterns. This optimization causes GCC to "helpfully" convert the hand-written loop in _dl_start into a call to memset, which is not available that early in program startup. Similar problems in other places in GLIBC have been addressed by explicitly building with -fno-tree-loop-distribute-patterns, but this one may have been overlooked previously because it only affects targets where HAVE_BUILTIN_MEMSET is not defined. This patch fixes a bug observed on nios2-linux-gnu target that caused all programs to segv on startup. --- elf/Makefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/elf/Makefile b/elf/Makefile index 0668818..b05af5c 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -65,6 +65,12 @@ CFLAGS-dl-runtime.c += -fexceptions -fasynchronous-unwind-tables CFLAGS-dl-lookup.c += -fexceptions -fasynchronous-unwind-tables CFLAGS-dl-iterate-phdr.c += $(uses-callbacks) +# On targets without __builtin_memset, rtld.c uses a hand-coded loop +# in _dl_start. Make sure this isn't turned into a call to regular memset. +ifeq (yes,$(have-loop-to-function)) +CFLAGS-rtld.c += -fno-tree-loop-distribute-patterns +endif + # Compile rtld itself without stack protection. # Also compile all routines in the static library that are elided from # the shared libc because they are in libc.a in the same way.