From patchwork Tue Oct 3 22:50: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: 23314 Received: (qmail 77416 invoked by alias); 3 Oct 2017 22:50: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 77406 invoked by uid 89); 3 Oct 2017 22:50:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 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= X-HELO: mail-oi0-f67.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=VF1eQkVjjmo7fTb0gNPkgz1/zoELeNPZKsj7sUFG3qs=; b=JWbfXQsAS7Q1TMzpPTFJfgdPGJwQkbhgx9gDrIIUlrj/Z9tJrbhDFRvPmOjdZ7KcDe YbBplkZcqsomSiF83MkPN9xODDZKtUEdcKcGdHf2qZjNsXy06Tl0Y/+bgsNmiKIOuq+s LvCRVfECNXwpbpcQ3GzIenTzpQMb78YFv/em6dQCWm/dqJYClkoBrXK0o/eQQVQxeYnp 6TIWF6QO3E2LTIvOTzR+gKgZRQNTYjsj+CI1tUpCPS6/6UXC8aMDl16D9svY9eYhrDe3 80cFtIPkAbXl0U7YbXKrnGu5nhQjhCHl+eel3AnmGankYTHsCoK1sa67CWodBQBYV6PK MTzQ== X-Gm-Message-State: AMCzsaUnOP3wCtJuOGe+7yYlG9UnurQtU27e92P4NmQMB5/Kp9oD7Ceh k9YETIQ44g/oqUtDcfYj8uEoA/hE X-Google-Smtp-Source: AOwi7QC1wRfOiE+SwuaBAfKDKQrXcFjUJWmXE890D6X9phQ9nXtzZjc45P97Dyr1LotxFDr0IggfLw== X-Received: by 10.202.184.198 with SMTP id i189mr8354035oif.380.1507071009015; Tue, 03 Oct 2017 15:50:09 -0700 (PDT) Date: Tue, 3 Oct 2017 15:50:01 -0700 From: "H.J. Lu" To: GNU C Library Subject: [PATCH] Revert x86: Allow undefined _DYNAMIC in static executable Message-ID: <20171003225001.GC27187@gmail.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.0 (2017-09-02) This code is used in non-PIE static executable and static PIE. It checks if _DYNAMIC is undefined before using it to compute load address. But not all targets can convert access _DYNAMIC via GOT, which needs dynamic relocation, to PC-relative at link-time. I am checking it in. H.J. --- * sysdeps/i386/dl-machine.h (elf_machine_load_address): Don't allow undefined _DYNAMIC in PIE libc.a. * sysdeps/x86_64/dl-machine.h (elf_machine_load_address): Likewse. --- sysdeps/i386/dl-machine.h | 11 ++--------- sysdeps/x86_64/dl-machine.h | 11 ++--------- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/sysdeps/i386/dl-machine.h b/sysdeps/i386/dl-machine.h index 242c692c17..2e17eba5c0 100644 --- a/sysdeps/i386/dl-machine.h +++ b/sysdeps/i386/dl-machine.h @@ -54,15 +54,8 @@ elf_machine_load_address (void) /* Compute the difference between the runtime address of _DYNAMIC as seen by a GOTOFF reference, and the link-time address found in the special unrelocated first GOT entry. */ -#ifndef SHARED - extern Elf32_Dyn _DYNAMIC[] __attribute__((weak, visibility ("hidden"))); - if (!_DYNAMIC) - return 0; -#endif - /* The address of dynamic must be taken as non-weak to avoid dynamic - relocation. */ - extern Elf32_Dyn dynamic[] asm ("_DYNAMIC") attribute_hidden; - return (Elf32_Addr) &dynamic - elf_machine_dynamic (); + extern Elf32_Dyn bygotoff[] asm ("_DYNAMIC") attribute_hidden; + return (Elf32_Addr) &bygotoff - elf_machine_dynamic (); } /* Set up the loaded object described by L so its unrelocated PLT diff --git a/sysdeps/x86_64/dl-machine.h b/sysdeps/x86_64/dl-machine.h index a79e5ca2f9..6a04cbcdc9 100644 --- a/sysdeps/x86_64/dl-machine.h +++ b/sysdeps/x86_64/dl-machine.h @@ -55,15 +55,8 @@ elf_machine_load_address (void) /* Compute the difference between the runtime address of _DYNAMIC as seen by an IP-relative reference, and the link-time address found in the special unrelocated first GOT entry. */ -#ifndef SHARED - extern ElfW(Dyn) _DYNAMIC[] __attribute__((weak, visibility ("hidden"))); - if (!_DYNAMIC) - return 0; -#endif - /* The address of dynamic must be taken as non-weak to avoid dynamic - relocation. */ - extern ElfW(Dyn) dynamic[] asm ("_DYNAMIC") attribute_hidden; - return (ElfW(Addr)) &dynamic - elf_machine_dynamic (); + extern ElfW(Dyn) _DYNAMIC[] attribute_hidden; + return (ElfW(Addr)) &_DYNAMIC - elf_machine_dynamic (); } /* Set up the loaded object described by L so its unrelocated PLT