gas/testsuite/
[deliverable/binutils-gdb.git] / ld / ldexp.c
index 59743ea1ec9d2fbd30070b27da6919c576de5e05..be296bccf53adcfd53ed7bb11338095e98444905 100644 (file)
@@ -213,10 +213,14 @@ new_rel (bfd_vma value, asection *section)
 static void
 new_rel_from_abs (bfd_vma value)
 {
+  asection *s = expld.section;
+
+  if (s == bfd_abs_section_ptr && expld.phase == lang_final_phase_enum)
+    s = section_for_dot ();
   expld.result.valid_p = TRUE;
-  expld.result.value = value - expld.section->vma;
+  expld.result.value = value - s->vma;
   expld.result.str = NULL;
-  expld.result.section = expld.section;
+  expld.result.section = s;
 }
 
 static void
@@ -606,7 +610,8 @@ fold_name (etree_type *tree)
                         output_section);
            }
          else if (expld.phase == lang_final_phase_enum
-                  || expld.assigning_to_dot)
+                  || (expld.phase != lang_mark_phase_enum
+                      && expld.assigning_to_dot))
            einfo (_("%F%S: undefined symbol `%s'"
                     " referenced in expression\n"),
                   tree, tree->name.name);
@@ -680,7 +685,7 @@ fold_name (etree_type *tree)
                       tree, tree->name.name);
              new_number (0);
            }
-         else if (os->processed_vma)
+         else if (os->bfd_section != NULL)
            {
              bfd_vma val;
 
@@ -692,6 +697,8 @@ fold_name (etree_type *tree)
              
              new_number (val);
            }
+         else
+           new_number (0);
        }
       break;
 
@@ -797,14 +804,7 @@ exp_fold_tree_1 (etree_type *tree)
          if (tree->type.node_class != etree_assign)
            einfo (_("%F%S can not PROVIDE assignment to"
                     " location counter\n"), tree);
-         /* After allocation, assignment to dot should not be done inside
-            an output section since allocation adds a padding statement
-            that effectively duplicates the assignment.  */
-         if (expld.phase == lang_mark_phase_enum
-             || expld.phase == lang_allocating_phase_enum
-             || ((expld.phase == lang_assigning_phase_enum
-                  || expld.phase == lang_final_phase_enum)
-                 && expld.section == bfd_abs_section_ptr))
+         if (expld.phase != lang_first_phase_enum)
            {
              /* Notify the folder that this is an assignment to dot.  */
              expld.assigning_to_dot = TRUE;
@@ -819,8 +819,14 @@ exp_fold_tree_1 (etree_type *tree)
                }
              else if (expld.dotp == NULL)
                einfo (_("%F%S assignment to location counter"
-                        " invalid outside of SECTION\n"), tree);
-             else
+                        " invalid outside of SECTIONS\n"), tree);
+
+             /* After allocation, assignment to dot should not be
+                done inside an output section since allocation adds a
+                padding statement that effectively duplicates the
+                assignment.  */
+             else if (expld.phase <= lang_allocating_phase_enum
+                      || expld.section == bfd_abs_section_ptr)
                {
                  bfd_vma nextdot;
 
This page took 0.024153 seconds and 4 git commands to generate.