]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gold/script-sections.cc
* script-sections.cc (Script_sections::create_segments): Use
[thirdparty/binutils-gdb.git] / gold / script-sections.cc
index f6b655083e6108aa4d1fb1acb312c4c5727fcb70..55db831ae7e647efd8a34e126e5a7112ae3b96cb 100644 (file)
@@ -2706,18 +2706,17 @@ Script_sections::create_segments(Layout* layout)
 
   size_t sizeof_headers = this->total_header_size(layout);
 
-  if ((first_seg->paddr() & (abi_pagesize - 1)) >= sizeof_headers)
-    {
-      first_seg->set_addresses(first_seg->vaddr() - sizeof_headers,
-                              first_seg->paddr() - sizeof_headers);
-      return first_seg;
-    }
-
   uint64_t vma = first_seg->vaddr();
   uint64_t lma = first_seg->paddr();
 
   uint64_t subtract = this->header_size_adjustment(lma, sizeof_headers);
 
+  if ((lma & (abi_pagesize - 1)) >= sizeof_headers)
+    {
+      first_seg->set_addresses(vma - subtract, lma - subtract);
+      return first_seg;
+    }
+
   // If there is no room to squeeze in the headers, then punt.  The
   // resulting executable probably won't run on GNU/Linux, but we
   // trust that the user knows what they are doing.