summaryrefslogtreecommitdiff
path: root/gold/options.h
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>2009-10-14 05:25:01 +0000
committerIan Lance Taylor <ian@airs.com>2009-10-14 05:25:01 +0000
commit118c8d19936a667003f767399a2671a2be3908a8 (patch)
treeac61299dfa6f6f4d0cba9dacdc86adcefd448564 /gold/options.h
parent8de144c816e48b92ac4511d0c9f724f116fb7d52 (diff)
downloadbinutils-redhat-118c8d19936a667003f767399a2671a2be3908a8.tar.gz
Add support for -pie.
* options.h (class General_options): Add -pie and --pic-executable. (General_options::output_is_position_independent): Test -pie. (General_options::output_is_executable): Return true if not shared and not relocatable. (General_options::output_is_pie): Remove. * options.cc (General_options::finalize): Reject incompatible uses of -pie. * gold.cc (queue_middle_tasks): A -pie link is not static. * symtab.h (Symbol::needs_plt_entry): Return false if -pie. * symtab.cc (Symbol::final_value_is_known): Return false if output_is_position_independent. * layout.cc (Layout::set_segment_offsets): Start at address 0 if output_is_position_independent. * output.cc (Output_file_header::do_sized_write): Use ET_DYN if output_is_position_independent. * i386.cc (Output_data_plt_i386::do_write): Use the PIC PLT if output_is_position_independent. * testsuite/Makefile.am (check_PROGRAMS): Add basic_pie_test and two_file_pie_test. (basic_pie_test.o, basic_pie_test): New targets. (two_file_test_1_pie.o, two_file_test_1b_pie.o): New targets. (two_file_test_2_pie.o, two_file_test_main_pie.o): New targets. (two_file_pie_test): New target. * testsuite/Makefile.in: Rebuild. * README: Remove note saying that -pie is not supported.
Diffstat (limited to 'gold/options.h')
-rw-r--r--gold/options.h16
1 files changed, 8 insertions, 8 deletions
diff --git a/gold/options.h b/gold/options.h
index 1a034423a7..cbb45b5217 100644
--- a/gold/options.h
+++ b/gold/options.h
@@ -763,6 +763,12 @@ class General_options
DEFINE_string(oformat, options::EXACTLY_TWO_DASHES, '\0', "elf",
N_("Set output format"), N_("[binary]"));
+ DEFINE_bool(pie, options::ONE_DASH, '\0', false,
+ N_("Create a position independent executable"), NULL);
+ DEFINE_bool_alias(pic_executable, pie, options::TWO_DASHES, '\0',
+ N_("Create a position independent executable"), NULL,
+ false);
+
#ifdef ENABLE_PLUGINS
DEFINE_special(plugin, options::TWO_DASHES, '\0',
N_("Load a plugin library"), N_("PLUGIN"));
@@ -1009,7 +1015,7 @@ class General_options
// the output is position-independent or not.
bool
output_is_position_independent() const
- { return this->shared(); }
+ { return this->shared() || this->pie(); }
// Return true if the output is something that can be exec()ed, such
// as a static executable, or a position-dependent or
@@ -1017,13 +1023,7 @@ class General_options
// object file.
bool
output_is_executable() const
- { return !this->shared() || this->output_is_pie(); }
-
- // Return true if the output is a position-independent executable.
- // This is currently not supported.
- bool
- output_is_pie() const
- { return false; }
+ { return !this->shared() && !this->relocatable(); }
// This would normally be static(), and defined automatically, but
// since static is a keyword, we need to come up with our own name.