home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / gnu / djgpp / src / binutils.2 / ld / ldlang.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-05-30  |  10.5 KB  |  349 lines

  1. /* ldlang.h - linker command language support
  2.    Copyright 1991, 1992 Free Software Foundation, Inc.
  3.    
  4.    This file is part of GLD, the Gnu Linker.
  5.    
  6.    GLD is free software; you can redistribute it and/or modify
  7.    it under the terms of the GNU General Public License as published by
  8.    the Free Software Foundation; either version 1, or (at your option)
  9.    any later version.
  10.    
  11.    GLD is distributed in the hope that it will be useful,
  12.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.    GNU General Public License for more details.
  15.    
  16.    You should have received a copy of the GNU General Public License
  17.    along with GLD; see the file COPYING.  If not, write to
  18.    the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. typedef enum {
  21.   lang_input_file_is_l_enum,
  22.   lang_input_file_is_symbols_only_enum,
  23.   lang_input_file_is_marker_enum,
  24.   lang_input_file_is_fake_enum,
  25.   lang_input_file_is_search_file_enum,
  26.   lang_input_file_is_file_enum } lang_input_file_enum_type;
  27.  
  28. typedef unsigned short fill_type;
  29. typedef struct statement_list {
  30.   union lang_statement_union *head;
  31.   union lang_statement_union **tail;
  32. } lang_statement_list_type;
  33.  
  34.  
  35. typedef struct memory_region_struct {
  36.   char *name;
  37.   struct memory_region_struct *next;
  38.   bfd_vma origin;
  39.   bfd_size_type length;
  40.   bfd_vma current;
  41.   bfd_size_type old_length;
  42.   int flags;
  43.   boolean had_full_message;
  44.  
  45. } lang_memory_region_type ;
  46.  
  47. typedef struct lang_statement_header_struct 
  48.   {
  49.     union  lang_statement_union  *next;
  50.     enum statement_enum {
  51.       lang_output_section_statement_enum,
  52.       lang_assignment_statement_enum,
  53.       lang_input_statement_enum,
  54.       lang_address_statement_enum,
  55.       lang_wild_statement_enum,
  56.       lang_input_section_enum,
  57.       lang_object_symbols_statement_enum,
  58.       lang_fill_statement_enum,
  59.       lang_data_statement_enum,
  60.       lang_target_statement_enum,
  61.       lang_output_statement_enum,
  62.       lang_padding_statement_enum,
  63.       
  64.       lang_afile_asection_pair_statement_enum,
  65.     lang_constructors_statement_enum
  66.       } type;
  67.     
  68.   } lang_statement_header_type;
  69.  
  70.  
  71. typedef struct 
  72.   {
  73.     lang_statement_header_type header;
  74.     union etree_union *exp;
  75.   }  lang_assignment_statement_type;
  76.  
  77.  
  78. typedef struct lang_target_statement_struct {
  79.   lang_statement_header_type header;
  80.   CONST char *target;
  81. } lang_target_statement_type;
  82.  
  83.  
  84. typedef struct lang_output_statement_struct {
  85.   lang_statement_header_type header;
  86.   CONST char *name;
  87. } lang_output_statement_type;
  88.  
  89.  
  90. typedef struct lang_output_section_statement_struct 
  91. {
  92.   lang_statement_header_type header;
  93.   union etree_union *addr_tree;
  94.   lang_statement_list_type children;
  95.   CONST char *memspec;
  96.   union lang_statement_union *next;
  97.   CONST char *name;
  98.  
  99.   boolean processed;
  100.     
  101.   asection *bfd_section;
  102.   int flags;            /* Or together of all input sections */
  103.   int loadable;            /* set from NOLOAD flag in script */
  104.   struct memory_region_struct *region;
  105.   size_t block_value;
  106.   fill_type fill;
  107.  
  108.   int subsection_alignment;  /* alignment of components */
  109.   int section_alignment;  /* alignment of start of section */
  110.  
  111.   union etree_union *load_base;  
  112. } lang_output_section_statement_type;
  113.  
  114.  
  115. typedef struct {
  116.   lang_statement_header_type header;
  117. } lang_common_statement_type;
  118.  
  119. typedef struct {
  120.   lang_statement_header_type header;
  121. } lang_object_symbols_statement_type;
  122.  
  123. typedef struct {
  124.   lang_statement_header_type header;
  125.   fill_type fill;
  126.   int size;
  127.   asection *output_section;
  128. } lang_fill_statement_type;
  129.  
  130. typedef struct {
  131.   lang_statement_header_type header;
  132.   unsigned int type;
  133.   union  etree_union *exp;
  134.   bfd_vma value;
  135.   asection *output_section;
  136.   bfd_vma output_vma;
  137. } lang_data_statement_type;
  138.  
  139.  
  140.  
  141.  
  142. typedef struct lang_input_statement_struct
  143.   {
  144.     lang_statement_header_type header;
  145.     /* Name of this file.  */
  146.     CONST char *filename;
  147.     /* Name to use for the symbol giving address of text start */
  148.     /* Usually the same as filename, but for a file spec'd with -l
  149.        this is the -l switch itself rather than the filename.  */
  150.     CONST char *local_sym_name;
  151.     
  152.     bfd *the_bfd;
  153.     
  154.     boolean closed;
  155.     file_ptr passive_position;
  156.     
  157.     /* Symbol table of the file.  */
  158.     asymbol **asymbols;
  159.     unsigned int symbol_count;
  160.     
  161.     /* For library members only */
  162.     
  163.     /* For a library, points to chain of entries for the library members.  */
  164.     struct lang_input_statement_struct *subfiles;
  165.  
  166.     /* Size of contents of this file, if library member.  */
  167.     bfd_size_type total_size;
  168.  
  169.     /* For library member, points to the library's own entry.  */
  170.     struct lang_input_statement_struct *superfile;
  171.  
  172.     /* For library member, points to next entry for next member.  */
  173.     struct lang_input_statement_struct *chain;
  174.  
  175.     /* Point to the next file - whatever it is, wanders up and down
  176.        archives */
  177.     
  178.     union lang_statement_union  *next;
  179.     /* Point to the next file, but skips archive contents */
  180.     union  lang_statement_union  *next_real_file;
  181.     
  182.     boolean is_archive;
  183.     
  184.     /* 1 means search a set of directories for this file.  */
  185.     boolean search_dirs_flag;
  186.     
  187.     /* 1 means this is base file of incremental load.
  188.        Do not load this file's text or data.
  189.        Also default text_start to after this file's bss. */
  190.     
  191.     boolean just_syms_flag;
  192.     
  193.     boolean loaded;
  194.     
  195.     
  196.     /*    unsigned int globals_in_this_file;*/
  197.     CONST char *target;
  198.     boolean real;
  199.     asection *common_section;
  200.     asection *common_output_section;
  201.     boolean complained;
  202.   } lang_input_statement_type;
  203.  
  204. typedef struct {
  205.   lang_statement_header_type header;
  206.   asection *section;
  207.   lang_input_statement_type *ifile;
  208.   
  209. } lang_input_section_type;
  210.  
  211.  
  212. typedef struct {
  213.   lang_statement_header_type header;
  214.   asection *section;
  215.   union lang_statement_union *file;
  216. } lang_afile_asection_pair_statement_type;
  217.  
  218. typedef struct lang_wild_statement_struct {
  219.   lang_statement_header_type header;
  220.   CONST char *section_name;
  221.   CONST char *filename;
  222.   lang_statement_list_type children;
  223. } lang_wild_statement_type;
  224.  
  225. typedef struct lang_address_statement_struct {
  226.   lang_statement_header_type header;
  227.   CONST  char *section_name;
  228.   union  etree_union *address;
  229. } lang_address_statement_type;
  230.  
  231. typedef struct {
  232.   lang_statement_header_type header;
  233.   bfd_vma output_offset;
  234.   size_t size;
  235.   asection *output_section;
  236.   fill_type fill;
  237. } lang_padding_statement_type;
  238.  
  239. typedef union lang_statement_union 
  240.   {
  241.     lang_statement_header_type header;
  242.     union lang_statement_union *next;
  243.     lang_wild_statement_type wild_statement;
  244.     lang_data_statement_type data_statement;
  245.     lang_address_statement_type address_statement;
  246.     lang_output_section_statement_type output_section_statement;
  247.     lang_afile_asection_pair_statement_type afile_asection_pair_statement;
  248.     lang_assignment_statement_type assignment_statement;
  249.     lang_input_statement_type input_statement;
  250.     lang_target_statement_type target_statement;
  251.     lang_output_statement_type output_statement;
  252.     lang_input_section_type input_section;
  253.     lang_common_statement_type common_statement;
  254.     lang_object_symbols_statement_type object_symbols_statement;
  255.     lang_fill_statement_type fill_statement;
  256.     lang_padding_statement_type padding_statement;
  257.   } lang_statement_union_type;
  258.  
  259.  
  260.  
  261. void lang_init PARAMS ((void));
  262. struct memory_region_struct *
  263.      lang_memory_region_lookup PARAMS ((CONST char *CONST));
  264.  
  265. void lang_map PARAMS ((void));
  266. void lang_set_flags PARAMS ((int *, CONST char *));
  267. void lang_add_output PARAMS ((CONST char *));
  268.  
  269. void lang_final PARAMS ((void));
  270. struct symbol_cache_entry *
  271.      create_symbol PARAMS ((CONST char *, unsigned int, struct sec *));
  272. void lang_process PARAMS ((void));
  273. void lang_section_start PARAMS ((CONST char *, union etree_union *));
  274. void lang_add_entry PARAMS ((CONST char *));
  275. void lang_add_target PARAMS ((CONST char *));
  276. void lang_add_wild PARAMS ((CONST char *CONST , CONST char *CONST));
  277. void lang_add_map PARAMS ((CONST char *));
  278. void lang_add_fill PARAMS ((int));
  279. void lang_add_assignment PARAMS ((union etree_union *));
  280. void lang_add_attribute PARAMS ((enum statement_enum));
  281. void lang_startup PARAMS ((CONST char *));
  282. void lang_float PARAMS ((enum bfd_boolean));
  283. void lang_leave_output_section_statement PARAMS ((bfd_vma, CONST char *));
  284. void lang_abs_symbol_at_end_of PARAMS ((CONST char *, CONST char *));
  285. void lang_abs_symbol_at_beginning_of PARAMS ((CONST char *, CONST char *));
  286. void lang_statement_append PARAMS ((struct statement_list *,
  287.     union lang_statement_union *, union lang_statement_union **));
  288. void lang_for_each_file PARAMS ((void (*dothis)(lang_input_statement_type *)));
  289.  
  290.  
  291. #define LANG_FOR_EACH_INPUT_STATEMENT(statement)               \
  292.   extern lang_statement_list_type file_chain;            \
  293.   lang_input_statement_type *statement;                \
  294.   for (statement = (lang_input_statement_type *)file_chain.head;\
  295.        statement != (lang_input_statement_type *)NULL;        \
  296.        statement = (lang_input_statement_type *)statement->next)\
  297.   
  298. #define LANG_FOR_EACH_INPUT_SECTION(statement, abfd, section, x) \
  299.   { extern lang_statement_list_type file_chain;            \
  300.       lang_input_statement_type *statement;                \
  301.     for (statement = (lang_input_statement_type *)file_chain.head;\
  302.          statement != (lang_input_statement_type *)NULL;        \
  303.          statement = (lang_input_statement_type *)statement->next)\
  304.          {                                \
  305.       asection *section;                    \
  306.     bfd *abfd = statement->the_bfd;                \
  307.       for (section = abfd->sections;                \
  308.        section != (asection *)NULL;                \
  309.        section = section->next) {                \
  310.       x;                            \
  311.   }                                \
  312.   }                                \
  313.  }        
  314.  
  315. #define LANG_FOR_EACH_OUTPUT_SECTION(section, x)        \
  316.   { extern bfd *output_bfd;                    \
  317.       asection *section;                          \
  318.     for (section = output_bfd->sections;                \
  319.          section != (asection *)NULL;                \
  320.          section = section->next)                \
  321.          { x; }                            \
  322.          }
  323.  
  324.  
  325. void lang_process PARAMS ((void));
  326. void ldlang_add_file PARAMS ((lang_input_statement_type *));
  327.  
  328. lang_output_section_statement_type
  329.       *lang_output_section_find PARAMS ((CONST char * CONST));
  330.  
  331. lang_input_statement_type *
  332.       lang_add_input_file PARAMS ((CONST char *name,
  333.                lang_input_file_enum_type file_type,
  334.               CONST char *target));
  335. lang_output_section_statement_type *
  336.       lang_output_section_statement_lookup PARAMS ((CONST char * CONST name));
  337.  
  338. void ldlang_add_undef PARAMS ((CONST char *CONST name));
  339. void lang_add_output_format PARAMS ((CONST char *));
  340.  
  341.  
  342. void lang_list_init PARAMS ((lang_statement_list_type*));
  343.  
  344. void lang_add_data PARAMS ((int type, union etree_union *));
  345.  
  346. void lang_for_each_statement PARAMS ((void (*func)()));
  347.  
  348. PTR stat_alloc PARAMS ((size_t size));
  349.