From: Ian Lance Taylor Date: Wed, 4 Nov 2009 16:36:08 +0000 (+0000) Subject: PR 10887 X-Git-Tag: binutils-2_20_1~165 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=70bc6f32cd76968a7e77b138b346131ccb735d3d;p=thirdparty%2Fbinutils-gdb.git PR 10887 * arm.cc (Target_arm::do_finalize_sections): Don't add dynamic tags if data is discarded by linker script. * i386.cc (Target_i386::do_finalize_sections): Likewise. * powerpc.cc (Target_powerpc::do_finalize_sections): Likewise. * sparc.cc (Target_sparc::do_finalize_sections): Likewise. * x86_64.cc (Target_x86_64::do_finalize_sections): Likewise. --- diff --git a/gold/ChangeLog b/gold/ChangeLog index 5589cd7b375..35a58f9679e 100644 --- a/gold/ChangeLog +++ b/gold/ChangeLog @@ -1,3 +1,13 @@ +2009-11-04 Ian Lance Taylor + + PR 10887 + * arm.cc (Target_arm::do_finalize_sections): Don't add dynamic + tags if data is discarded by linker script. + * i386.cc (Target_i386::do_finalize_sections): Likewise. + * powerpc.cc (Target_powerpc::do_finalize_sections): Likewise. + * sparc.cc (Target_sparc::do_finalize_sections): Likewise. + * x86_64.cc (Target_x86_64::do_finalize_sections): Likewise. + 2009-11-04 Ian Lance Taylor * layout.cc (Layout::get_output_section): Add is_interp and diff --git a/gold/arm.cc b/gold/arm.cc index 72f56ccd5fe..c1615f08c8b 100644 --- a/gold/arm.cc +++ b/gold/arm.cc @@ -1831,10 +1831,12 @@ Target_arm::do_finalize_sections(Layout* layout) Output_data_dynamic* const odyn = layout->dynamic_data(); if (odyn != NULL) { - if (this->got_plt_ != NULL) + if (this->got_plt_ != NULL + && this->got_plt_->output_section() != NULL) odyn->add_section_address(elfcpp::DT_PLTGOT, this->got_plt_); - if (this->plt_ != NULL) + if (this->plt_ != NULL + && this->plt_->output_section() != NULL) { const Output_data* od = this->plt_->rel_plt(); odyn->add_section_size(elfcpp::DT_PLTRELSZ, od); @@ -1842,7 +1844,8 @@ Target_arm::do_finalize_sections(Layout* layout) odyn->add_constant(elfcpp::DT_PLTREL, elfcpp::DT_REL); } - if (this->rel_dyn_ != NULL) + if (this->rel_dyn_ != NULL + && this->rel_dyn_->output_section() != NULL) { const Output_data* od = this->rel_dyn_; odyn->add_section_address(elfcpp::DT_REL, od); diff --git a/gold/i386.cc b/gold/i386.cc index aa2d650621d..f21cf7432d7 100644 --- a/gold/i386.cc +++ b/gold/i386.cc @@ -1569,10 +1569,12 @@ Target_i386::do_finalize_sections(Layout* layout) Output_data_dynamic* const odyn = layout->dynamic_data(); if (odyn != NULL) { - if (this->got_plt_ != NULL) + if (this->got_plt_ != NULL + && this->got_plt_->output_section() != NULL) odyn->add_section_address(elfcpp::DT_PLTGOT, this->got_plt_); - if (this->plt_ != NULL) + if (this->plt_ != NULL + && this->plt_->output_section() != NULL) { const Output_data* od = this->plt_->rel_plt(); odyn->add_section_size(elfcpp::DT_PLTRELSZ, od); @@ -1580,7 +1582,8 @@ Target_i386::do_finalize_sections(Layout* layout) odyn->add_constant(elfcpp::DT_PLTREL, elfcpp::DT_REL); } - if (this->rel_dyn_ != NULL) + if (this->rel_dyn_ != NULL + && this->rel_dyn_->output_section() != NULL) { const Output_data* od = this->rel_dyn_; odyn->add_section_address(elfcpp::DT_REL, od); diff --git a/gold/powerpc.cc b/gold/powerpc.cc index c0bb17ffc36..9aacbf34763 100644 --- a/gold/powerpc.cc +++ b/gold/powerpc.cc @@ -1547,7 +1547,8 @@ Target_powerpc::do_finalize_sections(Layout* layout) Output_data_dynamic* const odyn = layout->dynamic_data(); if (odyn != NULL) { - if (this->plt_ != NULL) + if (this->plt_ != NULL + && this->plt_->output_section() != NULL) { const Output_data* od = this->plt_->rel_plt(); odyn->add_section_size(elfcpp::DT_PLTRELSZ, od); @@ -1557,7 +1558,8 @@ Target_powerpc::do_finalize_sections(Layout* layout) odyn->add_section_address(elfcpp::DT_PLTGOT, this->plt_); } - if (this->rela_dyn_ != NULL) + if (this->rela_dyn_ != NULL + && this->rela_dyn_->output_section() != NULL) { const Output_data* od = this->rela_dyn_; odyn->add_section_address(elfcpp::DT_RELA, od); diff --git a/gold/sparc.cc b/gold/sparc.cc index c17d3d8b269..55a04d96232 100644 --- a/gold/sparc.cc +++ b/gold/sparc.cc @@ -2334,7 +2334,8 @@ Target_sparc::do_finalize_sections(Layout* layout) Output_data_dynamic* const odyn = layout->dynamic_data(); if (odyn != NULL) { - if (this->plt_ != NULL) + if (this->plt_ != NULL + && this->plt_->output_section() != NULL) { const Output_data* od = this->plt_->rel_plt(); odyn->add_section_size(elfcpp::DT_PLTRELSZ, od); @@ -2344,7 +2345,8 @@ Target_sparc::do_finalize_sections(Layout* layout) odyn->add_section_address(elfcpp::DT_PLTGOT, this->plt_); } - if (this->rela_dyn_ != NULL) + if (this->rela_dyn_ != NULL + && this->rela_dyn_->output_section() != NULL) { const Output_data* od = this->rela_dyn_; odyn->add_section_address(elfcpp::DT_RELA, od); diff --git a/gold/x86_64.cc b/gold/x86_64.cc index 0f3705c0c72..c6b5f942549 100644 --- a/gold/x86_64.cc +++ b/gold/x86_64.cc @@ -1659,10 +1659,12 @@ Target_x86_64::do_finalize_sections(Layout* layout) Output_data_dynamic* const odyn = layout->dynamic_data(); if (odyn != NULL) { - if (this->got_plt_ != NULL) + if (this->got_plt_ != NULL + && this->got_plt_->output_section() != NULL) odyn->add_section_address(elfcpp::DT_PLTGOT, this->got_plt_); - if (this->plt_ != NULL) + if (this->plt_ != NULL + && this->plt_->output_section() != NULL) { const Output_data* od = this->plt_->rel_plt(); odyn->add_section_size(elfcpp::DT_PLTRELSZ, od); @@ -1680,7 +1682,8 @@ Target_x86_64::do_finalize_sections(Layout* layout) } } - if (this->rela_dyn_ != NULL) + if (this->rela_dyn_ != NULL + && this->rela_dyn_->output_section() != NULL) { const Output_data* od = this->rela_dyn_; odyn->add_section_address(elfcpp::DT_RELA, od);