public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] powerpc: Update elf_machine_load_address for static PIE
@ 2017-09-29 21:34 H.J. Lu
  2017-09-29 23:17 ` Alan Modra
  0 siblings, 1 reply; 3+ messages in thread
From: H.J. Lu @ 2017-09-29 21:34 UTC (permalink / raw)
  To: GNU C Library

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.

OK for master?

	* sysdeps/powerpc/powerpc32/dl-machine.h (elf_machine_load_address):
	Return 0 if _DYNAMIC is undefined for static executable.
	* sysdeps/powerpc/powerpc64/dl-machine.h (elf_machine_load_address):
	Likewise.
---
 sysdeps/powerpc/powerpc32/dl-machine.h | 5 +++++
 sysdeps/powerpc/powerpc64/dl-machine.h | 5 +++++
 2 files changed, 10 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;
 
diff --git a/sysdeps/powerpc/powerpc64/dl-machine.h b/sysdeps/powerpc/powerpc64/dl-machine.h
index aeb91b8f69..3c67f831f3 100644
--- a/sysdeps/powerpc/powerpc64/dl-machine.h
+++ b/sysdeps/powerpc/powerpc64/dl-machine.h
@@ -90,6 +90,11 @@ elf_machine_load_address (void) __attribute__ ((const));
 static inline Elf64_Addr
 elf_machine_load_address (void)
 {
+#ifndef SHARED
+  extern Elf64_Dyn _DYNAMIC[] __attribute__((weak, visibility ("hidden")));
+  if (!_DYNAMIC)
+    return 0;
+#endif
   Elf64_Addr ret;
 
   /* The first entry in .got (and thus the first entry in .toc) is the
-- 
2.13.6

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] powerpc: Update elf_machine_load_address for static PIE
  2017-09-29 21:34 [PATCH] powerpc: Update elf_machine_load_address for static PIE H.J. Lu
@ 2017-09-29 23:17 ` Alan Modra
  2017-09-29 23:29   ` H.J. Lu
  0 siblings, 1 reply; 3+ messages in thread
From: Alan Modra @ 2017-09-29 23:17 UTC (permalink / raw)
  To: H.J. Lu; +Cc: GNU C Library

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?

> 
> OK for master?
> 
> 	* sysdeps/powerpc/powerpc32/dl-machine.h (elf_machine_load_address):
> 	Return 0 if _DYNAMIC is undefined for static executable.
> 	* sysdeps/powerpc/powerpc64/dl-machine.h (elf_machine_load_address):
> 	Likewise.

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] powerpc: Update elf_machine_load_address for static PIE
  2017-09-29 23:17 ` Alan Modra
@ 2017-09-29 23:29   ` H.J. Lu
  0 siblings, 0 replies; 3+ messages in thread
From: H.J. Lu @ 2017-09-29 23:29 UTC (permalink / raw)
  To: Alan Modra; +Cc: GNU C Library

[-- Attachment #1: Type: text/plain, Size: 446 bytes --]

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.

[-- Attachment #2: 0011-powerpc32-Update-elf_machine_load_address-for-static.patch --]
[-- Type: text/x-patch, Size: 1150 bytes --]

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-09-29 23:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-29 21:34 [PATCH] powerpc: Update elf_machine_load_address for static PIE H.J. Lu
2017-09-29 23:17 ` Alan Modra
2017-09-29 23:29   ` H.J. Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).