gdb/
[deliverable/binutils-gdb.git] / gold / expression.cc
index 6d18679971c3fd3e93f0e00d6346f512cdc584ca..e527b5e382cd53be2eda1bd16f330a0ffbfed5a2 100644 (file)
@@ -76,9 +76,8 @@ uint64_t
 Expression::eval(const Symbol_table* symtab, const Layout* layout,
                 bool check_assertions)
 {
-  Output_section* dummy;
   return this->eval_maybe_dot(symtab, layout, check_assertions,
-                             false, 0, NULL, &dummy, NULL);
+                             false, 0, NULL, NULL, NULL);
 }
 
 // Evaluate an expression which may refer to the dot symbol.
@@ -115,7 +114,8 @@ Expression::eval_maybe_dot(const Symbol_table* symtab, const Layout* layout,
 
   // We assume the value is absolute, and only set this to a section
   // if we find a section relative reference.
-  *result_section_pointer = NULL;
+  if (result_section_pointer != NULL)
+    *result_section_pointer = NULL;
   eei.result_section_pointer = result_section_pointer;
 
   eei.result_alignment_pointer = result_alignment_pointer;
@@ -181,7 +181,8 @@ Symbol_expression::value(const Expression_eval_info* eei)
       return 0;
     }
 
-  *eei->result_section_pointer = sym->output_section();
+  if (eei->result_section_pointer != NULL)
+    *eei->result_section_pointer = sym->output_section();
 
   if (parameters->target().get_size() == 32)
     return eei->symtab->get_sized_symbol<32>(sym)->value();
@@ -217,7 +218,8 @@ Dot_expression::value(const Expression_eval_info* eei)
                   "SECTIONS clause"));
       return 0;
     }
-  *eei->result_section_pointer = eei->dot_section;
+  if (eei->result_section_pointer != NULL)
+    *eei->result_section_pointer = eei->dot_section;
   return eei->dot_value;
 }
 
@@ -397,26 +399,30 @@ class Binary_expression : public Expression
     value(const Expression_eval_info* eei)                             \
     {                                                                  \
       Output_section* left_section;                                    \
-      uint64_t left_alignment;                                         \
+      uint64_t left_alignment = 0;                                     \
       uint64_t left = this->left_value(eei, &left_section,             \
                                       &left_alignment);                \
       Output_section* right_section;                                   \
-      uint64_t right_alignment;                                                \
+      uint64_t right_alignment = 0;                                    \
       uint64_t right = this->right_value(eei, &right_section,          \
                                         &right_alignment);             \
       if (KEEP_RIGHT && left_section == NULL && right_section != NULL) \
        {                                                               \
-         *eei->result_section_pointer = right_section;                 \
-         if (eei->result_alignment_pointer != NULL)                    \
+         if (eei->result_section_pointer != NULL)                      \
+           *eei->result_section_pointer = right_section;               \
+         if (eei->result_alignment_pointer != NULL                     \
+             && right_alignment > *eei->result_alignment_pointer)      \
            *eei->result_alignment_pointer = right_alignment;           \
        }                                                               \
       else if (KEEP_LEFT                                               \
               && left_section != NULL                                  \
               && right_section == NULL)                                \
        {                                                               \
-         *eei->result_section_pointer = left_section;                  \
-         if (eei->result_alignment_pointer != NULL)                    \
-           *eei->result_alignment_pointer = right_alignment;           \
+         if (eei->result_section_pointer != NULL)                      \
+           *eei->result_section_pointer = left_section;                \
+         if (eei->result_alignment_pointer != NULL                     \
+             && left_alignment > *eei->result_alignment_pointer)       \
+           *eei->result_alignment_pointer = left_alignment;            \
        }                                                               \
       else if ((WARN || left_section != right_section)                 \
               && (left_section != NULL || right_section != NULL)       \
@@ -602,7 +608,10 @@ class Max_expression : public Binary_expression
     uint64_t right_alignment;
     uint64_t right = this->right_value(eei, &right_section, &right_alignment);
     if (left_section == right_section)
-      *eei->result_section_pointer = left_section;
+      {
+       if (eei->result_section_pointer != NULL)
+         *eei->result_section_pointer = left_section;
+      }
     else if ((left_section != NULL || right_section != NULL)
             && parameters->options().relocatable())
       gold_warning(_("max applied to section relative value"));
@@ -650,7 +659,10 @@ class Min_expression : public Binary_expression
     uint64_t right_alignment;
     uint64_t right = this->right_value(eei, &right_section, &right_alignment);
     if (left_section == right_section)
-      *eei->result_section_pointer = left_section;
+      {
+       if (eei->result_section_pointer != NULL)
+         *eei->result_section_pointer = left_section;
+      }
     else if ((left_section != NULL || right_section != NULL)
             && parameters->options().relocatable())
       gold_warning(_("min applied to section relative value"));
@@ -756,10 +768,10 @@ class Absolute_expression : public Unary_expression
   uint64_t
   value(const Expression_eval_info* eei)
   {
-    Output_section* dummy;
-    uint64_t ret = this->arg_value(eei, &dummy);
+    uint64_t ret = this->arg_value(eei, NULL);
     // Force the value to be absolute.
-    *eei->result_section_pointer = NULL;
+    if (eei->result_section_pointer != NULL)
+      *eei->result_section_pointer = NULL;
     return ret;
   }
 
@@ -873,7 +885,8 @@ class Addr_expression : public Section_expression
   value_from_output_section(const Expression_eval_info* eei,
                            Output_section* os)
   {
-    *eei->result_section_pointer = os;
+    if (eei->result_section_pointer != NULL)
+      *eei->result_section_pointer = os;
     return os->address();
   }
 
@@ -1078,7 +1091,8 @@ class Loadaddr_expression : public Section_expression
       return os->load_address();
     else
       {
-       *eei->result_section_pointer = os;
+       if (eei->result_section_pointer != NULL)
+         *eei->result_section_pointer = os;
        return os->address();
       }
   }
@@ -1220,10 +1234,10 @@ Segment_start_expression::value(const Expression_eval_info* eei)
     return parameters->options().Tbss();
   else
     {
-      Output_section* dummy;
-      uint64_t ret = this->arg_value(eei, &dummy);
+      uint64_t ret = this->arg_value(eei, NULL);
       // Force the value to be absolute.
-      *eei->result_section_pointer = NULL;
+      if (eei->result_section_pointer != NULL)
+        *eei->result_section_pointer = NULL;
       return ret;
     }
 }
@@ -1237,19 +1251,4 @@ script_exp_function_segment_start(const char* segment_name,
                                      default_value);
 }
 
-// Functions for memory regions.  These can not be implemented unless
-// and until we implement memory regions.
-
-extern "C" Expression*
-script_exp_function_origin(const char*, size_t)
-{
-  gold_fatal(_("ORIGIN not implemented"));
-}
-
-extern "C" Expression*
-script_exp_function_length(const char*, size_t)
-{
-  gold_fatal(_("LENGTH not implemented"));
-}
-
 } // End namespace gold.
This page took 0.026291 seconds and 4 git commands to generate.