Added the sizeof_headers keyword.
authorSteve Chamberlain <steve@cygnus>
Wed, 24 Apr 1991 20:53:36 +0000 (20:53 +0000)
committerSteve Chamberlain <steve@cygnus>
Wed, 24 Apr 1991 20:53:36 +0000 (20:53 +0000)
ld/ldexp.c
ld/ldgram.y
ld/ldlang.c
ld/ldlex.l

index f798ac10b9212687daf91023b63501470e10001c..fe86a7ca904c4482cfb8de7c92f2b1d09e8b1b2e 100644 (file)
@@ -282,6 +282,17 @@ bfd_vma dot;
   etree_value_type result;
   switch (tree->type.node_code) 
       {
+      case SIZEOF_HEADERS:
+       if (allocation_done != lang_first_phase_enum) 
+           {
+             result = new_abs(bfd_sizeof_headers(output_bfd,
+                                               config.relocateable_output));
+
+           }
+       else {
+         result.valid = false;
+       }
+       break;
       case DEFINED:
        result.value =
          ldsym_get_soft(tree->name.name) != (ldsym_type *)NULL;
@@ -323,7 +334,7 @@ bfd_vma dot;
                      ((lang_input_statement_type*)(sdef->the_bfd->usrdata))->just_syms_flag == true) 
                      {
                        result = new_abs(sdef->value + (sdef->section ?
-                                        sdef->section->vma : 0));
+                                                       sdef->section->vma : 0));
                      }
                  else {
                    result = new_rel(sdef->value + sdef->section->output_offset, os);
@@ -423,7 +434,14 @@ bfd_vma *dotp;
                      result.value = -result.value;
                      break;
                    case NEXT:
+                     if (allocation_done ==lang_allocating_phase_enum) {
+                       make_abs(&result);
+                       result.value = ALIGN(dot, result.value);
+                     }
+                     else {
+                     /* Return next place aligned to value */
                      result.valid = false;
+                   }
                      break;
                    default:
                      FAIL();
@@ -767,3 +785,4 @@ lang_phase_type allocation_done;
 {
   return (int)exp_get_vma(tree,(bfd_vma)def,name, allocation_done);
 }
+
index 8bde4e4babb9c96c0d08e9661499ad7c667d6eb0..d0196b1433dbf0472b485639495f9841fc357ee3 100644 (file)
@@ -113,7 +113,7 @@ boolean ldgram_had_equals = false;
 %token SECTIONS  
 %token '{' '}'
 %token ALIGNMENT SIZEOF_HEADERS OUTPUT_FORMAT FORCE_COMMON_ALLOCATION OUTPUT_ARCH
-%token NEXT SIZEOF ADDR  SCRIPT ENDSCRIPT
+%token NEXT SIZEOF ADDR  SCRIPT ENDSCRIPT SIZEOF_HEADERS
 %token MEMORY 
 %token DSECT NOLOAD COPY INFO OVERLAY 
 %token NAME DEFINED TARGET_K SEARCH_DIR MAP ENTRY 
@@ -621,6 +621,8 @@ exp :
                        { $$ = exp_nameop(DEFINED, $3); }
        |       INT
                        { $$ = exp_intop($1); }
+        |      SIZEOF_HEADERS 
+                       { $$ = exp_nameop(SIZEOF_HEADERS,0); }
 
        |       SIZEOF  '('  NAME ')'
                        { $$ = exp_nameop($1,$3); }
index b124ac76dc72107c3aa716ea4a8e9c41a4eee732..ba165bd6a8080be04b5151085d7b2acaea23d804 100644 (file)
@@ -1060,7 +1060,7 @@ DEFUN(print_data_statement,(data),
   print_space();
   print_section("");
   print_space();
-  ASSERT(print_dot == data->output_vma);
+/*  ASSERT(print_dot == data->output_vma);*/
 
   print_address(data->output_vma);
   print_space();
@@ -1352,7 +1352,7 @@ DEFUN(lang_size_sections,(s, output_section_statement, prev, fill, dot),
        case lang_data_statement_enum: 
            {
              unsigned int size;
-             s->data_statement.output_vma = dot;
+             s->data_statement.output_vma = dot - output_section_statement->bfd_section->vma;
              s->data_statement.output_section =
                output_section_statement->bfd_section;
 
index d1f448ff0ae604675e26e2e8c8273b24478c787f..12105550b4664979abb1e29eb68e620719c0eb77 100644 (file)
@@ -74,6 +74,8 @@ keyword_type keywords[] =
 "SCRIPT", SCRIPT,
 "ENDSCRIPT", ENDSCRIPT,
 "NEXT",NEXT,
+"sizeof_headers",SIZEOF_HEADERS,
+"SIZEOF_HEADERS",SIZEOF_HEADERS,
 "MAP",MAP,
 "SIZEOF",SIZEOF,
 "TARGET",TARGET_K,