From 374ad2854b4a69a0efdb29f8f1122b4472e8055b Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Wed, 14 Oct 2009 05:25:02 +0000 Subject: 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. --- gold/options.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'gold/options.cc') diff --git a/gold/options.cc b/gold/options.cc index 5be414d..299a748 100644 --- a/gold/options.cc +++ b/gold/options.cc @@ -1001,17 +1001,24 @@ General_options::finalize() // Now that we've normalized the options, check for contradictory ones. if (this->shared() && this->is_static()) gold_fatal(_("-shared and -static are incompatible")); + if (this->shared() && this->pie()) + gold_fatal(_("-shared and -pie are incompatible")); if (this->shared() && this->relocatable()) gold_fatal(_("-shared and -r are incompatible")); + if (this->pie() && this->relocatable()) + gold_fatal(_("-pie and -r are incompatible")); // TODO: implement support for -retain-symbols-file with -r, if needed. if (this->relocatable() && this->retain_symbols_file()) gold_fatal(_("-retain-symbols-file does not yet work with -r")); if (this->oformat_enum() != General_options::OBJECT_FORMAT_ELF - && (this->shared() || this->relocatable())) - gold_fatal(_("binary output format not compatible with -shared or -r")); + && (this->shared() + || this->pie() + || this->relocatable())) + gold_fatal(_("binary output format not compatible " + "with -shared or -pie or -r")); if (this->user_set_hash_bucket_empty_fraction() && (this->hash_bucket_empty_fraction() < 0.0 -- cgit v1.1