diff mbox

Don't use PLT nor GOT in libc.a [BZ #20750]

Message ID CAMe9rOpcyETFMbJrDu2PontwYnyKX9Q+4jUj-BrATDFp_p7K8A@mail.gmail.com
State New
Headers show

Commit Message

H.J. Lu Nov. 28, 2016, 5:46 p.m. UTC
On Fri, Nov 25, 2016 at 12:43 AM, Florian Weimer <fweimer@redhat.com> wrote:
> On 11/24/2016 12:58 PM, Allan McRae wrote:

>>

>> Ping.  My distribution wants to enable PIE and -z,now by default and

>> this is required for glibc to build.

>

>

> My question has been answered.  H.J., could you please check this in?

>

> Thanks,

> Florian

>


This is what I checked in.

-- 
H.J.

Comments

Joseph Myers Nov. 28, 2016, 6:26 p.m. UTC | #1
Does this fix bug 20621 or not?  (At one point 20621 and 20750 were marked 
as duplicates.)

-- 
Joseph S. Myers
joseph@codesourcery.com
H.J. Lu Nov. 28, 2016, 9:32 p.m. UTC | #2
On Mon, Nov 28, 2016 at 10:26 AM, Joseph Myers <joseph@codesourcery.com> wrote:
> Does this fix bug 20621 or not?  (At one point 20621 and 20750 were marked

> as duplicates.)

>


Bug 20621 compiles glibc with -fPIC -DPIC.  I don't think it is the
supported way to build glibc.


-- 
H.J.
diff mbox

Patch

From dddb327ef2da7dfd86aed36b4db6e2fe471ed461 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Fri, 4 Nov 2016 10:43:42 -0700
Subject: [PATCH] X86_64: Don't use PLT nor GOT in static archives [BZ #20750]

There is no need to use PLT nor GOT in static archives to branch to a
function, regardless whether static archives is compiled with PIC or
not.  When static archives are used to create dynamic executable,
PLT/GOT may be used.  The resulting executable still works correctly.

	[BZ #20750]
	* sysdeps/x86_64/sysdep.h (JUMPTARGET): Check SHARED instead
	of PIC.
---
 sysdeps/x86_64/sysdep.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sysdeps/x86_64/sysdep.h b/sysdeps/x86_64/sysdep.h
index 75ac747..4b67fa8 100644
--- a/sysdeps/x86_64/sysdep.h
+++ b/sysdeps/x86_64/sysdep.h
@@ -89,13 +89,14 @@  lose:									      \
   END (name)
 
 #undef JUMPTARGET
-#ifdef PIC
+#ifdef SHARED
 # ifdef BIND_NOW
 #  define JUMPTARGET(name)	*name##@GOTPCREL(%rip)
 # else
 #  define JUMPTARGET(name)	name##@PLT
 # endif
 #else
+/* For static archives, branch to target directly.  */
 # define JUMPTARGET(name)	name
 #endif
 
-- 
2.7.4