home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / binutils-2.7-src.tgz / tar.out / fsf / binutils / ld / ldlang.h < prev    next >
C/C++ Source or Header  |  1996-09-28  |  13KB  |  446 lines

  1. /* ldlang.h - linker command language support
  2.    Copyright 1991, 92, 93, 94, 95, 1996 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
  19.  
  20. #ifndef LDLANG_H
  21. #define LDLANG_H
  22.  
  23. typedef enum
  24. {
  25.   lang_input_file_is_l_enum,
  26.   lang_input_file_is_symbols_only_enum,
  27.   lang_input_file_is_marker_enum,
  28.   lang_input_file_is_fake_enum,
  29.   lang_input_file_is_search_file_enum,
  30.   lang_input_file_is_file_enum
  31. } lang_input_file_enum_type;
  32.  
  33. typedef unsigned int fill_type;
  34. typedef struct statement_list
  35. {
  36.   union lang_statement_union *head;
  37.   union lang_statement_union **tail;
  38. } lang_statement_list_type;
  39.  
  40.  
  41. typedef struct memory_region_struct
  42. {
  43.   char *name;
  44.   struct memory_region_struct *next;
  45.   bfd_vma origin;
  46.   bfd_size_type length;
  47.   bfd_vma current;
  48.   bfd_size_type old_length;
  49.   int flags;
  50.   boolean had_full_message;
  51. } lang_memory_region_type ;
  52.  
  53. typedef struct lang_statement_header_struct 
  54. {
  55.   union  lang_statement_union  *next;
  56.   enum statement_enum
  57.     {
  58.       lang_output_section_statement_enum,
  59.       lang_assignment_statement_enum,
  60.       lang_input_statement_enum,
  61.       lang_address_statement_enum,
  62.       lang_wild_statement_enum,
  63.       lang_input_section_enum,
  64.       lang_object_symbols_statement_enum,
  65.       lang_fill_statement_enum,
  66.       lang_data_statement_enum,
  67.       lang_reloc_statement_enum,
  68.       lang_target_statement_enum,
  69.       lang_output_statement_enum,
  70.       lang_padding_statement_enum,
  71.       lang_group_statement_enum,
  72.  
  73.       lang_afile_asection_pair_statement_enum,
  74.       lang_constructors_statement_enum
  75.     } type;
  76. } lang_statement_header_type;
  77.  
  78.  
  79. typedef struct 
  80. {
  81.   lang_statement_header_type header;
  82.   union etree_union *exp;
  83. } lang_assignment_statement_type;
  84.  
  85.  
  86. typedef struct lang_target_statement_struct
  87. {
  88.   lang_statement_header_type header;
  89.   const char *target;
  90. } lang_target_statement_type;
  91.  
  92.  
  93. typedef struct lang_output_statement_struct
  94. {
  95.   lang_statement_header_type header;
  96.   const char *name;
  97. } lang_output_statement_type;
  98.  
  99. /* Section types specified in a linker script.  */
  100.  
  101. enum section_type
  102. {
  103.   normal_section,
  104.   dsect_section,
  105.   copy_section,
  106.   noload_section,
  107.   info_section,
  108.   overlay_section
  109. };
  110.  
  111. /* This structure holds a list of program headers describing segments
  112.    in which this section should be placed.  */
  113.  
  114. struct lang_output_section_phdr_list
  115. {
  116.   struct lang_output_section_phdr_list *next;
  117.   const char *name;
  118.   boolean used;
  119. };
  120.  
  121. typedef struct lang_output_section_statement_struct 
  122. {
  123.   lang_statement_header_type header;
  124.   union etree_union *addr_tree;
  125.   lang_statement_list_type children;
  126.   const char *memspec;
  127.   union lang_statement_union *next;
  128.   const char *name;
  129.  
  130.   boolean processed;
  131.     
  132.   asection *bfd_section;
  133.   int flags;            /* Or together of all input sections */
  134.   enum section_type sectype;
  135.   struct memory_region_struct *region;
  136.   size_t block_value;
  137.   fill_type fill;
  138.  
  139.   int subsection_alignment;  /* alignment of components */
  140.   int section_alignment;  /* alignment of start of section */
  141.  
  142.   union etree_union *load_base;
  143.  
  144.   struct lang_output_section_phdr_list *phdrs;
  145. } lang_output_section_statement_type;
  146.  
  147.  
  148. typedef struct
  149. {
  150.   lang_statement_header_type header;
  151. } lang_common_statement_type;
  152.  
  153. typedef struct
  154. {
  155.   lang_statement_header_type header;
  156. } lang_object_symbols_statement_type;
  157.  
  158. typedef struct
  159. {
  160.   lang_statement_header_type header;
  161.   fill_type fill;
  162.   int size;
  163.   asection *output_section;
  164. } lang_fill_statement_type;
  165.  
  166. typedef struct
  167. {
  168.   lang_statement_header_type header;
  169.   unsigned int type;
  170.   union  etree_union *exp;
  171.   bfd_vma value;
  172.   asection *output_section;
  173.   bfd_vma output_vma;
  174. } lang_data_statement_type;
  175.  
  176. /* Generate a reloc in the output file.  */
  177.  
  178. typedef struct
  179. {
  180.   lang_statement_header_type header;
  181.  
  182.   /* Reloc to generate.  */
  183.   bfd_reloc_code_real_type reloc;
  184.  
  185.   /* Reloc howto structure.  */
  186.   reloc_howto_type *howto;
  187.  
  188.   /* Section to generate reloc against.  Exactly one of section and
  189.      name must be NULL.  */
  190.   asection *section;
  191.  
  192.   /* Name of symbol to generate reloc against.  Exactly one of section
  193.      and name must be NULL.  */
  194.   const char *name;
  195.  
  196.   /* Expression for addend.  */
  197.   union etree_union *addend_exp;
  198.  
  199.   /* Resolved addend.  */
  200.   bfd_vma addend_value;
  201.  
  202.   /* Output section where reloc should be performed.  */
  203.   asection *output_section;
  204.  
  205.   /* VMA within output section.  */
  206.   bfd_vma output_vma;
  207. } lang_reloc_statement_type;
  208.  
  209. typedef struct lang_input_statement_struct
  210. {
  211.   lang_statement_header_type header;
  212.   /* Name of this file.  */
  213.   const char *filename;
  214.   /* Name to use for the symbol giving address of text start */
  215.   /* Usually the same as filename, but for a file spec'd with -l
  216.      this is the -l switch itself rather than the filename.  */
  217.   const char *local_sym_name;
  218.     
  219.   bfd *the_bfd;
  220.     
  221.   boolean closed;
  222.   file_ptr passive_position;
  223.     
  224.   /* Symbol table of the file.  */
  225.   asymbol **asymbols;
  226.   unsigned int symbol_count;
  227.     
  228.   /* Point to the next file - whatever it is, wanders up and down
  229.      archives */
  230.     
  231.   union lang_statement_union  *next;
  232.   /* Point to the next file, but skips archive contents */
  233.   union  lang_statement_union  *next_real_file;
  234.     
  235.   boolean is_archive;
  236.     
  237.   /* 1 means search a set of directories for this file.  */
  238.   boolean search_dirs_flag;
  239.     
  240.   /* 1 means this is base file of incremental load.
  241.      Do not load this file's text or data.
  242.      Also default text_start to after this file's bss. */
  243.     
  244.   boolean just_syms_flag;
  245.  
  246.   /* Whether to search for this entry as a dynamic archive.  */
  247.   boolean dynamic;
  248.  
  249.   /* Whether to include the entire contents of an archive.  */
  250.   boolean whole_archive;
  251.  
  252.   boolean loaded;
  253.     
  254.   /*    unsigned int globals_in_this_file;*/
  255.   const char *target;
  256.   boolean real;
  257.   /* Added for AMIGA support of section attributes */
  258.   int amiga_attribute;
  259. } lang_input_statement_type;
  260.  
  261. typedef struct
  262. {
  263.   lang_statement_header_type header;
  264.   asection *section;
  265.   lang_input_statement_type *ifile;
  266.   
  267. } lang_input_section_type;
  268.  
  269.  
  270. typedef struct
  271. {
  272.   lang_statement_header_type header;
  273.   asection *section;
  274.   union lang_statement_union *file;
  275. } lang_afile_asection_pair_statement_type;
  276.  
  277. typedef struct lang_wild_statement_struct
  278. {
  279.   lang_statement_header_type header;
  280.   const char *section_name;
  281.   const char *filename;
  282.   lang_statement_list_type children;
  283. } lang_wild_statement_type;
  284.  
  285. typedef struct lang_address_statement_struct
  286. {
  287.   lang_statement_header_type header;
  288.   const  char *section_name;
  289.   union  etree_union *address;
  290. } lang_address_statement_type;
  291.  
  292. typedef struct
  293. {
  294.   lang_statement_header_type header;
  295.   bfd_vma output_offset;
  296.   size_t size;
  297.   asection *output_section;
  298.   fill_type fill;
  299. } lang_padding_statement_type;
  300.  
  301. /* A group statement collects a set of libraries together.  The
  302.    libraries are searched multiple times, until no new undefined
  303.    symbols are found.  The effect is to search a group of libraries as
  304.    though they were a single library.  */
  305.  
  306. typedef struct
  307. {
  308.   lang_statement_header_type header;
  309.   lang_statement_list_type children;
  310. } lang_group_statement_type;
  311.  
  312. typedef union lang_statement_union 
  313. {
  314.   lang_statement_header_type header;
  315.   union lang_statement_union *next;
  316.   lang_wild_statement_type wild_statement;
  317.   lang_data_statement_type data_statement;
  318.   lang_reloc_statement_type reloc_statement;
  319.   lang_address_statement_type address_statement;
  320.   lang_output_section_statement_type output_section_statement;
  321.   lang_afile_asection_pair_statement_type afile_asection_pair_statement;
  322.   lang_assignment_statement_type assignment_statement;
  323.   lang_input_statement_type input_statement;
  324.   lang_target_statement_type target_statement;
  325.   lang_output_statement_type output_statement;
  326.   lang_input_section_type input_section;
  327.   lang_common_statement_type common_statement;
  328.   lang_object_symbols_statement_type object_symbols_statement;
  329.   lang_fill_statement_type fill_statement;
  330.   lang_padding_statement_type padding_statement;
  331.   lang_group_statement_type group_statement;
  332. } lang_statement_union_type;
  333.  
  334. /* This structure holds information about a program header, from the
  335.    PHDRS command in the linker script.  */
  336.  
  337. struct lang_phdr
  338. {
  339.   struct lang_phdr *next;
  340.   const char *name;
  341.   unsigned long type;
  342.   boolean filehdr;
  343.   boolean phdrs;
  344.   etree_type *at;
  345.   etree_type *flags;
  346. };
  347.  
  348. extern lang_output_section_statement_type *abs_output_section;
  349. extern boolean lang_has_input_file;
  350. extern etree_type *base;
  351. extern lang_statement_list_type *stat_ptr;
  352. extern boolean delete_output_file_on_failure;
  353.  
  354. extern const char *entry_symbol;
  355. extern boolean entry_from_cmdline;
  356.  
  357. extern void lang_init PARAMS ((void));
  358. extern struct memory_region_struct *lang_memory_region_lookup
  359.   PARAMS ((const char *const));
  360. extern void lang_map PARAMS ((void));
  361. extern void lang_set_flags PARAMS ((int *, const char *));
  362. extern void lang_add_output PARAMS ((const char *, int from_script));
  363. extern void lang_enter_output_section_statement
  364.   PARAMS ((const char *output_section_statement_name,
  365.        etree_type * address_exp,
  366.        enum section_type sectype,
  367.        bfd_vma block_value,
  368.        etree_type *align,
  369.        etree_type *subalign,
  370.        etree_type *));
  371. extern void lang_final PARAMS ((void));
  372. extern void lang_process PARAMS ((void));
  373. extern void lang_section_start PARAMS ((const char *, union etree_union *));
  374. extern void lang_add_entry PARAMS ((const char *, boolean));
  375. extern void lang_add_target PARAMS ((const char *));
  376. extern void lang_add_wild PARAMS ((const char *const , const char *const));
  377. extern void lang_add_map PARAMS ((const char *));
  378. extern void lang_add_fill PARAMS ((int));
  379. extern void lang_add_assignment PARAMS ((union etree_union *));
  380. extern void lang_add_attribute PARAMS ((enum statement_enum));
  381. extern void lang_startup PARAMS ((const char *));
  382. extern void lang_float PARAMS ((enum bfd_boolean));
  383. extern void lang_leave_output_section_statement PARAMS ((bfd_vma,
  384.                              const char *));
  385. extern void lang_abs_symbol_at_end_of PARAMS ((const char *, const char *));
  386. extern void lang_abs_symbol_at_beginning_of PARAMS ((const char *,
  387.                              const char *));
  388. extern void lang_statement_append PARAMS ((struct statement_list *,
  389.                        union lang_statement_union *,
  390.                        union lang_statement_union **));
  391. extern void lang_for_each_input_file
  392.   PARAMS ((void (*dothis) (lang_input_statement_type *)));
  393. extern void lang_for_each_file
  394.   PARAMS ((void (*dothis) (lang_input_statement_type *)));
  395. extern bfd_vma lang_do_assignments
  396.   PARAMS ((lang_statement_union_type * s,
  397.        lang_output_section_statement_type *output_section_statement,
  398.        fill_type fill,
  399.        bfd_vma dot));
  400.  
  401. #define LANG_FOR_EACH_INPUT_STATEMENT(statement)        \
  402.   extern lang_statement_list_type file_chain;            \
  403.   lang_input_statement_type *statement;                \
  404.   for (statement = (lang_input_statement_type *)file_chain.head;\
  405.        statement != (lang_input_statement_type *)NULL;        \
  406.        statement = (lang_input_statement_type *)statement->next)\
  407.   
  408. extern void lang_process PARAMS ((void));
  409. extern void ldlang_add_file PARAMS ((lang_input_statement_type *));
  410. extern lang_output_section_statement_type *lang_output_section_find
  411.   PARAMS ((const char * const));
  412. extern lang_input_statement_type *lang_add_input_file
  413.   PARAMS ((const char *name, lang_input_file_enum_type file_type,
  414.        const char *target));
  415. extern void lang_add_keepsyms_file PARAMS ((const char *filename));
  416. extern lang_output_section_statement_type *
  417.   lang_output_section_statement_lookup PARAMS ((const char * const name));
  418. extern void ldlang_add_undef PARAMS ((const char *const name));
  419. extern void lang_add_output_format PARAMS ((const char *, const char *,
  420.                         const char *, int from_script));
  421. extern void lang_list_init PARAMS ((lang_statement_list_type*));
  422. extern void lang_add_data PARAMS ((int type, union etree_union *));
  423. extern void lang_add_reloc
  424.   PARAMS ((bfd_reloc_code_real_type reloc, reloc_howto_type *howto,
  425.        asection *section, const char *name, union etree_union *addend));
  426. extern void lang_for_each_statement
  427.   PARAMS ((void (*func) (lang_statement_union_type *)));
  428. extern PTR stat_alloc PARAMS ((size_t size));
  429. extern bfd_vma lang_size_sections
  430.   PARAMS ((lang_statement_union_type *s,
  431.        lang_output_section_statement_type *output_section_statement,
  432.        lang_statement_union_type **prev, fill_type fill,
  433.        bfd_vma dot, boolean relax));
  434. extern void lang_enter_group PARAMS ((void));
  435. extern void lang_leave_group PARAMS ((void));
  436. extern void wild_doit
  437.   PARAMS ((lang_statement_list_type *ptr, asection *section,
  438.        lang_output_section_statement_type *output,
  439.        lang_input_statement_type *file));
  440. extern void lang_new_phdr
  441.   PARAMS ((const char *, etree_type *, boolean, boolean, etree_type *,
  442.        etree_type *));
  443. extern void lang_section_in_phdr PARAMS ((const char *));
  444.  
  445. #endif
  446.