From patchwork Mon May 23 14:31:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Brodkin X-Patchwork-Id: 625218 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rD1GJ4GWdz9sCY for ; Tue, 24 May 2016 00:32:22 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id D8B063335A; Mon, 23 May 2016 14:32:20 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7uEeAmuwSWgk; Mon, 23 May 2016 14:32:19 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id CFA8B33346; Mon, 23 May 2016 14:32:18 +0000 (UTC) X-Original-To: uclibc@lists.busybox.net Delivered-To: uclibc@osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 4841C1C29BF for ; Mon, 23 May 2016 14:32:17 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 452B1A66AD for ; Mon, 23 May 2016 14:32:17 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2IGs7SKHLgb7 for ; Mon, 23 May 2016 14:32:16 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from smtprelay.synopsys.com (smtprelay.synopsys.com [198.182.47.9]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 178EEA66E1 for ; Mon, 23 May 2016 14:32:15 +0000 (UTC) Received: from dc8secmta2.synopsys.com (dc8secmta2.synopsys.com [10.13.218.202]) by smtprelay.synopsys.com (Postfix) with ESMTP id 2B32C24E16C4; Mon, 23 May 2016 07:32:15 -0700 (PDT) Received: from dc8secmta2.internal.synopsys.com (dc8secmta2.internal.synopsys.com [127.0.0.1]) by dc8secmta2.internal.synopsys.com (Service) with ESMTP id 0E35AA4119; Mon, 23 May 2016 07:32:15 -0700 (PDT) Received: from mailhost.synopsys.com (mailhost1.synopsys.com [10.12.238.239]) by dc8secmta2.internal.synopsys.com (Service) with ESMTP id DAFD2A4118; Mon, 23 May 2016 07:32:14 -0700 (PDT) Received: from mailhost.synopsys.com (localhost [127.0.0.1]) by mailhost.synopsys.com (Postfix) with ESMTP id C5E196CD; Mon, 23 May 2016 07:32:14 -0700 (PDT) Received: from abrodkin-7440l.internal.synopsys.com (unknown [10.121.8.125]) by mailhost.synopsys.com (Postfix) with ESMTP id 232C86B4; Mon, 23 May 2016 07:32:12 -0700 (PDT) From: Alexey Brodkin To: devel@uclibc-ng.org Subject: [PATCH] ldso: Force disable -mlong-calls when compiling ldso for ARC Date: Mon, 23 May 2016 17:31:38 +0300 Message-Id: <1464013898-27459-1-git-send-email-abrodkin@synopsys.com> X-Mailer: git-send-email 2.5.5 Cc: uclibc@uclibc.org, Vineet Gupta , Alexey Brodkin , linux-snps-arc@lists.infradead.org X-BeenThere: uclibc@uclibc.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "Discussion and development of uClibc \(the embedded C library\)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: uclibc-bounces@uclibc.org Sender: "uClibc" Even though by default for ARC uClibc gets compiled with disabled long-calls user may provide UCLIBC_EXTRA_CFLAGS with "-mlong-calls". With this option uClibc will be successfully compiled but later it will fail in runtime because dynamic loader cannot deal with relocations at least very early on its start. In particular it will be seen as call to non-relocated symbol _dl_parse_dynamic_info() which ends-up as a segfault like this: ------------------------>8-------------------- potentially unexpected fatal signal 11. Path: /bin/test CPU: 0 PID: 63 Comm: test Not tainted 4.5.2 #7 task: 9f13f180 ti: 9f166000 task.ti: 9f166000 [ECR ]: 0x00040000 => Insn could not be fetched [EFA ]: 0x0000283c [BLINK ]: 0x2000407c [ERET ]: 0x283c @No matching VMA found [STAT32]: 0x8008009e : IE U BTA: 0x0000283c SP: 0x5fef5ccc FP: 0x00000000 LPS: 0x20004080 LPE: 0x20004064 LPC: 0x00000000 r00: 0x20006684 r01: 0x5fef5db0 r02: 0x00000000 r03: 0x20000000 r04: 0x80808080 r05: 0x2f2f2f2f r06: 0x41464d00 r07: 0x00000080 r08: 0x000000dd r09: 0x00000000 r10: 0x00000073 r11: 0x80808080 r12: 0x2000407c r13: 0x20000000 r14: 0x5fef5e74 r15: 0x000ceb3c r16: 0x5fef5e7c r17: 0x5fef5d44 r18: 0x000ceb0c r19: 0xffffffff r20: 0x000ceb1c r21: 0x00000000 r22: 0x00000000 r23: 0x000d08a5 r24: 0x00000000 r25: 0x80808080 Segmentation fault ------------------------>8-------------------- Solution to this issue is simple we make sure dynamic loader never gets compiled with "-mlong-calls" by forcing "-mno-long-calls" on it. Signed-off-by: Alexey Brodkin Cc: Vineet Gupta Cc: Anton Kolesov Cc: linux-snps-arc@lists.infradead.org --- ldso/ldso/Makefile.in | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ldso/ldso/Makefile.in b/ldso/ldso/Makefile.in index d85646a..dde6a53 100644 --- a/ldso/ldso/Makefile.in +++ b/ldso/ldso/Makefile.in @@ -34,6 +34,10 @@ CFLAGS-$(DODEBUG)-ldso/ldso := -O2 -g CFLAGS-ldso.c := -DLDSO_ELFINTERP=\"$(TARGET_ARCH)/elfinterp.c\" +ifeq ($(TARGET_ARCH),arc) +CFLAGS-ldso.c += -mno-long-calls +endif + LDFLAGS-$(UCLIBC_FORMAT_DSBT_ELF)-$(UCLIBC_LDSO_NAME).so := -Wl,--dsbt-index=1 ifneq ($(SUPPORT_LD_DEBUG),y) LDFLAGS-$(UCLIBC_LDSO_NAME).so := $(LDFLAGS)