Ignore:
Timestamp:
Aug 16, 2003, 6:59:22 PM (22 years ago)
Author:
bird
Message:

binutils v2.14 - offical sources.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/GNU/src/binutils/bfd/section.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r608 r609  
    11/* Object file "section" support for the BFD library.
    22   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
    3    2000, 2001
     3   2000, 2001, 2002, 2003
    44   Free Software Foundation, Inc.
    55   Written by Cygnus Support.
     
    171171.  {* The name of the section; the name isn't a copy, the pointer is
    172172.     the same as that passed to bfd_make_section.  *}
    173 .
    174173.  const char *name;
    175174.
    176175.  {* A unique sequence number.  *}
    177 .
    178176.  int id;
    179177.
    180 .  {* Which section is it; 0..nth.  *}
    181 .
     178.  {* Which section in the bfd; 0..n-1 as sections are created in a bfd.  *}
    182179.  int index;
    183180.
    184181.  {* The next section in the list belonging to the BFD, or NULL.  *}
    185 .
    186182.  struct sec *next;
    187183.
     
    189185.     flags are read in from the object file, and some are
    190186.     synthesized from other information.  *}
    191 .
    192187.  flagword flags;
    193188.
     
    206201.#define SEC_RELOC      0x004
    207202.
    208 .#if 0   {* Obsolete ? *}
    209 .#define SEC_BALIGN     0x008
    210 .#endif
     203.  {* ELF reserves 4 processor specific bits and 8 operating system
     204.     specific bits in sh_flags; at present we can get away with just
     205.     one in communicating between the assembler and BFD, but this
     206.     isn't a good long-term solution.  *}
     207.#define SEC_ARCH_BIT_0 0x008
    211208.
    212209.  {* A signal to the OS that the section contains read only data.  *}
     
    234231.#define SEC_CONSTRUCTOR 0x100
    235232.
    236 .  {* The section is a constructor, and should be placed at the
    237 .     end of the text, data, or bss section(?).  *}
    238 .#define SEC_CONSTRUCTOR_TEXT 0x1100
    239 .#define SEC_CONSTRUCTOR_DATA 0x2100
    240 .#define SEC_CONSTRUCTOR_BSS  0x3100
    241 .
    242233.  {* The section has contents - a data section could be
    243234.     <<SEC_ALLOC>> | <<SEC_HAS_CONTENTS>>; a debug section could be
     
    260251.#define SEC_COFF_SHARED_LIBRARY 0x800
    261252.
     253.  {* The section contains thread local data.  *}
     254.#define SEC_THREAD_LOCAL 0x1000
     255.
    262256.  {* The section has GOT references.  This flag is only for the
    263257.     linker, and is currently only used by the elf32-hppa back end.
     
    291285.#define SEC_EXCLUDE 0x40000
    292286.
    293 .  {* The contents of this section are to be sorted by the
    294 .     based on the address specified in the associated symbol
    295 .     table.  *}
     287.  {* The contents of this section are to be sorted based on the sum of
     288.     the symbol and addend values specified by the associated relocation
     289.     entries.  Entries without associated relocation entries will be
     290.     appended to the end of the section in an unspecified order.  *}
    296291.#define SEC_SORT_ENTRIES 0x80000
    297292.
     
    351346.#define SEC_CLINK 0x10000000
    352347.
     348.  {* Attempt to merge identical entities in the section.
     349.     Entity size is given in the entsize field.  *}
     350.#define SEC_MERGE 0x20000000
     351.
     352.  {* If given with SEC_MERGE, entities to merge are zero terminated
     353.     strings where entsize specifies character size instead of fixed
     354.     size entries.  *}
     355.#define SEC_STRINGS 0x40000000
     356.
     357.  {* This section contains data about section groups.  *}
     358.#define SEC_GROUP 0x80000000
     359.
    353360.  {*  End of section flags.  *}
    354361.
     
    365372.
    366373.  {* Another mark flag used by some of the linker backends.  Set for
    367 .     output sections that have a input section.  *}
     374.     output sections that have an input section.  *}
    368375.  unsigned int linker_has_input : 1;
    369376.
     
    371378.  unsigned int gc_mark : 1;
    372379.
    373 .  {* Used by the ELF code to mark sections which have been allocated to segments.  *}
     380.  {* The following flags are used by the ELF linker. *}
     381.
     382.  {* Mark sections which have been allocated to segments.  *}
    374383.  unsigned int segment_mark : 1;
     384.
     385.  {* Type of sec_info information.  *}
     386.  unsigned int sec_info_type:3;
     387.#define ELF_INFO_TYPE_NONE      0
     388.#define ELF_INFO_TYPE_STABS     1
     389.#define ELF_INFO_TYPE_MERGE     2
     390.#define ELF_INFO_TYPE_EH_FRAME  3
     391.#define ELF_INFO_TYPE_JUST_SYMS 4
     392.
     393.  {* Nonzero if this section uses RELA relocations, rather than REL.  *}
     394.  unsigned int use_rela_p:1;
     395.
     396.  {* Bits used by various backends.  *}
     397.  unsigned int has_tls_reloc:1;
     398.
     399.  {* Nonzero if this section needs the relax finalize pass.  *}
     400.  unsigned int need_finalize_relax:1;
     401.
     402.  {* Usused bits.  *}
     403.  unsigned int flag12:1;
     404.  unsigned int flag13:1;
     405.  unsigned int flag14:1;
     406.  unsigned int flag15:1;
     407.  unsigned int flag16:4;
     408.  unsigned int flag20:4;
     409.  unsigned int flag24:8;
    375410.
    376411.  {* End of internal packed boolean fields.  *}
     
    382417.      the default address for <<.data>> is dependent on the specific
    383418.      target and various flags).  *}
    384 .
    385419.  bfd_vma vma;
    386420.
    387421.  {*  The load address of the section - where it would be in a
    388422.      rom image; really only used for writing section header
    389 .      information. *}
    390 .
     423.      information.  *}
    391424.  bfd_vma lma;
    392425.
     
    394427.     Contains a value even if the section has no contents (e.g., the
    395428.     size of <<.bss>>).  This will be filled in after relocation.  *}
    396 .
    397429.  bfd_size_type _cooked_size;
    398430.
     
    400432.     value is the same as the size, but if some relaxing has
    401433.     been done, then this value will be bigger.  *}
    402 .
    403434.  bfd_size_type _raw_size;
    404435.
     
    410441.     would be 100.  However, if the target byte size is 16 bits
    411442.     (bfd_octets_per_byte is "2"), this value would be 50.  *}
    412 .
    413443.  bfd_vma output_offset;
    414444.
    415445.  {* The output section through which to map on output.  *}
    416 .
    417446.  struct sec *output_section;
    418447.
    419448.  {* The alignment requirement of the section, as an exponent of 2 -
    420449.     e.g., 3 aligns to 2^3 (or 8).  *}
    421 .
    422450.  unsigned int alignment_power;
    423451.
    424452.  {* If an input section, a pointer to a vector of relocation
    425453.     records for the data in this section.  *}
    426 .
    427454.  struct reloc_cache_entry *relocation;
    428455.
    429456.  {* If an output section, a pointer to a vector of pointers to
    430457.     relocation records for the data in this section.  *}
    431 .
    432458.  struct reloc_cache_entry **orelocation;
    433459.
    434 .  {* The number of relocation records in one of the above  *}
    435 .
     460.  {* The number of relocation records in one of the above.  *}
    436461.  unsigned reloc_count;
    437462.
     
    440465.
    441466.  {* File position of section data.  *}
    442 .
    443467.  file_ptr filepos;
    444468.
    445469.  {* File position of relocation info.  *}
    446 .
    447470.  file_ptr rel_filepos;
    448471.
    449472.  {* File position of line data.  *}
    450 .
    451473.  file_ptr line_filepos;
    452474.
    453475.  {* Pointer to data for applications.  *}
    454 .
    455476.  PTR userdata;
    456477.
     
    460481.
    461482.  {* Attached line number information.  *}
    462 .
    463483.  alent *lineno;
    464484.
    465485.  {* Number of line number records.  *}
    466 .
    467486.  unsigned int lineno_count;
    468487.
     488.  {* Entity size for merging purposes.  *}
     489.  unsigned int entsize;
     490.
    469491.  {* Optional information about a COMDAT entry; NULL if not COMDAT.  *}
    470 .
    471492.  struct bfd_comdat_info *comdat;
    472 .
    473 .  {* Points to the kept section if this section is a link-once section,
    474 .     and is discarded.  *}
    475 .  struct sec *kept_section;
    476493.
    477494.  {* When a section is being output, this value changes as more
    478495.     linenumbers are written out.  *}
    479 .
    480496.  file_ptr moving_line_filepos;
    481497.
    482498.  {* What the section number is in the target world.  *}
    483 .
    484499.  int target_index;
    485500.
     
    488503.  {* If this is a constructor section then here is a list of the
    489504.     relocations created to relocate items within it.  *}
    490 .
    491505.  struct relent_chain *constructor_chain;
    492506.
    493507.  {* The BFD which owns the section.  *}
    494 .
    495508.  bfd *owner;
    496509.
    497 .  {* A symbol which points at this section only *}
     510.  {* A symbol which points at this section only. *}
    498511.  struct symbol_cache_entry *symbol;
    499512.  struct symbol_cache_entry **symbol_ptr_ptr;
     
    501514.  struct bfd_link_order *link_order_head;
    502515.  struct bfd_link_order *link_order_tail;
    503 .} asection ;
     516.} asection;
    504517.
    505518.{* These sections are global, and are managed by BFD.  The application
     
    513526.#define BFD_IND_SECTION_NAME "*IND*"
    514527.
    515 .{* the absolute section *}
     528.{* The absolute section. *}
    516529.extern const asection bfd_abs_section;
    517530.#define bfd_abs_section_ptr ((asection *) &bfd_abs_section)
    518531.#define bfd_is_abs_section(sec) ((sec) == bfd_abs_section_ptr)
    519 .{* Pointer to the undefined section *}
     532.{* Pointer to the undefined section. *}
    520533.extern const asection bfd_und_section;
    521534.#define bfd_und_section_ptr ((asection *) &bfd_und_section)
    522535.#define bfd_is_und_section(sec) ((sec) == bfd_und_section_ptr)
    523 .{* Pointer to the common section *}
     536.{* Pointer to the common section. *}
    524537.extern const asection bfd_com_section;
    525538.#define bfd_com_section_ptr ((asection *) &bfd_com_section)
    526 .{* Pointer to the indirect section *}
     539.{* Pointer to the indirect section. *}
    527540.extern const asection bfd_ind_section;
    528541.#define bfd_ind_section_ptr ((asection *) &bfd_ind_section)
    529542.#define bfd_is_ind_section(sec) ((sec) == bfd_ind_section_ptr)
     543.
     544.#define bfd_is_const_section(SEC)              \
     545. (   ((SEC) == bfd_abs_section_ptr)            \
     546.  || ((SEC) == bfd_und_section_ptr)            \
     547.  || ((SEC) == bfd_com_section_ptr)            \
     548.  || ((SEC) == bfd_ind_section_ptr))
    530549.
    531550.extern const struct symbol_cache_entry * const bfd_abs_symbol;
     
    539558.     ((section)->reloc_done ? (section)->_cooked_size \
    540559.                            : (abort (), (bfd_size_type) 1))
     560.
     561.{* Macros to handle insertion and deletion of a bfd's sections.  These
     562.   only handle the list pointers, ie. do not adjust section_count,
     563.   target_index etc.  *}
     564.#define bfd_section_list_remove(ABFD, PS) \
     565.  do                                                   \
     566.    {                                                  \
     567.      asection **_ps = PS;                             \
     568.      asection *_s = *_ps;                             \
     569.      *_ps = _s->next;                                 \
     570.      if (_s->next == NULL)                            \
     571.        (ABFD)->section_tail = _ps;                    \
     572.    }                                                  \
     573.  while (0)
     574.#define bfd_section_list_insert(ABFD, PS, S) \
     575.  do                                                   \
     576.    {                                                  \
     577.      asection **_ps = PS;                             \
     578.      asection *_s = S;                                \
     579.      _s->next = *_ps;                                 \
     580.      *_ps = _s;                                       \
     581.      if (_s->next == NULL)                            \
     582.        (ABFD)->section_tail = &_s->next;              \
     583.    }                                                  \
     584.  while (0)
     585.
    541586*/
    542587
     
    572617    /* linker_mark, linker_has_input, gc_mark, segment_mark,         */ \
    573618       0,           0,                1,       0,                       \
     619                                                                        \
     620    /* sec_info_type, use_rela_p, has_tls_reloc, need_finalize_relax, flag12,     */ \
     621       0,             0,          0,             0,                   0,                \
     622                                                                        \
     623    /* flag13, flag14, flag15, flag16, flag20, flag24,               */ \
     624       0,      0,      0,      0,      0,      0,                       \
    574625                                                                        \
    575626    /* vma, lma, _cooked_size, _raw_size,                            */ \
     
    585636       0,            NULL,     NULL,     NULL,   0,                     \
    586637                                                                        \
    587     /* comdat, kept_section, moving_line_filepos, target_index,      */ \
    588        NULL,   NULL,         0,                   0,                    \
     638    /* entsize, comdat, moving_line_filepos,                         */ \
     639       0,       NULL,   0,                                              \
    589640                                                                        \
    590     /* used_by_bfd, constructor_chain, owner,                        */ \
    591        NULL,        NULL,              NULL,                            \
     641    /* target_index, used_by_bfd, constructor_chain, owner,          */ \
     642       0,            NULL,        NULL,              NULL,              \
    592643                                                                        \
    593644    /* symbol,                                                       */ \
     
    608659#undef STD_SECTION
    609660
     661struct section_hash_entry
     662{
     663  struct bfd_hash_entry root;
     664  asection section;
     665};
     666
     667/* Initialize an entry in the section hash table.  */
     668
     669struct bfd_hash_entry *
     670bfd_section_hash_newfunc (entry, table, string)
     671     struct bfd_hash_entry *entry;
     672     struct bfd_hash_table *table;
     673     const char *string;
     674{
     675  /* Allocate the structure if it has not already been allocated by a
     676     subclass.  */
     677  if (entry == NULL)
     678    {
     679      entry = (struct bfd_hash_entry *)
     680        bfd_hash_allocate (table, sizeof (struct section_hash_entry));
     681      if (entry == NULL)
     682        return entry;
     683    }
     684
     685  /* Call the allocation method of the superclass.  */
     686  entry = bfd_hash_newfunc (entry, table, string);
     687  if (entry != NULL)
     688    {
     689      memset ((PTR) &((struct section_hash_entry *) entry)->section,
     690              0, sizeof (asection));
     691    }
     692
     693  return entry;
     694}
     695
     696#define section_hash_lookup(table, string, create, copy) \
     697  ((struct section_hash_entry *) \
     698   bfd_hash_lookup ((table), (string), (create), (copy)))
     699
     700/* Initializes a new section.  NEWSECT->NAME is already set.  */
     701
     702static asection *bfd_section_init PARAMS ((bfd *, asection *));
     703
     704static asection *
     705bfd_section_init (abfd, newsect)
     706     bfd *abfd;
     707     asection *newsect;
     708{
     709  static int section_id = 0x10;  /* id 0 to 3 used by STD_SECTION.  */
     710
     711  newsect->id = section_id;
     712  newsect->index = abfd->section_count;
     713  newsect->owner = abfd;
     714
     715  /* Create a symbol whose only job is to point to this section.  This
     716     is useful for things like relocs which are relative to the base
     717     of a section.  */
     718  newsect->symbol = bfd_make_empty_symbol (abfd);
     719  if (newsect->symbol == NULL)
     720    return NULL;
     721
     722  newsect->symbol->name = newsect->name;
     723  newsect->symbol->value = 0;
     724  newsect->symbol->section = newsect;
     725  newsect->symbol->flags = BSF_SECTION_SYM;
     726
     727  newsect->symbol_ptr_ptr = &newsect->symbol;
     728
     729  if (! BFD_SEND (abfd, _new_section_hook, (abfd, newsect)))
     730    return NULL;
     731
     732  section_id++;
     733  abfd->section_count++;
     734  *abfd->section_tail = newsect;
     735  abfd->section_tail = &newsect->next;
     736  return newsect;
     737}
     738
    610739/*
    611740DOCDD
     
    620749/*
    621750FUNCTION
     751        bfd_section_list_clear
     752
     753SYNOPSIS
     754        void bfd_section_list_clear (bfd *);
     755
     756DESCRIPTION
     757        Clears the section list, and also resets the section count and
     758        hash table entries.
     759*/
     760
     761void
     762bfd_section_list_clear (abfd)
     763     bfd *abfd;
     764{
     765  abfd->sections = NULL;
     766  abfd->section_tail = &abfd->sections;
     767  abfd->section_count = 0;
     768  memset ((PTR) abfd->section_htab.table, 0,
     769          abfd->section_htab.size * sizeof (struct bfd_hash_entry *));
     770}
     771
     772/*
     773FUNCTION
    622774        bfd_get_section_by_name
    623775
     
    641793     const char *name;
    642794{
    643   asection *sect;
    644 
    645   for (sect = abfd->sections; sect != NULL; sect = sect->next)
    646     if (!strcmp (sect->name, name))
    647       return sect;
     795  struct section_hash_entry *sh;
     796
     797  sh = section_hash_lookup (&abfd->section_htab, name, FALSE, FALSE);
     798  if (sh != NULL)
     799    return &sh->section;
     800
    648801  return NULL;
    649802}
     
    677830
    678831  len = strlen (templat);
    679   sname = bfd_malloc (len + 8);
     832  sname = bfd_malloc ((bfd_size_type) len + 8);
    680833  if (sname == NULL)
    681834    return NULL;
    682   strcpy (sname, templat);
     835  memcpy (sname, templat, len);
    683836  num = 1;
    684837  if (count != NULL)
     
    692845      sprintf (sname + len, ".%d", num++);
    693846    }
    694   while (bfd_get_section_by_name (abfd, sname) != NULL);
     847  while (section_hash_lookup (&abfd->section_htab, sname, FALSE, FALSE));
    695848
    696849  if (count != NULL)
     
    729882     const char *name;
    730883{
    731   asection *sec = bfd_get_section_by_name (abfd, name);
    732   if (sec == (asection *) NULL)
    733     {
    734       sec = bfd_make_section (abfd, name);
    735     }
    736   return sec;
     884  struct section_hash_entry *sh;
     885  asection *newsect;
     886
     887  if (abfd->output_has_begun)
     888    {
     889      bfd_set_error (bfd_error_invalid_operation);
     890      return NULL;
     891    }
     892
     893  if (strcmp (name, BFD_ABS_SECTION_NAME) == 0)
     894    return bfd_abs_section_ptr;
     895
     896  if (strcmp (name, BFD_COM_SECTION_NAME) == 0)
     897    return bfd_com_section_ptr;
     898
     899  if (strcmp (name, BFD_UND_SECTION_NAME) == 0)
     900    return bfd_und_section_ptr;
     901
     902  if (strcmp (name, BFD_IND_SECTION_NAME) == 0)
     903    return bfd_ind_section_ptr;
     904
     905  sh = section_hash_lookup (&abfd->section_htab, name, TRUE, FALSE);
     906  if (sh == NULL)
     907    return NULL;
     908
     909  newsect = &sh->section;
     910  if (newsect->name != NULL)
     911    {
     912      /* Section already exists.  */
     913      return newsect;
     914    }
     915
     916  newsect->name = name;
     917  return bfd_section_init (abfd, newsect);
    737918}
    738919
     
    759940     const char *name;
    760941{
    761   static int section_id = 0x10;  /* id 0 to 3 used by STD_SECTION.  */
     942  struct section_hash_entry *sh;
    762943  asection *newsect;
    763   asection **prev = &abfd->sections;
    764   asection *sect = abfd->sections;
    765944
    766945  if (abfd->output_has_begun)
     
    770949    }
    771950
    772   while (sect)
    773     {
    774       prev = &sect->next;
    775       sect = sect->next;
    776     }
    777 
    778   newsect = (asection *) bfd_zalloc (abfd, sizeof (asection));
    779   if (newsect == NULL)
     951  sh = section_hash_lookup (&abfd->section_htab, name, TRUE, FALSE);
     952  if (sh == NULL)
    780953    return NULL;
    781954
     955  newsect = &sh->section;
     956  if (newsect->name != NULL)
     957    {
     958      /* We are making a section of the same name.  It can't go in
     959         section_htab without generating a unique section name and
     960         that would be pointless;  We don't need to traverse the
     961         hash table.  */
     962      newsect = (asection *) bfd_zalloc (abfd, sizeof (asection));
     963      if (newsect == NULL)
     964        return NULL;
     965    }
     966
    782967  newsect->name = name;
    783   newsect->id = section_id++;
    784   newsect->index = abfd->section_count++;
    785   newsect->flags = SEC_NO_FLAGS;
    786 
    787   newsect->userdata = NULL;
    788   newsect->contents = NULL;
    789   newsect->next = (asection *) NULL;
    790   newsect->relocation = (arelent *) NULL;
    791   newsect->reloc_count = 0;
    792   newsect->line_filepos = 0;
    793   newsect->owner = abfd;
    794   newsect->comdat = NULL;
    795   newsect->kept_section = NULL;
    796 
    797   /* Create a symbol whos only job is to point to this section. This is
    798      useful for things like relocs which are relative to the base of a
    799      section.  */
    800   newsect->symbol = bfd_make_empty_symbol (abfd);
    801   if (newsect->symbol == NULL)
    802     {
    803       bfd_release (abfd, newsect);
    804       return NULL;
    805     }
    806   newsect->symbol->name = name;
    807   newsect->symbol->value = 0;
    808   newsect->symbol->section = newsect;
    809   newsect->symbol->flags = BSF_SECTION_SYM;
    810 
    811   newsect->symbol_ptr_ptr = &newsect->symbol;
    812 
    813   if (BFD_SEND (abfd, _new_section_hook, (abfd, newsect)) != true)
    814     {
    815       bfd_release (abfd, newsect);
    816       return NULL;
    817     }
    818 
    819   *prev = newsect;
    820   return newsect;
     968  return bfd_section_init (abfd, newsect);
    821969}
    822970
     
    840988     const char *name;
    841989{
    842   asection *sect = abfd->sections;
    843 
    844   if (strcmp (name, BFD_ABS_SECTION_NAME) == 0)
    845     {
    846       return bfd_abs_section_ptr;
    847     }
    848   if (strcmp (name, BFD_COM_SECTION_NAME) == 0)
    849     {
    850       return bfd_com_section_ptr;
    851     }
    852   if (strcmp (name, BFD_UND_SECTION_NAME) == 0)
    853     {
    854       return bfd_und_section_ptr;
    855     }
    856 
    857   if (strcmp (name, BFD_IND_SECTION_NAME) == 0)
    858     {
    859       return bfd_ind_section_ptr;
    860     }
    861 
    862   while (sect)
    863     {
    864       if (!strcmp (sect->name, name))
    865         return NULL;
    866       sect = sect->next;
    867     }
    868 
    869   /* The name is not already used; go ahead and make a new section.  */
    870   return bfd_make_section_anyway (abfd, name);
     990  struct section_hash_entry *sh;
     991  asection *newsect;
     992
     993  if (abfd->output_has_begun)
     994    {
     995      bfd_set_error (bfd_error_invalid_operation);
     996      return NULL;
     997    }
     998
     999  if (strcmp (name, BFD_ABS_SECTION_NAME) == 0
     1000      || strcmp (name, BFD_COM_SECTION_NAME) == 0
     1001      || strcmp (name, BFD_UND_SECTION_NAME) == 0
     1002      || strcmp (name, BFD_IND_SECTION_NAME) == 0)
     1003    return NULL;
     1004
     1005  sh = section_hash_lookup (&abfd->section_htab, name, TRUE, FALSE);
     1006  if (sh == NULL)
     1007    return NULL;
     1008
     1009  newsect = &sh->section;
     1010  if (newsect->name != NULL)
     1011    {
     1012      /* Section already exists.  */
     1013      return newsect;
     1014    }
     1015
     1016  newsect->name = name;
     1017  return bfd_section_init (abfd, newsect);
    8711018}
    8721019
     
    8761023
    8771024SYNOPSIS
    878         boolean bfd_set_section_flags(bfd *abfd, asection *sec, flagword flags);
     1025        bfd_boolean bfd_set_section_flags (bfd *abfd, asection *sec, flagword flags);
    8791026
    8801027DESCRIPTION
    8811028        Set the attributes of the section @var{sec} in the BFD
    882         @var{abfd} to the value @var{flags}. Return <<true>> on success,
    883         <<false>> on error. Possible error returns are:
     1029        @var{abfd} to the value @var{flags}. Return <<TRUE>> on success,
     1030        <<FALSE>> on error. Possible error returns are:
    8841031
    8851032        o <<bfd_error_invalid_operation>> -
     
    8911038
    8921039/*ARGSUSED*/
    893 boolean
     1040bfd_boolean
    8941041bfd_set_section_flags (abfd, section, flags)
    8951042     bfd *abfd ATTRIBUTE_UNUSED;
     
    9061053    {
    9071054      bfd_set_error (bfd_error_invalid_operation);
    908       return false;
     1055      return FALSE;
    9091056    }
    9101057#endif
    9111058
    9121059  section->flags = flags;
    913   return true;
     1060  return TRUE;
    9141061}
    9151062
     
    9631110
    9641111SYNOPSIS
    965         boolean bfd_set_section_size(bfd *abfd, asection *sec, bfd_size_type val);
     1112        bfd_boolean bfd_set_section_size (bfd *abfd, asection *sec, bfd_size_type val);
    9661113
    9671114DESCRIPTION
    9681115        Set @var{sec} to the size @var{val}. If the operation is
    969         ok, then <<true>> is returned, else <<false>>.
     1116        ok, then <<TRUE>> is returned, else <<FALSE>>.
    9701117
    9711118        Possible error returns:
     
    9751122*/
    9761123
    977 boolean
     1124bfd_boolean
    9781125bfd_set_section_size (abfd, ptr, val)
    9791126     bfd *abfd;
     
    9871134    {
    9881135      bfd_set_error (bfd_error_invalid_operation);
    989       return false;
     1136      return FALSE;
    9901137    }
    9911138
     
    9931140  ptr->_raw_size = val;
    9941141
    995   return true;
     1142  return TRUE;
    9961143}
    9971144
     
    10011148
    10021149SYNOPSIS
    1003         boolean bfd_set_section_contents
    1004          (bfd *abfd,
    1005          asection *section,
    1006          PTR data,
    1007          file_ptr offset,
    1008          bfd_size_type count);
     1150        bfd_boolean bfd_set_section_contents (bfd *abfd, asection *section,
     1151                                              PTR data, file_ptr offset,
     1152                                              bfd_size_type count);
    10091153
    10101154DESCRIPTION
     
    10141158        @var{offset} for @var{count} octets.
    10151159
    1016         Normally <<true>> is returned, else <<false>>. Possible error
     1160        Normally <<TRUE>> is returned, else <<FALSE>>. Possible error
    10171161        returns are:
    10181162        o <<bfd_error_no_contents>> -
     
    10311175 : bfd_get_section_size_before_reloc (sec))
    10321176
    1033 boolean
     1177bfd_boolean
    10341178bfd_set_section_contents (abfd, section, location, offset, count)
    10351179     bfd *abfd;
     
    10441188    {
    10451189      bfd_set_error (bfd_error_no_contents);
    1046       return (false);
    1047     }
    1048 
    1049   if (offset < 0)
    1050     {
    1051     bad_val:
    1052       bfd_set_error (bfd_error_bad_value);
    1053       return false;
    1054     }
     1190      return FALSE;
     1191    }
     1192
    10551193  sz = bfd_get_section_size_now (abfd, section);
    10561194  if ((bfd_size_type) offset > sz
    10571195      || count > sz
    1058       || offset + count > sz)
    1059     goto bad_val;
     1196      || offset + count > sz
     1197      || count != (size_t) count)
     1198    {
     1199      bfd_set_error (bfd_error_bad_value);
     1200      return FALSE;
     1201    }
    10601202
    10611203  switch (abfd->direction)
     
    10641206    case no_direction:
    10651207      bfd_set_error (bfd_error_invalid_operation);
    1066       return false;
     1208      return FALSE;
    10671209
    10681210    case write_direction:
     
    10731215           the file was created.  Do not recompute sections sizes or alignments
    10741216           in _bfd_set_section_content.  */
    1075       abfd->output_has_begun = true;
     1217      abfd->output_has_begun = TRUE;
    10761218      break;
    10771219    }
     
    10791221  /* Record a copy of the data in memory if desired.  */
    10801222  if (section->contents
    1081       && location != section->contents + offset)
    1082     memcpy (section->contents + offset, location, count);
     1223      && location != (PTR) (section->contents + offset))
     1224    memcpy (section->contents + offset, location, (size_t) count);
    10831225
    10841226  if (BFD_SEND (abfd, _bfd_set_section_contents,
    10851227                (abfd, section, location, offset, count)))
    10861228    {
    1087       abfd->output_has_begun = true;
    1088       return true;
    1089     }
    1090 
    1091   return false;
     1229      abfd->output_has_begun = TRUE;
     1230      return TRUE;
     1231    }
     1232
     1233  return FALSE;
    10921234}
    10931235
     
    10971239
    10981240SYNOPSIS
    1099         boolean bfd_get_section_contents
    1100         (bfd *abfd, asection *section, PTR location,
    1101          file_ptr offset, bfd_size_type count);
     1241        bfd_boolean bfd_get_section_contents (bfd *abfd, asection *section,
     1242                                              PTR location, file_ptr offset,
     1243                                              bfd_size_type count);
    11021244
    11031245DESCRIPTION
     
    11101252        flag set are requested or if the section does not have the
    11111253        <<SEC_HAS_CONTENTS>> flag set, then the @var{location} is filled
    1112         with zeroes. If no errors occur, <<true>> is returned, else
    1113         <<false>>.
    1114 
    1115 */
    1116 boolean
     1254        with zeroes. If no errors occur, <<TRUE>> is returned, else
     1255        <<FALSE>>.
     1256
     1257*/
     1258bfd_boolean
    11171259bfd_get_section_contents (abfd, section, location, offset, count)
    11181260     bfd *abfd;
     
    11261268  if (section->flags & SEC_CONSTRUCTOR)
    11271269    {
    1128       memset (location, 0, (unsigned) count);
    1129       return true;
    1130     }
    1131 
    1132   if (offset < 0)
    1133     {
    1134     bad_val:
    1135       bfd_set_error (bfd_error_bad_value);
    1136       return false;
    1137     }
    1138   /* Even if reloc_done is true, this function reads unrelocated
     1270      memset (location, 0, (size_t) count);
     1271      return TRUE;
     1272    }
     1273
     1274  /* Even if reloc_done is TRUE, this function reads unrelocated
    11391275     contents, so we want the raw size.  */
    11401276  sz = section->_raw_size;
    1141   if ((bfd_size_type) offset > sz || count > sz || offset + count > sz)
    1142     goto bad_val;
     1277  if ((bfd_size_type) offset > sz
     1278      || count > sz
     1279      || offset + count > sz
     1280      || count != (size_t) count)
     1281    {
     1282      bfd_set_error (bfd_error_bad_value);
     1283      return FALSE;
     1284    }
    11431285
    11441286  if (count == 0)
    11451287    /* Don't bother.  */
    1146     return true;
     1288    return TRUE;
    11471289
    11481290  if ((section->flags & SEC_HAS_CONTENTS) == 0)
    11491291    {
    1150       memset (location, 0, (unsigned) count);
    1151       return true;
     1292      memset (location, 0, (size_t) count);
     1293      return TRUE;
    11521294    }
    11531295
     
    11551297    {
    11561298      memcpy (location, section->contents + offset, (size_t) count);
    1157       return true;
     1299      return TRUE;
    11581300    }
    11591301
     
    11671309
    11681310SYNOPSIS
    1169         boolean bfd_copy_private_section_data(bfd *ibfd, asection *isec, bfd *obfd, asection *osec);
     1311        bfd_boolean bfd_copy_private_section_data (bfd *ibfd, asection *isec,
     1312                                                   bfd *obfd, asection *osec);
    11701313
    11711314DESCRIPTION
    11721315        Copy private section information from @var{isec} in the BFD
    11731316        @var{ibfd} to the section @var{osec} in the BFD @var{obfd}.
    1174         Return <<true>> on success, <<false>> on error.  Possible error
     1317        Return <<TRUE>> on success, <<FALSE>> on error.  Possible error
    11751318        returns are:
    11761319
     
    11931336DESCRIPTION
    11941337        Remove @var{section} from the output.  If the output section
    1195         becomes empty, remove it from the output bfd.  @var{info} may
    1196         be NULL; if it is not, it is used to decide whether the output
    1197         section is empty.
     1338        becomes empty, remove it from the output bfd.
     1339
     1340        This function won't actually do anything except twiddle flags
     1341        if called too late in the linking process, when it's not safe
     1342        to remove sections.
    11981343*/
    11991344void
     
    12021347     asection *s;
    12031348{
    1204   asection **spp, *os;
    1205   struct bfd_link_order *p, *pp;
    1206   boolean keep_os;
    1207 
    1208   /* Excise the input section from the link order.
    1209 
    1210      FIXME: For all calls that I can see to this function, the link
    1211      orders have not yet been set up.  So why are we checking them? --
    1212      Ian */
     1349  asection *os;
     1350  asection *is;
     1351  bfd *abfd;
     1352
     1353  s->flags |= SEC_EXCLUDE;
     1354
     1355  /* If the section wasn't assigned to an output section, or the
     1356     section has been discarded by the linker script, there's nothing
     1357     more to do. */
    12131358  os = s->output_section;
    1214 
    1215   /* Handle a section that wasn't output.  */
    1216   if (os == NULL)
     1359  if (os == NULL || os->owner == NULL)
    12171360    return;
    12181361
    1219   for (p = os->link_order_head, pp = NULL; p != NULL; pp = p, p = p->next)
    1220     if (p->type == bfd_indirect_link_order
    1221         && p->u.indirect.section == s)
    1222       {
    1223         if (pp)
    1224           pp->next = p->next;
    1225         else
    1226           os->link_order_head = p->next;
    1227         if (!p->next)
    1228           os->link_order_tail = pp;
    1229         break;
    1230       }
    1231 
    1232   keep_os = os->link_order_head != NULL;
    1233 
    1234   if (! keep_os && info != NULL)
    1235     {
    1236       bfd *abfd;
    1237       for (abfd = info->input_bfds; abfd != NULL; abfd = abfd->link_next)
    1238         {
    1239           asection *is;
    1240           for (is = abfd->sections; is != NULL; is = is->next)
    1241             {
    1242               if (is != s && is->output_section == os)
    1243                 break;
    1244             }
    1245           if (is != NULL)
    1246             break;
    1247         }
    1248       if (abfd != NULL)
    1249         keep_os = true;
    1250     }
    1251 
    1252   /* If the output section is empty, remove it too.  Careful about sections
    1253      that have been discarded in the link script -- they are mapped to
    1254      bfd_abs_section, which has no owner.  */
    1255   if (!keep_os && os->owner != NULL)
    1256     {
    1257       for (spp = &os->owner->sections; *spp; spp = &(*spp)->next)
    1258         if (*spp == os)
    1259           {
    1260             *spp = os->next;
    1261             os->owner->section_count--;
    1262             break;
    1263           }
    1264     }
    1265 }
     1362  /* If the output section has other (non-excluded) input sections, we
     1363     can't remove it.  */
     1364  for (abfd = info->input_bfds; abfd != NULL; abfd = abfd->link_next)
     1365    for (is = abfd->sections; is != NULL; is = is->next)
     1366      if (is->output_section == os && (is->flags & SEC_EXCLUDE) == 0)
     1367        return;
     1368
     1369  /* If the output section is empty, flag it for removal too.
     1370     See ldlang.c:strip_excluded_output_sections for the action.  */
     1371  os->flags |= SEC_EXCLUDE;
     1372}
     1373
     1374/*
     1375FUNCTION
     1376        bfd_generic_discard_group
     1377
     1378SYNOPSIS
     1379        bfd_boolean bfd_generic_discard_group (bfd *abfd, asection *group);
     1380
     1381DESCRIPTION
     1382        Remove all members of @var{group} from the output.
     1383*/
     1384
     1385bfd_boolean
     1386bfd_generic_discard_group (abfd, group)
     1387     bfd *abfd ATTRIBUTE_UNUSED;
     1388     asection *group ATTRIBUTE_UNUSED;
     1389{
     1390  return TRUE;
     1391}
Note: See TracChangeset for help on using the changeset viewer.