This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] powerpc: Update elf_machine_load_address for static PIE


On 9/29/17, Alan Modra <amodra@gmail.com> wrote:
> On Fri, Sep 29, 2017 at 02:34:00PM -0700, H.J. Lu wrote:
>> powerpc uses _DYNAMIC to compute load address, which works with static
>> PIE.  We just need to return 0 if _DYNAMIC is undefined for static
>> executable.
>
> powerpc does, but powerpc64 does not.  So why is the test necessary on
> powerpc64?
>

You are right.  Here is the updated patch for powerpc32.  OK for master?

Thanks.

H.J.
From 077b614369ee19dd5cc798181d0c936f98497390 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Thu, 28 Sep 2017 14:51:41 -0700
Subject: [PATCH] powerpc32: Update elf_machine_load_address for static
 PIE

powerpc32 uses _DYNAMIC to compute load address, which works with static
PIE.  We just need to return 0 if _DYNAMIC is undefined for static
executable.

	* sysdeps/powerpc/powerpc32/dl-machine.h (elf_machine_load_address):
	Return 0 if _DYNAMIC is undefined for static executable.
---
 sysdeps/powerpc/powerpc32/dl-machine.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/sysdeps/powerpc/powerpc32/dl-machine.h b/sysdeps/powerpc/powerpc32/dl-machine.h
index 1f8437ed9c..9cf876e136 100644
--- a/sysdeps/powerpc/powerpc32/dl-machine.h
+++ b/sysdeps/powerpc/powerpc32/dl-machine.h
@@ -64,6 +64,11 @@ elf_machine_dynamic (void)
 static inline Elf32_Addr __attribute__ ((const))
 elf_machine_load_address (void)
 {
+#ifndef SHARED
+  extern Elf32_Dyn _DYNAMIC[] __attribute__((weak, visibility ("hidden")));
+  if (!_DYNAMIC)
+    return 0;
+#endif
   Elf32_Addr *branchaddr;
   Elf32_Addr runtime_dynamic;
 
-- 
2.13.6


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]