Back to index

cell-binutils  2.17cvs20070401
Classes | Defines | Functions | Variables
frags.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  frag

Defines

#define SIZEOF_STRUCT_FRAG   ((char *) zero_address_frag.fr_literal - (char *) &zero_address_frag)
#define FRAG_APPEND_1_CHAR(X)   frag_append_1_char (X)

Functions

addressT frag_now_fix (void)
addressT frag_now_fix_octets (void)
void frag_append_1_char (int)
void frag_init (void)
fragS * frag_alloc (struct obstack *)
void frag_grow (unsigned int nchars)
char * frag_more (int nchars)
void frag_align (int alignment, int fill_character, int max)
void frag_align_pattern (int alignment, const char *fill_pattern, int n_fill, int max)
void frag_align_code (int alignment, int max)
void frag_new (int old_frags_var_max_size)
void frag_wane (fragS *fragP)
int frag_room (void)
char * frag_variant (relax_stateT type, int max_chars, int var, relax_substateT subtype, symbolS *symbol, offsetT offset, char *opcode)
char * frag_var (relax_stateT type, int max_chars, int var, relax_substateT subtype, symbolS *symbol, offsetT offset, char *opcode)
bfd_boolean frag_offset_fixed_p (const fragS *, const fragS *, bfd_vma *)

Variables

COMMON fragS * frag_now
COMMON fragS zero_address_frag
COMMON fragS bss_address_frag

Class Documentation

struct frag

Definition at line 41 of file frags.h.

Collaboration diagram for frag:
Class Members
addressT fr_address
char * fr_file
offsetT fr_fix
unsigned int fr_line
char fr_literal
struct frag * fr_next
offsetT fr_offset
char * fr_opcode
relax_substateT fr_subtype
symbolS * fr_symbol
relax_stateT fr_type
offsetT fr_var
unsigned int has_code:1
unsigned int insn_addr:6
addressT last_fr_address
struct list_info_struct * line
unsigned int relax_marker:1

Define Documentation

#define FRAG_APPEND_1_CHAR (   X)    frag_append_1_char (X)

Definition at line 121 of file frags.h.

#define SIZEOF_STRUCT_FRAG   ((char *) zero_address_frag.fr_literal - (char *) &zero_address_frag)

Definition at line 104 of file frags.h.


Function Documentation

void frag_align ( int  alignment,
int  fill_character,
int  max 
)

Definition at line 288 of file frags.c.

{
  if (now_seg == absolute_section)
    {
      addressT new_off;
      addressT mask;

      mask = (~(addressT) 0) << alignment;
      new_off = (abs_section_offset + ~mask) & mask;
      if (max == 0 || new_off - abs_section_offset <= (addressT) max)
       abs_section_offset = new_off;
    }
  else
    {
      char *p;

      p = frag_var (rs_align, 1, 1, (relax_substateT) max,
                  (symbolS *) 0, (offsetT) alignment, (char *) 0);
      *p = fill_character;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void frag_align_code ( int  alignment,
int  max 
)

Definition at line 349 of file frags.c.

{
  char *p;

  p = frag_var (rs_align_code, MAX_MEM_FOR_RS_ALIGN_CODE, 1,
              (relax_substateT) max, (symbolS *) 0,
              (offsetT) alignment, (char *) 0);
  *p = NOP_OPCODE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void frag_align_pattern ( int  alignment,
const char *  fill_pattern,
int  n_fill,
int  max 
)

Definition at line 318 of file frags.c.

{
  char *p;

  p = frag_var (rs_align, n_fill, n_fill, (relax_substateT) max,
              (symbolS *) 0, (offsetT) alignment, (char *) 0);
  memcpy (p, fill_pattern, n_fill);
}

Here is the call graph for this function:

Here is the caller graph for this function:

fragS* frag_alloc ( struct obstack )

Definition at line 64 of file frags.c.

{
  fragS *ptr;
  int oalign;

  (void) obstack_alloc (ob, 0);
  oalign = obstack_alignment_mask (ob);
  obstack_alignment_mask (ob) = 0;
  ptr = (fragS *) obstack_alloc (ob, SIZEOF_STRUCT_FRAG);
  obstack_alignment_mask (ob) = oalign;
  memset (ptr, 0, SIZEOF_STRUCT_FRAG);
  return ptr;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void frag_append_1_char ( int  )

Definition at line 376 of file frags.c.

{
  frag_alloc_check (&frchain_now->frch_obstack);
  if (obstack_room (&frchain_now->frch_obstack) <= 1)
    {
      frag_wane (frag_now);
      frag_new (0);
    }
  obstack_1grow (&frchain_now->frch_obstack, datum);
}

Here is the call graph for this function:

void frag_grow ( unsigned int  nchars)

Definition at line 84 of file frags.c.

{
  if (obstack_room (&frchain_now->frch_obstack) < nchars)
    {
      unsigned int n;
      long oldc;

      frag_wane (frag_now);
      frag_new (0);
      oldc = frchain_now->frch_obstack.chunk_size;
      /* Try to allocate a bit more than needed right now.  But don't do
         this if we would waste too much memory.  Especially necessary
        for extremely big (like 2GB initialized) frags.  */
      if (nchars < 0x10000)
       frchain_now->frch_obstack.chunk_size = 2 * nchars;
      else
        frchain_now->frch_obstack.chunk_size = nchars + 0x10000;
      frchain_now->frch_obstack.chunk_size += SIZEOF_STRUCT_FRAG;
      if (frchain_now->frch_obstack.chunk_size > 0)
       while ((n = obstack_room (&frchain_now->frch_obstack)) < nchars
              && (unsigned long) frchain_now->frch_obstack.chunk_size > nchars)
         {
           frag_wane (frag_now);
           frag_new (0);
         }
      frchain_now->frch_obstack.chunk_size = oldc;
    }
  if (obstack_room (&frchain_now->frch_obstack) < nchars)
    as_fatal (_("can't extend frag %u chars"), nchars);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void frag_init ( void  )

Definition at line 33 of file frags.c.

Here is the caller graph for this function:

char* frag_more ( int  nchars)

Definition at line 185 of file frags.c.

{
  register char *retval;

  frag_alloc_check (&frchain_now->frch_obstack);
  frag_grow (nchars);
  retval = obstack_next_free (&frchain_now->frch_obstack);
  obstack_blank_fast (&frchain_now->frch_obstack, nchars);
  return (retval);
}

Here is the call graph for this function:

void frag_new ( int  old_frags_var_max_size)

Definition at line 133 of file frags.c.

{
  fragS *former_last_fragP;
  frchainS *frchP;

  assert (frchain_now->frch_last == frag_now);

  /* Fix up old frag's fr_fix.  */
  frag_now->fr_fix = frag_now_fix_octets () - old_frags_var_max_size;
  /* Make sure its type is valid.  */
  assert (frag_now->fr_type != 0);

  /* This will align the obstack so the next struct we allocate on it
     will begin at a correct boundary.  */
  obstack_finish (&frchain_now->frch_obstack);
  frchP = frchain_now;
  know (frchP);
  former_last_fragP = frchP->frch_last;
  assert (former_last_fragP != 0);
  assert (former_last_fragP == frag_now);
  frag_now = frag_alloc (&frchP->frch_obstack);

  as_where (&frag_now->fr_file, &frag_now->fr_line);

  /* Generally, frag_now->points to an address rounded up to next
     alignment.  However, characters will add to obstack frags
     IMMEDIATELY after the struct frag, even if they are not starting
     at an alignment address.  */
  former_last_fragP->fr_next = frag_now;
  frchP->frch_last = frag_now;

#ifndef NO_LISTING
  {
    extern struct list_info_struct *listing_tail;
    frag_now->line = listing_tail;
  }
#endif

  assert (frchain_now->frch_last == frag_now);

  frag_now->fr_next = NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

addressT frag_now_fix ( void  )

Definition at line 370 of file frags.c.

Here is the call graph for this function:

Definition at line 360 of file frags.c.

{
  if (now_seg == absolute_section)
    return abs_section_offset;

  return ((char *) obstack_next_free (&frchain_now->frch_obstack)
         - frag_now->fr_literal);
}

Here is the call graph for this function:

Here is the caller graph for this function:

bfd_boolean frag_offset_fixed_p ( const fragS *  ,
const fragS *  ,
bfd_vma  
)

Definition at line 392 of file frags.c.

{
  const fragS *frag;
  bfd_vma off;

  /* Start with offset initialised to difference between the two frags.
     Prior to assigning frag addresses this will be zero.  */
  off = frag1->fr_address - frag2->fr_address;
  if (frag1 == frag2)
    {
      *offset = off;
      return TRUE;
    }

  /* Maybe frag2 is after frag1.  */
  frag = frag1;
  while (frag->fr_type == rs_fill)
    {
      off += frag->fr_fix + frag->fr_offset * frag->fr_var;
      frag = frag->fr_next;
      if (frag == NULL)
       break;
      if (frag == frag2)
       {
         *offset = off;
         return TRUE;
       }
    }

  /* Maybe frag1 is after frag2.  */
  off = frag1->fr_address - frag2->fr_address;
  frag = frag2;
  while (frag->fr_type == rs_fill)
    {
      off -= frag->fr_fix + frag->fr_offset * frag->fr_var;
      frag = frag->fr_next;
      if (frag == NULL)
       break;
      if (frag == frag1)
       {
         *offset = off;
         return TRUE;
       }
    }

  return FALSE;
}

Here is the caller graph for this function:

int frag_room ( void  )

Definition at line 275 of file frags.c.

{
  return obstack_room (&frchain_now->frch_obstack);
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* frag_var ( relax_stateT  type,
int  max_chars,
int  var,
relax_substateT  subtype,
symbolS *  symbol,
offsetT  offset,
char *  opcode 
)

Definition at line 204 of file frags.c.

{
  register char *retval;

  frag_grow (max_chars);
  retval = obstack_next_free (&frchain_now->frch_obstack);
  obstack_blank_fast (&frchain_now->frch_obstack, max_chars);
  frag_now->fr_var = var;
  frag_now->fr_type = type;
  frag_now->fr_subtype = subtype;
  frag_now->fr_symbol = symbol;
  frag_now->fr_offset = offset;
  frag_now->fr_opcode = opcode;
#ifdef USING_CGEN
  frag_now->fr_cgen.insn = 0;
  frag_now->fr_cgen.opindex = 0;
  frag_now->fr_cgen.opinfo = 0;
#endif
#ifdef TC_FRAG_INIT
  TC_FRAG_INIT (frag_now);
#endif
  as_where (&frag_now->fr_file, &frag_now->fr_line);
  frag_new (max_chars);
  return (retval);
}

Here is the call graph for this function:

char* frag_variant ( relax_stateT  type,
int  max_chars,
int  var,
relax_substateT  subtype,
symbolS *  symbol,
offsetT  offset,
char *  opcode 
)

Definition at line 236 of file frags.c.

{
  register char *retval;

  retval = obstack_next_free (&frchain_now->frch_obstack);
  frag_now->fr_var = var;
  frag_now->fr_type = type;
  frag_now->fr_subtype = subtype;
  frag_now->fr_symbol = symbol;
  frag_now->fr_offset = offset;
  frag_now->fr_opcode = opcode;
#ifdef USING_CGEN
  frag_now->fr_cgen.insn = 0;
  frag_now->fr_cgen.opindex = 0;
  frag_now->fr_cgen.opinfo = 0;
#endif
#ifdef TC_FRAG_INIT
  TC_FRAG_INIT (frag_now);
#endif
  as_where (&frag_now->fr_file, &frag_now->fr_line);
  frag_new (max_chars);
  return (retval);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void frag_wane ( fragS *  fragP)

Variable Documentation

Definition at line 118 of file frags.h.

COMMON fragS* frag_now

Definition at line 111 of file frags.h.

Definition at line 116 of file frags.h.