* merge.h (Output_merge_string::Merged_string): Remove object, shndx,
[binutils-gdb.git] / gold / script-c.h
index 496e18b5f24112c66edc02518d361801f8704f6c..29901e3c3a8c77887b4bf44de1096980379a8a70 100644 (file)
@@ -61,6 +61,33 @@ typedef Expression* Expression_ptr;
 typedef void* Expression_ptr;
 #endif
 
+/* Script_section type.  */
+enum Script_section_type
+{
+  /* No section type.  */
+  SCRIPT_SECTION_TYPE_NONE,
+  SCRIPT_SECTION_TYPE_NOLOAD,
+  SCRIPT_SECTION_TYPE_DSECT,
+  SCRIPT_SECTION_TYPE_COPY,
+  SCRIPT_SECTION_TYPE_INFO,
+  SCRIPT_SECTION_TYPE_OVERLAY
+};
+
+/* A constraint for whether to use a particular output section
+   definition.  */
+
+enum Section_constraint
+{
+  /* No constraint.  */
+  CONSTRAINT_NONE,
+  /* Only if all input sections are read-only.  */
+  CONSTRAINT_ONLY_IF_RO,
+  /* Only if at least input section is writable.  */
+  CONSTRAINT_ONLY_IF_RW,
+  /* Special constraint.  */
+  CONSTRAINT_SPECIAL
+};
+
 /* The information we store for an output section header in the bison
    parser.  */
 
@@ -68,6 +95,8 @@ struct Parser_output_section_header
 {
   /* The address.  This may be NULL.  */
   Expression_ptr address;
+  /* Section type.  May be NULL string.  */ 
+  enum Script_section_type section_type;
   /* The load address, from the AT specifier.  This may be NULL.  */
   Expression_ptr load_address;
   /* The alignment, from the ALIGN specifier.  This may be NULL.  */
@@ -75,15 +104,8 @@ struct Parser_output_section_header
   /* The input section alignment, from the SUBALIGN specifier.  This
      may be NULL.  */
   Expression_ptr subalign;
-};
-
-/* The information we store for an output section trailer in the bison
-   parser.  */
-
-struct Parser_output_section_trailer
-{
-  /* The fill value.  This may be NULL.  */
-  Expression_ptr fill;
+  /* A constraint on this output section.  */
+  enum Section_constraint constraint;
 };
 
 /* We keep vectors of strings.  In order to manage this in both C and
@@ -97,6 +119,18 @@ typedef String_list* String_list_ptr;
 typedef void* String_list_ptr;
 #endif
 
+/* The information we store for an output section trailer in the bison
+   parser.  */
+
+struct Parser_output_section_trailer
+{
+  /* The fill value.  This may be NULL.  */
+  Expression_ptr fill;
+  /* The program segments this section should go into.  This may be
+     NULL.  */
+  String_list_ptr phdrs;
+};
+
 /* The different sorts we can find in a linker script.  */
 
 enum Sort_wildcard
@@ -148,6 +182,22 @@ struct Input_section_spec
   struct Wildcard_sections input_sections;
 };
 
+/* Information for a program header.  */
+
+struct Phdr_info
+{
+  /* A boolean value: whether to include the file header.  */
+  int includes_filehdr;
+  /* A boolean value: whether to include the program headers.  */
+  int includes_phdrs;
+  /* A boolean value: whether the flags field is valid.  */
+  int is_flags_valid;
+  /* The value to use for the flags.  */
+  unsigned int flags;
+  /* The load address.  */
+  Expression_ptr load_address;
+};
+
 struct Version_dependency_list;
 struct Version_expression_list;
 struct Version_tree;
@@ -175,11 +225,22 @@ yylex(YYSTYPE*, void* closure);
 extern void
 yyerror(void* closure, const char*);
 
+/* Called by the bison parser to add an external symbol (a symbol in
+   an EXTERN declaration) to the link.  */
+
+extern void
+script_add_extern(void* closure, const char*, size_t);
+
 /* Called by the bison parser to add a file to the link.  */
 
 extern void
 script_add_file(void* closure, const char*, size_t);
 
+/* Called by the bison parser to add a library to the link.  */
+
+extern void
+script_add_library(void* closure, const char*, size_t);
+
 /* Called by the bison parser to start and stop a group.  */
 
 extern void
@@ -199,11 +260,32 @@ script_end_as_needed(void* closure);
 extern void
 script_set_entry(void* closure, const char*, size_t);
 
+/* Called by the bison parser to set whether to define common symbols.  */
+
+extern void
+script_set_common_allocation(void* closure, int);
+
 /* Called by the bison parser to parse an OPTION.  */
 
 extern void
 script_parse_option(void* closure, const char*, size_t);
 
+/* Called by the bison parser to handle OUTPUT_FORMAT.  This return 0
+   if the parse should be aborted.  */
+
+extern int
+script_check_output_format(void* closure, const char*, size_t,
+                          const char*, size_t, const char*, size_t);
+
+/* Called by the bison parser to handle TARGET.  */
+extern void
+script_set_target(void* closure, const char*, size_t);
+
+/* Called by the bison parser to handle SEARCH_DIR.  */
+
+extern void
+script_add_search_dir(void* closure, const char*, size_t);
+
 /* Called by the bison parser to push the lexer into expression
    mode.  */
 
@@ -307,6 +389,30 @@ script_string_list_push_back(String_list_ptr, const char*, size_t);
 extern String_list_ptr
 script_string_list_append(String_list_ptr, String_list_ptr);
 
+/* Define a new program header.  */
+
+extern void
+script_add_phdr(void* closure, const char* name, size_t namelen,
+               unsigned int type, const struct Phdr_info*);
+
+/* Convert a program header string to a type.  */
+
+extern unsigned int
+script_phdr_string_to_type(void* closure, const char*, size_t);
+
+/* Handle DATA_SEGMENT_ALIGN and DATA_SEGMENT_RELRO_END.  */
+
+extern void
+script_data_segment_align(void* closure);
+
+extern void
+script_data_segment_relro_end(void* closure);
+
+/* Record the fact that a SEGMENT_START expression is seen.  */
+
+extern void
+script_saw_segment_start_expression(void* closure);
+
 /* Called by the bison parser for expressions.  */
 
 extern Expression_ptr