* gdb.go/package.exp: Partially revert earlier patch; use
[deliverable/binutils-gdb.git] / ld / ldexp.c
index bf0e00b17965e0ffc13040976622ade9173300aa..be296bccf53adcfd53ed7bb11338095e98444905 100644 (file)
@@ -59,7 +59,7 @@ exp_print_token (token_code_type code, int infix_p)
   static const struct
   {
     token_code_type code;
-    char * name;
+    const char * name;
   }
   table[] =
   {
@@ -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;
 
@@ -1145,6 +1151,17 @@ exp_print_tree (etree_type *tree)
        case DATA_SEGMENT_ALIGN:
        case DATA_SEGMENT_RELRO_END:
          function_like = TRUE;
+         break;
+       case SEGMENT_START:
+         /* Special handling because arguments are in reverse order and
+            the segment name is quoted.  */
+         exp_print_token (tree->type.node_code, FALSE);
+         fputs (" (\"", config.map_file);
+         exp_print_tree (tree->binary.rhs);
+         fputs ("\", ", config.map_file);
+         exp_print_tree (tree->binary.lhs);
+         fputc (')', config.map_file);
+         return;
        }
       if (function_like)
        {
This page took 0.035975 seconds and 4 git commands to generate.