From patchwork Thu Jan 26 07:03:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Neyman X-Patchwork-Id: 719977 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3v8CZW1qF5z9t1P for ; Thu, 26 Jan 2017 18:04:03 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="Pwzb0Jpl"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:to:from:subject:message-id:date:mime-version :content-type; q=dns; s=default; b=EKZF7J82sEi+J45sCY1U+RYYmSSU6 0ZcCOqSisCMCUEYj4GhKwopnza2da0RtlTDOAxhuw/gQUF58CRWqx1xv6Uy3QwGm EVdS/p0ToJDzYhRi5q0sHuA4vTa7h90ybFfLzcxukcw52Rxfg/dttGbC4MTiQnkC 9dHPC6fsIfSuZc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:to:from:subject:message-id:date:mime-version :content-type; s=default; bh=cYRVcoer68DHArQZPJj8cgWfuXo=; b=Pwz b0Jplg/UeLFSBBUW6O8YoW+aL/WGAFrk/EcBRj5jBGzpDJEX7UTojzi61tGzMWzh SYOYC551p0paltCiiCxt5m0yueC9QG7MC456A2FmZahFXhfCOeQvnEKNF7bJqQFM qHdMjYmnXEnuOscgBxwcIXBz/Z6gbRq8xBmWLpzc= Received: (qmail 118674 invoked by alias); 26 Jan 2017 07:03:51 -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 118614 invoked by uid 89); 26 Jan 2017 07:03:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=copyinglib, UD:LIB, COPYINGLIB, COPYING.LIB X-HELO: nm2-vm10.access.bullet.mail.bf1.yahoo.com X-Yahoo-SMTP: 0h0Q7euswBD_g.kcEqbzJWRFfrba801gq1M1 To: libc-alpha@sourceware.org From: Alexey Neyman Subject: [PATCH] [RFC] Building for SuperH fails with gcc5/6 Message-ID: Date: Wed, 25 Jan 2017 23:03:36 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 Hi, Build glibc for sh4-unknown-linux-gnu currently fails if one's using GCC5/6: in dl-conflict.c, the elf_machine_rela() function is called with NULL as its 3rd argument, sym. The implementation of that function in sysdeps/sh/dl-machine.h dereferences that pointer: const Elf32_Sym *const refsym = sym; ... if (map == &GL(dl_rtld_map)) value -= map->l_addr + refsym->st_value + reloc->r_addend; GCC discovers a null pointer dereference, and in accordance with -fdelete-null-pointer-checks (which is enabled in -O2) replaces this code with a trap - which, as SH does not implement a trap pattern in GCC, evaluates to an abort() call. This abort() call pulls many more objects from libc_nonshared.a, eventually resulting in link failure due to multiple definitions for a number of symbols. As far as I see, the conditional before this code is always false in rtld: _dl_resolve_conflicts() is called with main_map as the first argument, not GL(_dl_rtld_map), but since that call is in yet another compilation unit, GCC does not know about it. Patch that wraps this conditional into !defined RESOLVE_CONFLICT_FIND_MAP attached. However, I thought the abort() call may be also inserted by GCC on other architectures that do not implement the trap pattern, so it may make sense to provide a dummy abort() in rtld that does not pull any other dependencies. An alternative patch for this approach also attached. And, of course, it is also possible to just add -fno-delete-null-pointer-checks to the compiler flags for dl-conflict.c on SH, even though it would unnecessarily pessimize the code. Comments? Regards, Alexey. From 279acf7a059f2d2296f690d7f2d886bd0e404f30 Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Wed, 25 Jan 2017 21:46:53 -0800 Subject: [PATCH] sh: conditional is false in dl-conflict.c ... ifdef it out, so that it doesn't create a call to abort(). Signed-off-by: Alexey Neyman --- sysdeps/sh/dl-machine.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sysdeps/sh/dl-machine.h b/sysdeps/sh/dl-machine.h index 449deea..2b468af 100644 --- a/sysdeps/sh/dl-machine.h +++ b/sysdeps/sh/dl-machine.h @@ -389,7 +389,7 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc, break; case R_SH_DIR32: { -#ifndef RTLD_BOOTSTRAP +#if !defined RTLD_BOOTSTRAP && !defined RESOLVE_CONFLICT_FIND_MAP /* This is defined in rtld.c, but nowhere in the static libc.a; make the reference weak so static programs can still link. This declaration cannot be done when -- 2.9.3