PR ld/10515
[binutils-gdb.git] / gold / script-sections.cc
index 9daf9ece1da74244c1cd233da38ea948015958e0..7396b3bf2485362b6f795225bd0fa2f470292447 100644 (file)
@@ -1863,12 +1863,12 @@ Output_section_definition::set_section_addresses(Symbol_table* symtab,
   else
     {
       Output_section* dummy;
-      uint64_t load_address =
+      uint64_t laddr =
        this->load_address_->eval_with_dot(symtab, layout, true, *dot_value,
                                           this->output_section_, &dummy);
       if (this->output_section_ != NULL)
-        this->output_section_->set_load_address(load_address);
-      this->evaluated_load_address_ = load_address;
+        this->output_section_->set_load_address(laddr);
+      this->evaluated_load_address_ = laddr;
     }
 
   uint64_t subalign;
@@ -2981,6 +2981,11 @@ Script_sections::create_segments(Layout* layout)
   if (first_seg == NULL)
     return NULL;
 
+  // -n or -N mean that the program is not demand paged and there is
+  // no need to put the program headers in a PT_LOAD segment.
+  if (parameters->options().nmagic() || parameters->options().omagic())
+    return NULL;
+
   size_t sizeof_headers = this->total_header_size(layout);
 
   uint64_t vma = first_seg->vaddr();
@@ -3071,7 +3076,7 @@ Script_sections::create_note_and_tls_segments(
 
 // Add a program header.  The PHDRS clause is syntactically distinct
 // from the SECTIONS clause, but we implement it with the SECTIONS
-// support becauase PHDRS is useless if there is no SECTIONS clause.
+// support because PHDRS is useless if there is no SECTIONS clause.
 
 void
 Script_sections::add_phdr(const char* name, size_t namelen, unsigned int type,