From patchwork Fri Sep 29 21:37:01 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: 23256 Received: (qmail 106311 invoked by alias); 29 Sep 2017 21:37:12 -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 106080 invoked by uid 89); 29 Sep 2017 21:37:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.3 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:1631 X-HELO: mail-io0-f170.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=z9RQjELj00/sDvO0lNfn7cwDmcIQyOKztA1y09Lyl48=; b=H/AFNgwMvok3pKuKLvkRJ+kWAv6A5sXqaFHAI2fJ6QNDanx2aBCXRTmkGF9EyNWJq9 iKqikPy5CwXJ2IlST0za1b+2ooa0I5brDSEID0KR7PNY1KK4aEqKgwqUBL2gJHdyRqDA O0SWJlmtFwZASgYkUrth6Rf5sxxEGjnXqL/cbz+sMDUaB3hMHhV4zp3GaKE+WXP+FzM7 UnAIdwDm6fqRO+/D54ghXPC+HCAG83oaGTVmvTDH0PbTPIVYPxltWftP2SQZziz1jRqE wSbxLMzAqnnYwJhLrbq7SNsCstkHisusCtKc0LFaN2wteQUrwoEJ4u2eLUaJgZaCuACm l/tA== X-Gm-Message-State: AMCzsaXHblJEvOREnY12daQ229EH4IRUylJi6V/vKVj5gxOD1RT1hcPC AzZsKiyGSUf/ubo7MhjLdDOq+gWr X-Google-Smtp-Source: AOwi7QAWilfX8NrNW35F18wnS07j8qckeEv8mEbr5E8Pc5yIePe1JFlJRqnwxZSKGMf+CZCdKIrj9w== X-Received: by 10.107.88.18 with SMTP id m18mr14394156iob.192.1506721028828; Fri, 29 Sep 2017 14:37:08 -0700 (PDT) Date: Fri, 29 Sep 2017 14:37:01 -0700 From: "H.J. Lu" To: GNU C Library Subject: [PATCH] aarch64: Update elf_machine_load_address for static PIE Message-ID: <20170929213701.GT2482@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/aarch64/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/aarch64/dl-machine.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/sysdeps/aarch64/dl-machine.h b/sysdeps/aarch64/dl-machine.h index 60472036f5..6f259f1ef7 100644 --- a/sysdeps/aarch64/dl-machine.h +++ b/sysdeps/aarch64/dl-machine.h @@ -61,6 +61,7 @@ elf_machine_load_address (void) ElfW(Addr) static_addr; ElfW(Addr) dynamic_addr; +#ifdef SHARED asm (" \n" " adrp %1, _dl_start; \n" #ifdef __LP64__ @@ -84,6 +85,34 @@ elf_machine_load_address (void) #endif "2: \n" : "=r" (static_addr), "=r" (dynamic_addr)); +#else + extern ElfW(Dyn) _DYNAMIC[] __attribute__((weak, visibility ("hidden"))); + if (!_DYNAMIC) + return 0; + asm (" \n" +" adrp %1, _dl_relocate_static_pie; \n" +#ifdef __LP64__ +" add %1, %1, #:lo12:_dl_relocate_static_pie \n" +#else +" add %w1, %w1, #:lo12:_dl_relocate_static_pie\n" +#endif +" ldr %w0, 1f \n" +" b 2f \n" +"1: \n" +#ifdef __LP64__ +" .word _dl_relocate_static_pie \n" +#else +# ifdef __AARCH64EB__ +" .short 0 \n" +# endif +" .short _dl_relocate_static_pie \n" +# ifndef __AARCH64EB__ +" .short 0 \n" +# endif +#endif +"2: \n" + : "=r" (static_addr), "=r" (dynamic_addr)); +#endif return dynamic_addr - static_addr; }