From patchwork Sat May 16 13:53:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: develop--- via Libc-alpha X-Patchwork-Id: 39276 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C6FFA3840C2D; Sat, 16 May 2020 13:53:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C6FFA3840C2D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1589637227; bh=wOFzzPHn0n8RgZeAvLp0LPn4/G/vmHHorDpttf5b0lA=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=rQxjzXRMHzXdZIGu6xgphL10fO5N0CUBdEvyS2TBk9OzD1MO4bfcowbl9Y9WKcbuf XXgRnh7ZsErNXor5tTLjKdU609SFLlJvc+ampG8odQ5LDrelQPmEb3XAXwihJ5XjUg maGsaH/Rf83fgSh5dWqjLq0EJ9w065wBL985+mGs= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by sourceware.org (Postfix) with ESMTPS id 0E377386F442 for ; Sat, 16 May 2020 13:53:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 0E377386F442 Received: by mail-wr1-x443.google.com with SMTP id l18so6638107wrn.6 for ; Sat, 16 May 2020 06:53:45 -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:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=wOFzzPHn0n8RgZeAvLp0LPn4/G/vmHHorDpttf5b0lA=; b=Wx6hw5pghkNf1LYyK6YvEOI++Hu+kH4da9YGn19tbSdiVPKrgF+3w3B+j2Yep+K1rY LeVsMBFHyqsPGLSW+m5TjythIjnb+a/XGjBhXWDE/bxUoJlEiBBY7vfD6+NUELifubfJ MLoCQeV/Dq3/YFaffTO7dgKXjE9sP/0mqRxofSn3MpeL/ZV+ijaYFFd4LlHfSJoidB02 zPqpiEDC72oNn1tULq7461LwkN8jV/M+aOBVsl9VgtDm2tzo1afeKeT3DD8gRTIb3p0p q/A4CBxDzdPzbPgemV8YvKkNeXY5Ka0oJLOwhmGX8jc9lJckwoUqWqCCLdTChWhcCE2j 4TCw== X-Gm-Message-State: AOAM53312Mm3WKJd/2fwjAlPImax4c2R3tsCdotEENx4dEayRvcv4RiK hXKW+adDQByGvtPWz9/mfPcBWXUxVTc= X-Google-Smtp-Source: ABdhPJwW/WYIRVkkb18BYvg1wPLkBjEiNMDJaR3LnpUlNDY73t/hcWmTNOK5VyyH+zq7ynX4Bny65Q== X-Received: by 2002:a5d:5503:: with SMTP id b3mr9797646wrv.272.1589637224110; Sat, 16 May 2020 06:53:44 -0700 (PDT) Received: from sf.home (host81-147-8-205.range81-147.btcentralplus.com. [81.147.8.205]) by smtp.gmail.com with ESMTPSA id y4sm8230240wro.91.2020.05.16.06.53.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 May 2020 06:53:43 -0700 (PDT) Received: by sf.home (Postfix, from userid 1000) id 662285A22061; Sat, 16 May 2020 14:53:42 +0100 (BST) To: libc-alpha@sourceware.org Subject: [PATCH] ia64: fix dl-sysdep miscompilation on gcc-10 Date: Sat, 16 May 2020 14:53:32 +0100 Message-Id: <20200516135332.3969575-1-slyich@gmail.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 X-Spam-Status: No, score=-9.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: slyich--- via Libc-alpha From: develop--- via Libc-alpha Reply-To: slyich@gmail.com Cc: Sergei Trofimovich Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" From: Sergei Trofimovich gcc-10 enabled -fno-common by default. This caused glibc link failure: ``` $ ia64-unknown-linux-gnu-gcc -pipe -O2 -nostdlib -nostartfiles \ -static -o .../elf/sln ... libc.a(dl-support.o): in function `setup_vdso': glibc-2.31/elf/setup-vdso.h:116:(.text+0x1322): relocation truncated to fit: GPREL22 against `.text' collect2: error: ld returned 1 exit status ``` The difference between gcc-9 and gcc-10 is the way relocation is generated for ia64-specific symbol '_dl_sysinfo_break', defined as: ```c 32 #ifndef __ASSEMBLER__ 33 /* Don't declare this as a function---we want it's entry-point, not 34 it's function descriptor... */ 35 extern int _dl_sysinfo_break attribute_hidden; 36 # define DL_SYSINFO_DEFAULT ((uintptr_t) &_dl_sysinfo_break) 37 # define DL_SYSINFO_IMPLEMENTATION \ 38 asm (".text\n\t" \ 39 ".hidden _dl_sysinfo_break\n\t" \ 40 ".proc _dl_sysinfo_break\n\t" \ ``` Note: it's declared as ".sdata" (defined nearby GOT) but assumed to be defined in ".text" as it's really a direct function address. As a result generated relocation changed from: from `GPREL64I`: ``` 1390: 05 00 84 1e 98 11 [MLX] st8 [r15]=r33 1391: GPREL64I .text 1396: 00 00 00 00 00 e0 movl r15=0x0;; 139c: 01 00 00 60 13a0: 0b 78 04 1e 00 20 [MMI] add r15=r1,r15;; ``` to `GPREL22`: ``` if (GLRO(dl_sysinfo) == DL_SYSINFO_DEFAULT) 1320: 0b 80 00 1c 18 10 [MMI] ld8 r16=[r14];; 1322: GPREL22 .text 1326: 00 08 3d 30 23 e0 st8 [r15]=r33 132c: 01 08 00 90 addl r15=0,r1;; ``` This change explicitly declares symbol to be in ".text" section. That allows gcc to generate far relocations. Regression tested on glibc-master and gcc-10.1.0 on rx3600. Bug: https://bugs.gentoo.org/723268 Signed-off-by: Sergei Trofimovich --- sysdeps/unix/sysv/linux/ia64/dl-sysdep.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sysdeps/unix/sysv/linux/ia64/dl-sysdep.h b/sysdeps/unix/sysv/linux/ia64/dl-sysdep.h index 78fa6dd2c9..e526e02ff4 100644 --- a/sysdeps/unix/sysv/linux/ia64/dl-sysdep.h +++ b/sysdeps/unix/sysv/linux/ia64/dl-sysdep.h @@ -32,7 +32,9 @@ #ifndef __ASSEMBLER__ /* Don't declare this as a function---we want it's entry-point, not it's function descriptor... */ -extern int _dl_sysinfo_break attribute_hidden; +/* Use section ".text" to force far GPREL64 relocation instead of + GPREL22 . */ +extern int _dl_sysinfo_break attribute_hidden __attribute__((section(".text"))); # define DL_SYSINFO_DEFAULT ((uintptr_t) &_dl_sysinfo_break) # define DL_SYSINFO_IMPLEMENTATION \ asm (".text\n\t" \