[PATCH] gold: Set DF_1_PIE for -pie
Fangrui Song
maskray@google.com
Sat May 30 22:04:23 GMT 2020
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
More information about the Binutils
mailing list