]> Git Repo - binutils.git/blobdiff - bfd/aoutx.h
* elf.c (_bfd_elf_make_section_from_shdr): New function, based on
[binutils.git] / bfd / aoutx.h
index ca56a50c763a801d848cdd97a9c215c36915aebb..c65924d0c8faa5075e0b99d85e11516065586711 100644 (file)
@@ -121,7 +121,6 @@ DESCRIPTION
 #define KEEPIT flags
 #define KEEPITTYPE int
 
-#include <assert.h>
 #include <string.h>            /* For strchr and friends */
 #include "bfd.h"
 #include <sysdep.h>
@@ -198,6 +197,29 @@ HOWTO( 7,         0,  4,   64, true,  0, complain_overflow_signed,  0,"DISP64",    tr
 { -1 },
 HOWTO( 9,             0,  1,   16, false, 0, complain_overflow_bitfield,0,"BASE16",    false,0xffffffff,0xffffffff, false),
 HOWTO(10,             0,  2,   32, false, 0, complain_overflow_bitfield,0,"BASE32",    false,0xffffffff,0xffffffff, false),
+{ -1 },
+{ -1 },
+{ -1 },
+{ -1 },
+{ -1 },
+  HOWTO(16,           0,  2,    0, false, 0, complain_overflow_bitfield,0,"JMP_TABLE", false,         0,0x00000000, false),
+{ -1 },
+{ -1 },
+{ -1 },
+{ -1 },
+{ -1 },
+{ -1 },
+{ -1 },
+{ -1 }, { -1 }, { -1 }, { -1 }, { -1 }, { -1 }, { -1 }, { -1 },
+  HOWTO(32,           0,  2,    0, false, 0, complain_overflow_bitfield,0,"RELATIVE",  false,         0,0x00000000, false),
+{ -1 },
+{ -1 },
+{ -1 },
+{ -1 },
+{ -1 },
+{ -1 },
+{ -1 },
+  HOWTO(40,           0,  2,    0, false, 0, complain_overflow_bitfield,0,"BASEREL",   false,         0,0x00000000, false),
 };
 
 #define TABLE_SIZE(TABLE)      (sizeof(TABLE)/sizeof(TABLE[0]))
@@ -334,7 +356,23 @@ NAME(aout,swap_exec_header_out) (abfd, execp, raw_bytes)
   PUT_WORD (abfd, execp->a_drsize, bytes->e_drsize);
 }
 
+/* Make all the section for an a.out file.  */
 
+boolean
+NAME(aout,make_sections) (abfd)
+     bfd *abfd;
+{
+  if (obj_textsec (abfd) == (asection *) NULL
+      && bfd_make_section (abfd, ".text") == (asection *) NULL)
+    return false;
+  if (obj_datasec (abfd) == (asection *) NULL
+      && bfd_make_section (abfd, ".data") == (asection *) NULL)
+    return false;
+  if (obj_bsssec (abfd) == (asection *) NULL
+      && bfd_make_section (abfd, ".bss") == (asection *) NULL)
+    return false;
+  return true;
+}
 
 /*
 FUNCTION
@@ -420,18 +458,8 @@ NAME(aout,some_aout_object_p) (abfd, execp, callback_to_real_object_p)
   obj_aout_external_strings (abfd) = NULL;
   obj_aout_sym_hashes (abfd) = NULL;
 
-  /* Create the sections.  This is raunchy, but bfd_close wants to reclaim
-     them.  */
-
-  obj_textsec (abfd) = bfd_make_section_old_way (abfd, ".text");
-  obj_datasec (abfd) = bfd_make_section_old_way (abfd, ".data");
-  obj_bsssec (abfd) = bfd_make_section_old_way (abfd, ".bss");
-
-#if 0
-  (void)bfd_make_section (abfd, ".text");
-  (void)bfd_make_section (abfd, ".data");
-  (void)bfd_make_section (abfd, ".bss");
-#endif
+  if (! NAME(aout,make_sections) (abfd))
+    return NULL;
 
   obj_datasec (abfd)->_raw_size = execp->a_data;
   obj_bsssec (abfd)->_raw_size = execp->a_bss;
@@ -565,17 +593,9 @@ NAME(aout,mkobject) (abfd)
   abfd->tdata.aout_data = rawptr;
   exec_hdr (abfd) = &(rawptr->e);
 
-  /* For simplicity's sake we just make all the sections right here. */
-
   obj_textsec (abfd) = (asection *)NULL;
   obj_datasec (abfd) = (asection *)NULL;
   obj_bsssec (abfd) = (asection *)NULL;
-  bfd_make_section (abfd, ".text");
-  bfd_make_section (abfd, ".data");
-  bfd_make_section (abfd, ".bss");
-  bfd_make_section (abfd, BFD_ABS_SECTION_NAME);
-  bfd_make_section (abfd, BFD_UND_SECTION_NAME);
-  bfd_make_section (abfd, BFD_COM_SECTION_NAME);
 
   return true;
 }
@@ -878,11 +898,9 @@ NAME(aout,adjust_sizes_and_vmas) (abfd, text_size, text_end)
 {
   struct internal_exec *execp = exec_hdr (abfd);
 
-  if ((obj_textsec (abfd) == NULL) || (obj_datasec (abfd) == NULL))
-    {
-      bfd_set_error (bfd_error_invalid_operation);
-      return false;
-    }
+  if (! NAME(aout,make_sections) (abfd))
+    return false;
+
   if (adata(abfd).magic != undecided_magic) return true;
 
   obj_textsec(abfd)->_raw_size =
@@ -1906,17 +1924,17 @@ add_to_stringtab (abfd, str, tab)
   entry->count = 1;
 #endif
 
-  assert (*tab->end == 0);
+  BFD_ASSERT (*tab->end == 0);
   *(tab->end) = entry;
   tab->end = &entry->next_to_output;
-  assert (*tab->end == 0);
+  BFD_ASSERT (*tab->end == 0);
 
   {
     tab->index += len + 1;
     if (len == 0)
       tab->empty_string_index = entry->index;
   }
-  assert (*ep == 0);
+  BFD_ASSERT (*ep == 0);
   *ep = entry;
   return entry->index;
 }
@@ -2088,9 +2106,8 @@ NAME(aout,swap_std_reloc_out) (abfd, g, natptr)
   r_pcrel  = (int) g->howto->pc_relative; /* Relative to PC? */
   /* XXX This relies on relocs coming from a.out files.  */
   r_baserel = (g->howto->type & 8) != 0;
-  /* r_jmptable, r_relative???  FIXME-soon */
-  r_jmptable = 0;
-  r_relative = 0;
+  r_jmptable = (g->howto->type & 16) != 0;
+  r_relative = (g->howto->type & 32) != 0;
 
 #if 0
   /* For a standard reloc, the addend is in the object file.  */
@@ -2353,13 +2370,11 @@ NAME(aout,swap_std_reloc_in) (abfd, bytes, cache_ptr, symbols)
                        >> RELOC_STD_BITS_LENGTH_SH_LITTLE;
   }
 
-  howto_idx = r_length + 4 * r_pcrel + 8 * r_baserel;
+  howto_idx = r_length + 4 * r_pcrel + 8 * r_baserel
+             + 16 * r_jmptable + 32 * r_relative;
   BFD_ASSERT (howto_idx < TABLE_SIZE (howto_table_std));
   cache_ptr->howto =  howto_table_std + howto_idx;
   BFD_ASSERT (cache_ptr->howto->type != -1);
-  BFD_ASSERT (r_jmptable == 0);
-  BFD_ASSERT (r_relative == 0);
-  /* FIXME-soon:  Roll jmptable, relative bits into howto setting */
 
   MOVE_ADDRESS(0);
 }
@@ -3381,13 +3396,15 @@ NAME(aout,final_link) (abfd, info, callback)
              abort ();
            }
        }
-      trsize += (_bfd_count_link_order_relocs (obj_textsec (abfd)
-                                              ->link_order_head)
-                * obj_reloc_entry_size (abfd));
+      if (obj_textsec (abfd) != (asection *) NULL)
+       trsize += (_bfd_count_link_order_relocs (obj_textsec (abfd)
+                                                ->link_order_head)
+                  * obj_reloc_entry_size (abfd));
       exec_hdr (abfd)->a_trsize = trsize;
-      drsize += (_bfd_count_link_order_relocs (obj_datasec (abfd)
-                                              ->link_order_head)
-                * obj_reloc_entry_size (abfd));
+      if (obj_datasec (abfd) != (asection *) NULL)
+       drsize += (_bfd_count_link_order_relocs (obj_datasec (abfd)
+                                                ->link_order_head)
+                  * obj_reloc_entry_size (abfd));
       exec_hdr (abfd)->a_drsize = drsize;
     }
 
@@ -4205,10 +4222,9 @@ aout_link_input_section_std (finfo, input_bfd, input_section, relocs,
                       >> RELOC_STD_BITS_LENGTH_SH_LITTLE);
        }
 
-      howto_idx = r_length + 4 * r_pcrel + 8 * r_baserel;
+      howto_idx = r_length + 4 * r_pcrel + 8 * r_baserel
+                 + 16 * r_jmptable + 32 * r_relative;
       BFD_ASSERT (howto_idx < TABLE_SIZE (howto_table_std));
-      BFD_ASSERT (r_jmptable == 0);
-      BFD_ASSERT (r_relative == 0);
 
       if (relocateable)
        {
@@ -4775,8 +4791,8 @@ aout_link_reloc_link_order (finfo, o, p)
 
       r_pcrel = howto->pc_relative;
       r_baserel = (howto->type & 8) != 0;
-      r_jmptable = 0;
-      r_relative = 0;
+      r_jmptable = (howto->type & 16) != 0;
+      r_relative = (howto->type & 32) != 0;
       r_length = howto->size;
 
       PUT_WORD (finfo->output_bfd, p->offset, srel.r_address);
This page took 0.029448 seconds and 4 git commands to generate.