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: 23246 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; }