From patchwork Fri Sep 29 21:33:37 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: 23247 Received: (qmail 51422 invoked by alias); 29 Sep 2017 21:33:48 -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 51293 invoked by uid 89); 29 Sep 2017 21:33:47 -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:2309 X-HELO: mail-it0-f47.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=C07EvqKWp/7E1IaYDoe3fcL/HT9/4EmW73qkSxj/N8I=; b=WKEYd3m9JByRk2FyPAOlX+/BfG4g5Ddub4ur3+a/JLi9b7rHMjMxIManVbrfw1ZhSy 3fMo0R25ML9IVe2BRGIEQm6FdtmlQVtjlhFRvjmC1ckywt1143gAqxuuC/PWeUU6sJrb zGG9pPVFjmhSrCXoDvWOlSxplwArSMJYJKdDVMdQM4H8tV2EcK8V/sir9DyiDv47Ylwi gNKk3BCZec2yIeFMjZ2eVO1Ag18Kbv3UqBYQXpDKGMtEdnZAnzGEAOos+G/WXNyhk2vL 7QVXA3HGofqqvMzIV7erdBpqCb9Wb2bt6EljZAElN0r2IhITNH8lE8bIDlVVHH4ffZyV EHbQ== X-Gm-Message-State: AHPjjUgyPQlRlIg9WYSsvlRPNoSCRm9IpmON7q3MZuWY7IVPuyGkpobH j+GUbqTJiLqeqgxW/I+aNMoMRX1X X-Google-Smtp-Source: AOwi7QCtzN+UwsbCzwAcWpGN3yyq5AYoQgM+PNn92NrHT8+UcSFWSTPW3iRSyYaqujY7EOkwxgWT5A== X-Received: by 10.36.31.200 with SMTP id d191mr9072856itd.81.1506720824541; Fri, 29 Sep 2017 14:33:44 -0700 (PDT) Date: Fri, 29 Sep 2017 14:33:37 -0700 From: "H.J. Lu" To: GNU C Library Subject: [PATCH] s390: Update elf_machine_load_address for static PIE Message-ID: <20170929213337.GK2482@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/s390/s390-32/dl-machine.h (elf_machine_dynamic): 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/s390/s390-64/dl-machine.h (elf_machine_dynamic): Likewise. --- sysdeps/s390/s390-32/dl-machine.h | 14 ++++++++++++++ sysdeps/s390/s390-64/dl-machine.h | 11 +++++++++++ 2 files changed, 25 insertions(+) diff --git a/sysdeps/s390/s390-32/dl-machine.h b/sysdeps/s390/s390-32/dl-machine.h index c302c9d2ce..b5cdcb87cb 100644 --- a/sysdeps/s390/s390-32/dl-machine.h +++ b/sysdeps/s390/s390-32/dl-machine.h @@ -70,6 +70,7 @@ elf_machine_load_address (void) { Elf32_Addr addr; +#ifdef SHARED __asm__( " bras 1,2f\n" "1: .long _GLOBAL_OFFSET_TABLE_ - 1b\n" " .long (_dl_start - 1b - 0x80000000) & 0x00000000ffffffff\n" @@ -78,6 +79,19 @@ elf_machine_load_address (void) " al 1,0(1)\n" " sl %0,_dl_start@GOT(1)" : "=&d" (addr) : : "1" ); +#else + extern Elf32_Dyn _DYNAMIC[] __attribute__((weak, visibility ("hidden"))); + if (!_DYNAMIC) + return 0; + __asm__( " bras 1,2f\n" + "1: .long _GLOBAL_OFFSET_TABLE_ - 1b\n" + " .long (_dl_relocate_static_pie - 1b - 0x80000000) & 0x00000000ffffffff\n" + "2: l %0,4(1)\n" + " ar %0,1\n" + " al 1,0(1)\n" + " sl %0,_dl_relocate_static_pie@GOT(1)" + : "=&d" (addr) : : "1" ); +#endif return addr; } diff --git a/sysdeps/s390/s390-64/dl-machine.h b/sysdeps/s390/s390-64/dl-machine.h index 7513520417..724cc4f2e5 100644 --- a/sysdeps/s390/s390-64/dl-machine.h +++ b/sysdeps/s390/s390-64/dl-machine.h @@ -63,11 +63,22 @@ elf_machine_load_address (void) { Elf64_Addr addr; +#ifdef SHARED __asm__( " larl %0,_dl_start\n" " larl 1,_GLOBAL_OFFSET_TABLE_\n" " lghi 2,_dl_start@GOT\n" " slg %0,0(2,1)" : "=&d" (addr) : : "1", "2" ); +#else + extern Elf64_Dyn _DYNAMIC[] __attribute__((weak, visibility ("hidden"))); + if (!_DYNAMIC) + return 0; + __asm__( " larl %0,_dl_relocate_static_pie\n" + " larl 1,_GLOBAL_OFFSET_TABLE_\n" + " lghi 2,_dl_relocate_static_pie@GOT\n" + " slg %0,0(2,1)" + : "=&d" (addr) : : "1", "2" ); +#endif return addr; }