From patchwork Fri Sep 29 21:33:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 820093 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-85150-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="dYuq/x2N"; dkim-atps=neutral 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 3y3lDL6kMhz9t0F for ; Sat, 30 Sep 2017 07:33:38 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:mime-version :content-type; q=dns; s=default; b=jj1aYBapHrumMqKjU89oQkb7R8b07 SgzftIeHJpkykBa1jAP4TwDG+be6I3KlcTQdkdmHA65fIaFRe5OdYiNycWgGvPyy 7rpR1zPop8U5VdpqZrUWEO0wkE8/aTRr0GL3Is9BoVsA0LS4AWiuFeSWgE9CtbC4 l6lNPv7VI54LE0= 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:date:from:to:subject:message-id:mime-version :content-type; s=default; bh=2esQko7kAloU/Vpj8fGK/ha8xE0=; b=dYu q/x2NDioz2vgtn3vQmefhRZ+Mx11Auh/Dkh0be8rWeNN4+FTeipiEHFk8DvdE3Lp mwLKWC1aK5a7cI4M7a9P4g08g+NbI/7qYgk0HvKA5Ilqjv7C3Ny9unORegBRoi3z zMh1rw1Muzwc8+qgtmvq6vQKuHZjOomTHFHO3dv4= Received: (qmail 47283 invoked by alias); 29 Sep 2017 21:33:29 -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 47030 invoked by uid 89); 29 Sep 2017 21:33:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.2 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, 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=Hx-languages-length:1376 X-HELO: mail-it0-f48.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:user-agent; bh=f8aSjZWhp/RTF5rm5YbqgssoW/uGDRynTGVtVHVT6rw=; b=RESXSunAZTmjy7uzAVOgJlvRaLfCDGOTokmgFmSflfXHRI7FSJuUhqIylWNeLnu2TI tKF7gS7JcuBwN21mYPXL5S6IvFHEtOpaxbrupjCq0HaBtbwU/1l5bO/2TiVk66uMNpbv UojrYYht9VBiqweKn1fWeP91U2am9Ne9JGZC5QqBzXKzHPJk/l9F9ibHTF59fu6ERUWK sbomUWU084DbALcCqUMoOMWU97D9OI1qS9mhX6EwCQBGtN54DVx2oX7ygzB64URVZJl2 Wedct1RyPbsIDPJGLUYbnSaooZt32ISeWllrVIlc4yt1kE+9PCTkPINSb/lJO+2j2c58 rqtg== X-Gm-Message-State: AMCzsaUnuqke3MPfdkRTWX3sYZwcrEpwnJK+M/KFAfP3+gBozHDy2a2p CjenJtIagKpU1ilhPlZFRpE3nHNL X-Google-Smtp-Source: AOwi7QDsx/MMjkSIkYpgYub4mYni9YdBRJhEfG1z6DSw5q4sFwolbpKoUAY63oB9tRMXCfS/kX4eIw== X-Received: by 10.36.117.79 with SMTP id y76mr8732676itc.16.1506720806093; Fri, 29 Sep 2017 14:33:26 -0700 (PDT) Date: Fri, 29 Sep 2017 14:33:19 -0700 From: "H.J. Lu" To: GNU C Library Subject: [PATCH] sh: Update elf_machine_load_address for static PIE Message-ID: <20170929213319.GJ2482@gmail.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.0 (2017-09-02) When --enable-static-pie is used to configure glibc, we need to use _dl_relocate_static_pie to compute load address in static PIE. OK for master? * sysdeps/sh/dl-machine.h (elf_machine_load_address): Use _dl_relocate_static_pie instead of _dl_start to compute load address in static PIE. Return 0 if _DYNAMIC is undefined for static executable. --- sysdeps/sh/dl-machine.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/sysdeps/sh/dl-machine.h b/sysdeps/sh/dl-machine.h index 7106afbdbd..627ef115a9 100644 --- a/sysdeps/sh/dl-machine.h +++ b/sysdeps/sh/dl-machine.h @@ -50,6 +50,7 @@ static inline Elf32_Addr __attribute__ ((unused)) elf_machine_load_address (void) { Elf32_Addr addr; +#ifdef SHARED asm ("mov.l 1f,r0\n\ mov.l 3f,r2\n\ add r12,r2\n\ @@ -61,6 +62,22 @@ elf_machine_load_address (void) 3: .long _dl_start@GOTOFF\n\ 2: mov r2,%0" : "=r" (addr) : : "r0", "r1", "r2"); +#else + extern Elf32_Dyn _DYNAMIC[] __attribute__((weak, visibility ("hidden"))); + if (!_DYNAMIC) + return 0; + asm ("mov.l 1f,r0\n\ + mov.l 3f,r2\n\ + add r12,r2\n\ + mov.l @(r0,r12),r0\n\ + bra 2f\n\ + sub r0,r2\n\ + .align 2\n\ + 1: .long _dl_relocate_static_pie@GOT\n\ + 3: .long _dl_relocate_static_pie@GOTOFF\n\ + 2: mov r2,%0" + : "=r" (addr) : : "r0", "r1", "r2"); +#endif return addr; }