mips: Update elf_machine_load_address for static PIE

Message ID 20170929213441.GN2482@gmail.com
State New, archived
Headers

Commit Message

H.J. Lu Sept. 29, 2017, 9:34 p.m. UTC
  mips uses a local label 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/mips/dl-machine.h (elf_machine_dynamic): Return 0 if
	_DYNAMIC is undefined for static executable.
---
 sysdeps/mips/dl-machine.h | 5 +++++
 1 file changed, 5 insertions(+)
  

Comments

Joseph Myers Sept. 29, 2017, 10:16 p.m. UTC | #1
On Fri, 29 Sep 2017, H.J. Lu wrote:

> mips uses a local label 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/mips/dl-machine.h (elf_machine_dynamic): Return 0 if
> 	_DYNAMIC is undefined for static executable.

OK.
  

Patch

diff --git a/sysdeps/mips/dl-machine.h b/sysdeps/mips/dl-machine.h
index da9d6332ea..b4fee49cb1 100644
--- a/sysdeps/mips/dl-machine.h
+++ b/sysdeps/mips/dl-machine.h
@@ -147,6 +147,11 @@  elf_machine_dynamic (void)
 static inline ElfW(Addr)
 elf_machine_load_address (void)
 {
+#ifndef SHARED
+  extern ElfW(Dyn) _DYNAMIC[] __attribute__((weak, visibility ("hidden")));
+  if (!_DYNAMIC)
+    return 0;
+#endif
   ElfW(Addr) addr;
 #ifndef __mips16
   asm ("	.set noreorder\n"