diff --git a/gold/layout.cc b/gold/layout.cc index b454c10..09edaae 100644 --- a/gold/layout.cc +++ b/gold/layout.cc @@ -975,6 +975,7 @@ Layout::choose_output_section(const Relobj* relobj, const char* name, case Script_sections::ST_NONE: break; case Script_sections::ST_NOLOAD: + type = elfcpp::SHT_NOBITS; flags &= elfcpp::SHF_ALLOC; break; default: @@ -1005,24 +1006,6 @@ Layout::choose_output_section(const Relobj* relobj, const char* name, os->set_found_in_sections_clause(); - // Special handling for NOLOAD sections. - if (script_section_type == Script_sections::ST_NOLOAD) - { - os->set_is_noload(); - - // The constructor of Output_section sets addresses of non-ALLOC - // sections to 0 by default. We don't want that for NOLOAD - // sections even if they have no SHF_ALLOC flag. - if ((os->flags() & elfcpp::SHF_ALLOC) == 0 - && os->is_address_valid()) - { - gold_assert(os->address() == 0 - && !os->is_offset_valid() - && !os->is_data_size_valid()); - os->reset_address_and_file_offset(); - } - } - *output_section_slot = os; return os; } @@ -2062,15 +2045,14 @@ Layout::make_output_section_for_script( Script_sections::Section_type section_type) { name = this->namepool_.add(name, false, NULL); - elfcpp::Elf_Xword sh_flags = elfcpp::SHF_ALLOC; + elfcpp::Elf_Word type = elfcpp::SHT_PROGBITS; if (section_type == Script_sections::ST_NOLOAD) - sh_flags = 0; - Output_section* os = this->make_output_section(name, elfcpp::SHT_PROGBITS, - sh_flags, ORDER_INVALID, + type = elfcpp::SHT_NOBITS; + Output_section* os = this->make_output_section(name, type, elfcpp::SHF_ALLOC, + ORDER_INVALID, false); os->set_found_in_sections_clause(); - if (section_type == Script_sections::ST_NOLOAD) - os->set_is_noload(); + return os; } diff --git a/gold/output.cc b/gold/output.cc index 5cc3629..e23cd27 100644 --- a/gold/output.cc +++ b/gold/output.cc @@ -2293,7 +2293,6 @@ Output_section::Output_section(const char* name, elfcpp::Elf_Word type, generate_code_fills_at_write_(false), is_entsize_zero_(false), section_offsets_need_adjustment_(false), - is_noload_(false), always_keeps_input_sections_(false), has_fixed_layout_(false), is_patch_space_allowed_(false), @@ -3129,9 +3128,8 @@ Output_section::do_reset_address_and_file_offset() { // An unallocated section has no address. Forcing this means that // we don't need special treatment for symbols defined in debug - // sections. We do the same in the constructor. This does not - // apply to NOLOAD sections though. - if (((this->flags_ & elfcpp::SHF_ALLOC) == 0) && !this->is_noload_) + // sections. We do the same in the constructor. + if ((this->flags_ & elfcpp::SHF_ALLOC) == 0) this->set_address(0); for (Input_section_list::iterator p = this->input_sections_.begin(); diff --git a/gold/output.h b/gold/output.h index c7ad54e..1e3c8b1 100644 --- a/gold/output.h +++ b/gold/output.h @@ -3872,16 +3872,6 @@ class Output_section : public Output_data void adjust_section_offsets(); - // Whether this is a NOLOAD section. - bool - is_noload() const - { return this->is_noload_; } - - // Set NOLOAD flag. - void - set_is_noload() - { this->is_noload_ = true; } - // Print merge statistics to stderr. void print_merge_stats(); @@ -4389,8 +4379,6 @@ class Output_section : public Output_data bool is_entsize_zero_ : 1; // Whether section offsets need adjustment due to relaxation. bool section_offsets_need_adjustment_ : 1; - // Whether this is a NOLOAD section. - bool is_noload_ : 1; // Whether this always keeps input section. bool always_keeps_input_sections_ : 1; // Whether this section has a fixed layout, for incremental update links. diff --git a/gold/script-sections.cc b/gold/script-sections.cc index 261e8e3..c5737c6 100644 --- a/gold/script-sections.cc +++ b/gold/script-sections.cc @@ -2342,8 +2342,6 @@ Output_section_definition::set_section_addresses(Symbol_table* symtab, Script_sections* script_sections = layout->script_options()->script_sections(); uint64_t address; - uint64_t old_dot_value = *dot_value; - uint64_t old_load_address = *load_address; // If input section sorting is requested via --section-ordering-file or // linker plugins, then do it here. This is important because we want @@ -2413,11 +2411,10 @@ Output_section_definition::set_section_addresses(Symbol_table* symtab, *dot_value = address; - // Except for NOLOAD sections, the address of non-SHF_ALLOC sections is - // forced to zero, regardless of what the linker script wants. + // The address of non-SHF_ALLOC sections is forced to zero, regardless + // of what the linker script wants. if (this->output_section_ != NULL - && ((this->output_section_->flags() & elfcpp::SHF_ALLOC) != 0 - || this->output_section_->is_noload())) + && ((this->output_section_->flags() & elfcpp::SHF_ALLOC) != 0)) this->output_section_->set_address(address); this->evaluated_address_ = address; @@ -2588,13 +2585,6 @@ Output_section_definition::set_section_addresses(Symbol_table* symtab, this->output_section_->set_is_relro(); else this->output_section_->clear_is_relro(); - - // If this is a NOLOAD section, keep dot and load address unchanged. - if (this->output_section_->is_noload()) - { - *dot_value = old_dot_value; - *load_address = old_load_address; - } } } @@ -3717,12 +3707,6 @@ Sort_output_sections::operator()(const Output_section* os1, if (tls1 != tls2) return nobits1 ? tls1 : tls2; - // Sort non-NOLOAD before NOLOAD. - if (os1->is_noload() && !os2->is_noload()) - return true; - if (!os1->is_noload() && os2->is_noload()) - return true; - // The sections seem practically identical. Sort by name to get a // stable sort. return os1->name() < os2->name();