public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gold: Set DF_1_PIE for -pie
@ 2020-05-30 22:04 Fangrui Song
  2020-05-31  0:14 ` Fangrui Song
  0 siblings, 1 reply; 4+ messages in thread
From: Fangrui Song @ 2020-05-30 22:04 UTC (permalink / raw)
  To: binutils, Cary Coutant; +Cc: Pedro, Alves, palves, Fangrui Song

DF_1_PIE originated from Solaris.
GNU ld since 5fe2850dd96483f176858fd75c098313d5b20bc2
sets the flag on non-Solaris platforms.

It can help distinguish PIE from ET_DYN.
eu-classify from elfutils uses this flag to recognize PIE.
glibc uses this flag to reject dlopen'ing a PIE (PR glibc/24323).

	PR gold/26039
	* layout.cc (Layout::finish_dynamic_section): Set DF_1_PIE.

	elfcpp/
	* elfcpp.h (enum DF_1): New enum member DF_1_PIE.
---
 elfcpp/elfcpp.h | 3 ++-
 gold/layout.cc  | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/elfcpp/elfcpp.h b/elfcpp/elfcpp.h
index 339faadaf3..a1d0090ab6 100644
--- a/elfcpp/elfcpp.h
+++ b/elfcpp/elfcpp.h
@@ -913,7 +913,8 @@ enum DF_1
   DF_1_INTERPOSE = 0x400,
   DF_1_NODEFLIB = 0x800,
   DF_1_NODUMP = 0x1000,
-  DF_1_CONLFAT = 0x2000
+  DF_1_CONLFAT = 0x2000,
+  DF_1_PIE = 0x08000000,
 };
 
 // Version numbers which appear in the vd_version field of a Verdef
diff --git a/gold/layout.cc b/gold/layout.cc
index be437f3900..ee75c50cad 100644
--- a/gold/layout.cc
+++ b/gold/layout.cc
@@ -5351,6 +5351,8 @@ Layout::finish_dynamic_section(const Input_objects* input_objects,
     flags |= elfcpp::DF_1_NOW;
   if (parameters->options().Bgroup())
     flags |= elfcpp::DF_1_GROUP;
+  if (parameters->options().pie())
+    flags |= elfcpp::DF_1_PIE;
   if (flags != 0)
     odyn->add_constant(elfcpp::DT_FLAGS_1, flags);
 }
-- 
2.27.0.rc0.183.gde8f92d652-goog


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

end of thread, other threads:[~2020-06-14  0:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-30 22:04 [PATCH] gold: Set DF_1_PIE for -pie Fangrui Song
2020-05-31  0:14 ` Fangrui Song
2020-06-14  0:30   ` Cary Coutant
2020-06-14  0:51     ` Fāng-ruì Sòng

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).