Add support for --disassembler-options=force-thumb
[deliverable/binutils-gdb.git] / bfd / section.c
index da4c4bcba86ab2c81c76b113b4117ba25574c9e4..e2ca4435fb5ead8c15689fcffdc4899c25e3a139 100644 (file)
@@ -1,5 +1,5 @@
 /* Object file "section" support for the BFD library.
-   Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 1997
+   Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 97, 98, 1999
    Free Software Foundation, Inc.
    Written by Cygnus Support.
 
@@ -150,6 +150,27 @@ SUBSECTION
 
 CODE_FRAGMENT
 .
+. {* This structure is used for a comdat section, as in PE.  A comdat
+.    section is associated with a particular symbol.  When the linker
+.    sees a comdat section, it keeps only one of the sections with a
+.    given name and associated with a given symbol. *}
+.
+.struct bfd_comdat_info
+.{
+.  {* The name of the symbol associated with a comdat section.  *}
+.  const char *name;
+.
+.  {* The local symbol table index of the symbol associated with a
+.     comdat section.  This is only meaningful to the object file format
+.     specific code; it is not an index into the list returned by
+.     bfd_canonicalize_symtab.  *}
+.  long symbol;
+.
+.  {* If this section is being discarded, the linker uses this field
+.     to point to the input section which is being kept.  *}
+.  struct sec *sec;
+.};
+.
 .typedef struct sec
 .{
 .        {* The name of the section; the name isn't a copy, the pointer is
@@ -307,6 +328,14 @@ CODE_FRAGMENT
 .      {* This section should not be subject to garbage collection.  *}
 .#define SEC_KEEP 0x1000000
 .
+.      {* This section contains "short" data, and should be placed
+.         "near" the GP.  *}
+.#define SEC_SMALL_DATA 0x2000000
+.
+.      {* This section contains data which may be shared with other
+.         executables or shared objects.  *}
+.#define SEC_SHARED 0x4000000
+.
 .      {*  End of section flags.  *}
 .
 .      {* Some internal packed boolean fields.  *}
@@ -413,6 +442,10 @@ CODE_FRAGMENT
 .
 .   unsigned int lineno_count;
 .
+.       {* Optional information about a COMDAT entry; NULL if not COMDAT *}
+.
+.   struct bfd_comdat_info *comdat;
+.
 .        {* When a section is being output, this value changes as more
 .           linenumbers are written out *}
 .
@@ -477,23 +510,53 @@ CODE_FRAGMENT
 .     ((section->reloc_done) ? (section)->_cooked_size: (abort(),1))
 */
 
+/* We use a macro to initialize the static asymbol structures because
+   traditional C does not permit us to initialize a union member while
+   gcc warns if we don't initialize it.  */
+ /* the_bfd, name, value, attr, section [, udata] */
+#ifdef __STDC__
+#define GLOBAL_SYM_INIT(NAME, SECTION) \
+  { 0, NAME, 0, BSF_SECTION_SYM, (asection *) SECTION, { 0 }}
+#else
+#define GLOBAL_SYM_INIT(NAME, SECTION) \
+  { 0, NAME, 0, BSF_SECTION_SYM, (asection *) SECTION }
+#endif
+
 /* These symbols are global, not specific to any BFD.  Therefore, anything
    that tries to change them is broken, and should be repaired.  */
+
 static const asymbol global_syms[] =
 {
- /* the_bfd, name, value, attr, section [, udata] */
-  {0, BFD_COM_SECTION_NAME, 0, BSF_SECTION_SYM, (asection *) &bfd_com_section},
-  {0, BFD_UND_SECTION_NAME, 0, BSF_SECTION_SYM, (asection *) &bfd_und_section},
-  {0, BFD_ABS_SECTION_NAME, 0, BSF_SECTION_SYM, (asection *) &bfd_abs_section},
-  {0, BFD_IND_SECTION_NAME, 0, BSF_SECTION_SYM, (asection *) &bfd_ind_section},
+  GLOBAL_SYM_INIT (BFD_COM_SECTION_NAME, &bfd_com_section),
+  GLOBAL_SYM_INIT (BFD_UND_SECTION_NAME, &bfd_und_section),
+  GLOBAL_SYM_INIT (BFD_ABS_SECTION_NAME, &bfd_abs_section),
+  GLOBAL_SYM_INIT (BFD_IND_SECTION_NAME, &bfd_ind_section)
 };
 
 #define STD_SECTION(SEC, FLAGS, SYM, NAME, IDX)        \
   const asymbol * const SYM = (asymbol *) &global_syms[IDX]; \
   const asection SEC = \
-    { NAME, 0, 0, FLAGS, 0, 0, 0, 0, 0, 0, 0, 0, 0, (asection *) &SEC, \
-      0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0, \
-      (asymbol *) &global_syms[IDX], (asymbol **) &SYM, 0, 0 }
+    /* name, index, next, flags, set_vma, reloc_done, linker_mark, gc_mark */ \
+    { NAME,  0,     0,    FLAGS, 0,       0,          0,           0,        \
+                                                                             \
+    /* vma, lma, _cooked_size, _raw_size, output_offset, output_section, */   \
+       0,   0,   0,            0,         0,             (struct sec *) &SEC, \
+                                                                             \
+    /* alig..., reloc..., orel..., reloc_count, filepos, rel_..., line_... */ \
+       0,       0,        0,       0,           0,       0,       0,         \
+                                                                             \
+    /* userdata, contents, lineno, lineno_count */                           \
+       0,        0,        0,      0,                                        \
+                                                                             \
+    /* comdat_info, moving_line_filepos, target_index, used_by_bfd,  */       \
+       NULL,        0,                   0,            0,                    \
+                                                                             \
+    /* cons..., owner, symbol */                                             \
+       0,       0,     (struct symbol_cache_entry *) &global_syms[IDX],       \
+                                                                             \
+    /* symbol_ptr_ptr,                      link_order_head, ..._tail */      \
+       (struct symbol_cache_entry **) &SYM, 0,               0                \
+    }
 
 STD_SECTION (bfd_com_section, SEC_IS_COMMON, bfd_com_symbol,
             BFD_COM_SECTION_NAME, 0);
@@ -636,6 +699,7 @@ bfd_make_section_anyway (abfd, name)
   newsect->reloc_count = 0;
   newsect->line_filepos = 0;
   newsect->owner = abfd;
+  newsect->comdat = NULL;
 
   /* Create a symbol whos only job is to point to this section. This is
      useful for things like relocs which are relative to the base of a
@@ -733,7 +797,7 @@ DESCRIPTION
 /*ARGSUSED*/
 boolean
 bfd_set_section_flags (abfd, section, flags)
-     bfd *abfd;
+     bfd *abfd ATTRIBUTE_UNUSED;
      sec_ptr section;
      flagword flags;
 {
@@ -1061,8 +1125,10 @@ _bfd_strip_section_from_output (s)
        break;
       }
 
-  /* If the output section is empty, remove it too.  */
-  if (!os->link_order_head)
+  /* If the output section is empty, remove it too.  Careful about sections
+     that have been discarded in the link script -- they are mapped to 
+     bfd_abs_section, which has no owner.  */
+  if (!os->link_order_head && os->owner)
     {
       for (spp = &os->owner->sections; *spp; spp = &(*spp)->next)
        if (*spp == os)
This page took 0.024647 seconds and 4 git commands to generate.