From 02d2d8927d2fd3815a9f3c5c767aa71a8a33408e Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Tue, 3 Oct 2017 17:48:55 -0700 Subject: Revert x86: Allow undefined _DYNAMIC in static executable 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. * 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/x86_64/dl-machine.h | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'sysdeps/x86_64') diff --git a/sysdeps/x86_64/dl-machine.h b/sysdeps/x86_64/dl-machine.h index a79e5ca..6a04cbc 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 -- cgit v1.1