OSDN Git Service

* stabs.c (_bfd_link_section_stabs): Use bfd_make_section*_with_flags
authorAlan Modra <amodra@bigpond.net.au>
Thu, 1 Jun 2006 03:45:58 +0000 (03:45 +0000)
committerAlan Modra <amodra@bigpond.net.au>
Thu, 1 Jun 2006 03:45:58 +0000 (03:45 +0000)
instead of bfd_make_section*.
* aix386-core.c: Likewise.
* aix5ppc-core.c: Likewise.
* aout-adobe.c: Likewise.
* aoutf1.h: Likewise.
* binary.c: Likewise.
* cisco-core.c: Likewise.
* coff-arm.c: Likewise.
* coff-h8300.c: Likewise.
* elf.c: Likewise.
* elf32-bfin.c: Likewise.
* elf32-m32c.c: Likewise.
* hppabsd-core.c: Likewise.
* hpux-core.c: Likewise.
* i386linux.c: Likewise.
* ieee.c: Likewise.
* ihex.c: Likewise.
* irix-core.c: Likewise.
* lynx-core.c: Likewise.
* m68klinux.c: Likewise.
* mach-o.c: Likewise.
* netbsd-core.c: Likewise.
* nlmcode.h: Likewise.
* opncls.c: Likewise.
* osf-core.c: Likewise.
* peXXigen.c: Likewise.
* ppcboot.c: Likewise.
* ptrace-core.c: Likewise.
* rs6000-core.c: Likewise.
* sco5-core.c: Likewise.
* sparclinux.c: Likewise.
* srec.c: Likewise.
* sunos.c: Likewise.
* trad-core.c: Likewise.
* xcofflink.c: Likewise.
* xsym.c: Likewise.

37 files changed:
bfd/ChangeLog
bfd/aix386-core.c
bfd/aix5ppc-core.c
bfd/aout-adobe.c
bfd/aoutf1.h
bfd/binary.c
bfd/cisco-core.c
bfd/coff-arm.c
bfd/coff-h8300.c
bfd/elf.c
bfd/elf32-bfin.c
bfd/elf32-m32c.c
bfd/hppabsd-core.c
bfd/hpux-core.c
bfd/i386linux.c
bfd/ieee.c
bfd/ihex.c
bfd/irix-core.c
bfd/lynx-core.c
bfd/m68klinux.c
bfd/mach-o.c
bfd/netbsd-core.c
bfd/nlmcode.h
bfd/opncls.c
bfd/osf-core.c
bfd/peXXigen.c
bfd/ppcboot.c
bfd/ptrace-core.c
bfd/rs6000-core.c
bfd/sco5-core.c
bfd/sparclinux.c
bfd/srec.c
bfd/stabs.c
bfd/sunos.c
bfd/trad-core.c
bfd/xcofflink.c
bfd/xsym.c

index 6072222..57aa072 100644 (file)
@@ -1,3 +1,43 @@
+2006-06-01  Alan Modra  <amodra@bigpond.net.au>
+
+       * stabs.c (_bfd_link_section_stabs): Use bfd_make_section*_with_flags
+       instead of bfd_make_section*.
+       * aix386-core.c: Likewise.
+       * aix5ppc-core.c: Likewise.
+       * aout-adobe.c: Likewise.
+       * aoutf1.h: Likewise.
+       * binary.c: Likewise.
+       * cisco-core.c: Likewise.
+       * coff-arm.c: Likewise.
+       * coff-h8300.c: Likewise.
+       * elf.c: Likewise.
+       * elf32-bfin.c: Likewise.
+       * elf32-m32c.c: Likewise.
+       * hppabsd-core.c: Likewise.
+       * hpux-core.c: Likewise.
+       * i386linux.c: Likewise.
+       * ieee.c: Likewise.
+       * ihex.c: Likewise.
+       * irix-core.c: Likewise.
+       * lynx-core.c: Likewise.
+       * m68klinux.c: Likewise.
+       * mach-o.c: Likewise.
+       * netbsd-core.c: Likewise.
+       * nlmcode.h: Likewise.
+       * opncls.c: Likewise.
+       * osf-core.c: Likewise.
+       * peXXigen.c: Likewise.
+       * ppcboot.c: Likewise.
+       * ptrace-core.c: Likewise.
+       * rs6000-core.c: Likewise.
+       * sco5-core.c: Likewise.
+       * sparclinux.c: Likewise.
+       * srec.c: Likewise.
+       * sunos.c: Likewise.
+       * trad-core.c: Likewise.
+       * xcofflink.c: Likewise.
+       * xsym.c: Likewise.
+
 2006-05-31  Daniel Jacobowitz  <dan@codesourcery.com>
 
        * Makefile.am (INCLUDES): Use @INCINTL@.
index 17a0290..19ab4dc 100644 (file)
@@ -2,7 +2,7 @@
    This was based on trad-core.c, which was written by John Gilmore of
         Cygnus Support.
    Copyright 1988, 1989, 1991, 1992, 1993, 1994, 1996, 1998, 1999, 2000,
-   2001, 2002, 2004
+   2001, 2002, 2004, 2006
    Free Software Foundation, Inc.
    Written by Minh Tran-Le <TRANLE@INTELLICORP.COM>.
    Converted to back end form by Ian Lance Taylor <ian@cygnus.com>.
@@ -80,6 +80,7 @@ aix386_core_file_p (abfd)
     struct trad_core_struct coredata;
     struct corehdr internal_core;
   } *mergem;
+  flagword flags;
 
   amt = sizeof (longbuf);
   if (bfd_bread ((PTR) longbuf, amt, abfd) != amt)
@@ -117,11 +118,12 @@ aix386_core_file_p (abfd)
   core_hdr (abfd) = core;
 
   /* Create the sections.  */
-  core_regsec (abfd) = bfd_make_section_anyway (abfd, ".reg");
+  flags = SEC_HAS_CONTENTS;
+  core_regsec (abfd) = bfd_make_section_anyway_with_flags (abfd, ".reg",
+                                                          flags);
   if (core_regsec (abfd) == NULL)
     goto loser;
 
-  core_regsec (abfd)->flags = SEC_HAS_CONTENTS;
   core_regsec (abfd)->size = sizeof (core->cd_regs);
   core_regsec (abfd)->vma = (bfd_vma) -1;
 
@@ -129,12 +131,13 @@ aix386_core_file_p (abfd)
   core_regsec (abfd)->filepos =
     (file_ptr) offsetof (struct corehdr, cd_regs[0]);
 
-  core_reg2sec (abfd) = bfd_make_section_anyway (abfd, ".reg2");
+  flags = SEC_HAS_CONTENTS;
+  core_reg2sec (abfd) = bfd_make_section_anyway_with_flags (abfd, ".reg2",
+                                                           flags);
   if (core_reg2sec (abfd) == NULL)
     /* bfd_release frees everything allocated after it's arg.  */
     goto loser;
 
-  core_reg2sec (abfd)->flags = SEC_HAS_CONTENTS;
   core_reg2sec (abfd)->size = sizeof (core->cd_fpregs);
   core_reg2sec (abfd)->vma = (bfd_vma) -1;
   core_reg2sec (abfd)->filepos =
@@ -175,11 +178,12 @@ aix386_core_file_p (abfd)
          flags = SEC_ALLOC + SEC_HAS_CONTENTS;
          break;
        }
-      core_section (abfd, n) = bfd_make_section_anyway (abfd, sname);
+      core_section (abfd, n) = bfd_make_section_anyway_with_flags (abfd,
+                                                                  sname,
+                                                                  flags);
       if (core_section (abfd, n) == NULL)
        goto loser;
 
-      core_section (abfd, n)->flags = flags;
       core_section (abfd, n)->size = core->cd_segs[i].cs_len;
       core_section (abfd, n)->vma       = core->cd_segs[i].cs_address;
       core_section (abfd, n)->filepos   = core->cd_segs[i].cs_offset;
index ee2a223..62d11e2 100644 (file)
@@ -1,5 +1,5 @@
 /* IBM RS/6000 "XCOFF" back-end for BFD.
-   Copyright 2001, 2002, 2003, 2004, 2005
+   Copyright 2001, 2002, 2003, 2004, 2005, 2006
    Free Software Foundation, Inc.
    Written by Tom Rix
    Contributed by Red Hat Inc.
@@ -56,6 +56,7 @@ xcoff64_core_p (bfd *abfd)
   bfd_size_type i;
   struct vm_infox vminfo;
   const bfd_target *return_value = NULL;
+  flagword flags;
 
   /* Get the header.  */
   if (bfd_seek (abfd, 0, SEEK_SET) != 0)
@@ -117,21 +118,21 @@ xcoff64_core_p (bfd *abfd)
   abfd->tdata.any = new_core_hdr;
 
   /* .stack section.  */
-  sec = bfd_make_section_anyway (abfd, ".stack");
+  flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
+  sec = bfd_make_section_anyway_with_flags (abfd, ".stack", flags);
   if (NULL == sec)
     return return_value;
 
-  sec->flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
   sec->size = core.c_size;
   sec->vma = core.c_stackorg;
   sec->filepos = core.c_stack;
 
   /* .reg section for all registers.  */
-  sec = bfd_make_section_anyway (abfd, ".reg");
+  flags = SEC_HAS_CONTENTS | SEC_IN_MEMORY;
+  sec = bfd_make_section_anyway_with_flags (abfd, ".reg", flags);
   if (NULL == sec)
     return return_value;
 
-  sec->flags = SEC_HAS_CONTENTS | SEC_IN_MEMORY;
   sec->size = sizeof (struct __context64);
   sec->vma = 0;
   sec->filepos = 0;
@@ -141,11 +142,11 @@ xcoff64_core_p (bfd *abfd)
      To actually find out how long this section is in this particular
      core dump would require going down the whole list of struct
      ld_info's.   See if we can just fake it.  */
-  sec = bfd_make_section_anyway (abfd, ".ldinfo");
+  flags = SEC_HAS_CONTENTS;
+  sec = bfd_make_section_anyway_with_flags (abfd, ".ldinfo", flags);
   if (NULL == sec)
     return return_value;
 
-  sec->flags = SEC_HAS_CONTENTS;
   sec->size = core.c_lsize;
   sec->vma = 0;
   sec->filepos = core.c_loader;
@@ -155,11 +156,11 @@ xcoff64_core_p (bfd *abfd)
      regions.  */
 
   /* .data section from executable.  */
-  sec = bfd_make_section_anyway (abfd, ".data");
+  flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
+  sec = bfd_make_section_anyway_with_flags (abfd, ".data", flags);
   if (NULL == sec)
     return return_value;
 
-  sec->flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
   sec->size = core.c_datasize;
   sec->vma = core.c_dataorg;
   sec->filepos = core.c_data;
@@ -178,11 +179,11 @@ xcoff64_core_p (bfd *abfd)
 
       if (ldinfo.ldinfo_core)
        {
-         sec = bfd_make_section_anyway (abfd, ".data");
+         flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
+         sec = bfd_make_section_anyway_with_flags (abfd, ".data", flags);
          if (NULL == sec)
            return return_value;
 
-         sec->flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
          sec->size = ldinfo.ldinfo_datasize;
          sec->vma = ldinfo.ldinfo_dataorg;
          sec->filepos = ldinfo.ldinfo_core;
@@ -206,11 +207,11 @@ xcoff64_core_p (bfd *abfd)
 
       if (vminfo.vminfo_offset)
        {
-         sec = bfd_make_section_anyway (abfd, ".vmdata");
+         flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
+         sec = bfd_make_section_anyway_with_flags (abfd, ".vmdata", flags);
          if (NULL == sec)
            return return_value;
 
-         sec->flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
          sec->size = vminfo.vminfo_size;
          sec->vma = vminfo.vminfo_addr;
          sec->filepos = vminfo.vminfo_offset;
index 93182f7..85e31fd 100644 (file)
@@ -1,6 +1,6 @@
 /* BFD back-end for a.out.adobe binaries.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000,
-   2001, 2002, 2003, 2004, 2005
+   2001, 2002, 2003, 2004, 2005, 2006
    Free Software Foundation, Inc.
    Written by Cygnus Support.  Based on bout.c.
 
@@ -132,7 +132,7 @@ aout_adobe_callback (bfd *abfd)
       /* First one is called ".text" or whatever; subsequent ones are
         ".text1", ".text2", ...  */
       bfd_set_error (bfd_error_no_error);
-      sect = bfd_make_section (abfd, section_name);
+      sect = bfd_make_section_with_flags (abfd, section_name, flags);
       trynum = 0;
 
       while (!sect)
@@ -141,7 +141,7 @@ aout_adobe_callback (bfd *abfd)
            /* Some other error -- slide into the sunset.  */
            return NULL;
          sprintf (try_again, "%s%d", section_name, ++trynum);
-         sect = bfd_make_section (abfd, try_again);
+         sect = bfd_make_section_with_flags (abfd, try_again, flags);
        }
 
       /* Fix the name, if it is a sprintf'd name.  */
@@ -155,8 +155,6 @@ aout_adobe_callback (bfd *abfd)
          sect->name = newname;
        }
 
-      /* Now set the section's attributes.  */
-      bfd_set_section_flags (abfd, sect, flags);
       /* Assumed big-endian.  */
       sect->size = ((ext->e_size[0] << 8)
                    | ext->e_size[1] << 8
index e67190d..8e41b61 100644 (file)
@@ -1,6 +1,6 @@
 /* A.out "format 1" file handling code for BFD.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000,
-   2001, 2002, 2003, 2004, 2005
+   2001, 2002, 2003, 2004, 2005, 2006
    Free Software Foundation, Inc.
    Written by Cygnus Support.
 
@@ -566,6 +566,7 @@ sunos4_core_file_p (bfd *abfd)
       struct internal_sunos_core internal_sunos_core;
       char external_core[1];
     } *mergem;
+  flagword flags;
 
   if (bfd_bread ((void *) longbuf, (bfd_size_type) sizeof (longbuf), abfd)
       != sizeof (longbuf))
@@ -627,28 +628,31 @@ sunos4_core_file_p (bfd *abfd)
   abfd->tdata.sun_core_data->hdr = core;
 
   /* Create the sections.  */
-  core_stacksec (abfd) = bfd_make_section_anyway (abfd, ".stack");
+  flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
+  core_stacksec (abfd) = bfd_make_section_anyway_with_flags (abfd, ".stack",
+                                                            flags);
   if (core_stacksec (abfd) == NULL)
     /* bfd_release frees everything allocated after it's arg.  */
     goto loser;
 
-  core_datasec (abfd) = bfd_make_section_anyway (abfd, ".data");
+  flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
+  core_datasec (abfd) = bfd_make_section_anyway_with_flags (abfd, ".data",
+                                                           flags);
   if (core_datasec (abfd) == NULL)
     goto loser;
 
-  core_regsec (abfd) = bfd_make_section_anyway (abfd, ".reg");
+  flags = SEC_HAS_CONTENTS;
+  core_regsec (abfd) = bfd_make_section_anyway_with_flags (abfd, ".reg",
+                                                          flags);
   if (core_regsec (abfd) == NULL)
     goto loser;
 
-  core_reg2sec (abfd) = bfd_make_section_anyway (abfd, ".reg2");
+  flags = SEC_HAS_CONTENTS;
+  core_reg2sec (abfd) = bfd_make_section_anyway_with_flags (abfd, ".reg2",
+                                                           flags);
   if (core_reg2sec (abfd) == NULL)
     goto loser;
 
-  core_stacksec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
-  core_datasec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
-  core_regsec (abfd)->flags = SEC_HAS_CONTENTS;
-  core_reg2sec (abfd)->flags = SEC_HAS_CONTENTS;
-
   core_stacksec (abfd)->size = core->c_ssize;
   core_datasec (abfd)->size = core->c_dsize;
   core_regsec (abfd)->size = core->c_regs_size;
index 458626f..92a47ad 100644 (file)
@@ -1,6 +1,6 @@
 /* BFD back-end for binary objects.
    Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
-   2004, 2005 Free Software Foundation, Inc.
+   2004, 2005, 2006 Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Cygnus Support, <ian@cygnus.com>
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -63,6 +63,7 @@ binary_object_p (bfd *abfd)
 {
   struct stat statbuf;
   asection *sec;
+  flagword flags;
 
   if (abfd->target_defaulted)
     {
@@ -80,10 +81,10 @@ binary_object_p (bfd *abfd)
     }
 
   /* One data section.  */
-  sec = bfd_make_section (abfd, ".data");
+  flags = SEC_ALLOC | SEC_LOAD | SEC_DATA | SEC_HAS_CONTENTS;
+  sec = bfd_make_section_with_flags (abfd, ".data", flags);
   if (sec == NULL)
     return NULL;
-  sec->flags = SEC_ALLOC | SEC_LOAD | SEC_DATA | SEC_HAS_CONTENTS;
   sec->vma = 0;
   sec->size = statbuf.st_size;
   sec->filepos = 0;
index b7f735b..7d63118 100644 (file)
@@ -1,5 +1,5 @@
 /* BFD back-end for CISCO crash dumps.
-   Copyright 1994, 1997, 1999, 2000, 2001, 2002, 2004
+   Copyright 1994, 1997, 1999, 2000, 2001, 2002, 2004, 2006
    Free Software Foundation, Inc.
 
 This file is part of BFD, the Binary File Descriptor library.
@@ -95,6 +95,7 @@ cisco_core_file_validate (abfd, crash_info_loc)
   sec_ptr asect;
   struct stat statbuf;
   bfd_size_type amt;
+  flagword flags;
 
   if (bfd_seek (abfd, (file_ptr) crash_info_loc, SEEK_SET) != 0)
     return NULL;
@@ -241,10 +242,10 @@ cisco_core_file_validate (abfd, crash_info_loc)
   /* Create a ".data" section that maps the entire file, which is
      essentially a dump of the target system's RAM.  */
 
-  asect = bfd_make_section_anyway (abfd, ".data");
+  flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
+  asect = bfd_make_section_anyway_with_flags (abfd, ".data", flags);
   if (asect == NULL)
     goto error_return;
-  asect->flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
   /* The size of memory is the size of the core file itself.  */
   asect->size = statbuf.st_size;
   asect->vma = rambase;
@@ -253,10 +254,10 @@ cisco_core_file_validate (abfd, crash_info_loc)
   /* Create a ".crash" section to allow access to the saved
      crash information.  */
 
-  asect = bfd_make_section_anyway (abfd, ".crash");
+  flags = SEC_HAS_CONTENTS;
+  asect = bfd_make_section_anyway_with_flags (abfd, ".crash", flags);
   if (asect == NULL)
     goto error_return;
-  asect->flags = SEC_HAS_CONTENTS;
   asect->vma = 0;
   asect->filepos = crashinfo_offset;
   asect->size = sizeof (crashinfo);
@@ -264,10 +265,9 @@ cisco_core_file_validate (abfd, crash_info_loc)
   /* Create a ".reg" section to allow access to the saved
      registers.  */
 
-  asect = bfd_make_section_anyway (abfd, ".reg");
+  asect = bfd_make_section_anyway_with_flags (abfd, ".reg", flags);
   if (asect == NULL)
     goto error_return;
-  asect->flags = SEC_HAS_CONTENTS;
   asect->vma = 0;
   asect->filepos = bfd_get_32 (abfd, crashinfo.registers) - rambase;
   /* Since we don't know the exact size of the saved register info,
index c5b4765..ff4b239 100644 (file)
@@ -1940,12 +1940,11 @@ bfd_arm_get_bfd_for_interworking (bfd *                  abfd,
 
   if (sec == NULL)
     {
-      flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_CODE | SEC_READONLY;
-
-      sec = bfd_make_section (abfd, ARM2THUMB_GLUE_SECTION_NAME);
-
+      flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY
+              | SEC_CODE | SEC_READONLY);
+      sec = bfd_make_section_with_flags (abfd, ARM2THUMB_GLUE_SECTION_NAME,
+                                        flags);
       if (sec == NULL
-         || ! bfd_set_section_flags (abfd, sec, flags)
          || ! bfd_set_section_alignment (abfd, sec, 2))
        return FALSE;
     }
@@ -1954,12 +1953,12 @@ bfd_arm_get_bfd_for_interworking (bfd *                  abfd,
 
   if (sec == NULL)
     {
-      flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_CODE | SEC_READONLY;
-
-      sec = bfd_make_section (abfd, THUMB2ARM_GLUE_SECTION_NAME);
+      flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY
+              | SEC_CODE | SEC_READONLY);
+      sec = bfd_make_section_with_flags (abfd, THUMB2ARM_GLUE_SECTION_NAME,
+                                        flags);
 
       if (sec == NULL
-         || ! bfd_set_section_flags (abfd, sec, flags)
          || ! bfd_set_section_alignment (abfd, sec, 2))
        return FALSE;
     }
index 9c858e1..1a9c4a7 100644 (file)
@@ -1276,12 +1276,12 @@ h8300_bfd_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
       /* Make sure the appropriate flags are set, including SEC_IN_MEMORY.  */
       flags = (SEC_ALLOC | SEC_LOAD
               | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_READONLY);
-      htab->vectors_sec = bfd_make_section (abfd, ".vectors");
+      htab->vectors_sec = bfd_make_section_with_flags (abfd, ".vectors",
+                                                      flags);
 
       /* If the section wasn't created, or we couldn't set the flags,
         quit quickly now, rather than dying a painful death later.  */
-      if (!htab->vectors_sec
-         || !bfd_set_section_flags (abfd, htab->vectors_sec, flags))
+      if (!htab->vectors_sec)
        return FALSE;
 
       /* Also create the vector hash table.  */
index 7db3a27..7d3dd5a 100644 (file)
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -7313,13 +7313,12 @@ elfcore_maybe_make_sect (bfd *abfd, char *name, asection *sect)
   if (bfd_get_section_by_name (abfd, name) != NULL)
     return TRUE;
 
-  sect2 = bfd_make_section (abfd, name);
+  sect2 = bfd_make_section_with_flags (abfd, name, sect->flags);
   if (sect2 == NULL)
     return FALSE;
 
   sect2->size = sect->size;
   sect2->filepos = sect->filepos;
-  sect2->flags = sect->flags;
   sect2->alignment_power = sect->alignment_power;
   return TRUE;
 }
@@ -7351,12 +7350,12 @@ _bfd_elfcore_make_pseudosection (bfd *abfd,
     return FALSE;
   memcpy (threaded_name, buf, len);
 
-  sect = bfd_make_section_anyway (abfd, threaded_name);
+  sect = bfd_make_section_anyway_with_flags (abfd, threaded_name,
+                                            SEC_HAS_CONTENTS);
   if (sect == NULL)
     return FALSE;
   sect->size = size;
   sect->filepos = filepos;
-  sect->flags = SEC_HAS_CONTENTS;
   sect->alignment_power = 2;
 
   return elfcore_maybe_make_sect (abfd, name, sect);
@@ -7635,7 +7634,7 @@ elfcore_grok_lwpstatus (bfd *abfd, Elf_Internal_Note *note)
     return FALSE;
   memcpy (name, buf, len);
 
-  sect = bfd_make_section_anyway (abfd, name);
+  sect = bfd_make_section_anyway_with_flags (abfd, name, SEC_HAS_CONTENTS);
   if (sect == NULL)
     return FALSE;
 
@@ -7650,7 +7649,6 @@ elfcore_grok_lwpstatus (bfd *abfd, Elf_Internal_Note *note)
   sect->filepos = note->descpos + offsetof (lwpstatus_t, pr_reg);
 #endif
 
-  sect->flags = SEC_HAS_CONTENTS;
   sect->alignment_power = 2;
 
   if (!elfcore_maybe_make_sect (abfd, ".reg", sect))
@@ -7665,7 +7663,7 @@ elfcore_grok_lwpstatus (bfd *abfd, Elf_Internal_Note *note)
     return FALSE;
   memcpy (name, buf, len);
 
-  sect = bfd_make_section_anyway (abfd, name);
+  sect = bfd_make_section_anyway_with_flags (abfd, name, SEC_HAS_CONTENTS);
   if (sect == NULL)
     return FALSE;
 
@@ -7680,7 +7678,6 @@ elfcore_grok_lwpstatus (bfd *abfd, Elf_Internal_Note *note)
   sect->filepos = note->descpos + offsetof (lwpstatus_t, pr_fpreg);
 #endif
 
-  sect->flags = SEC_HAS_CONTENTS;
   sect->alignment_power = 2;
 
   return elfcore_maybe_make_sect (abfd, ".reg2", sect);
@@ -7721,7 +7718,7 @@ elfcore_grok_win32pstatus (bfd *abfd, Elf_Internal_Note *note)
 
       memcpy (name, buf, len);
 
-      sect = bfd_make_section_anyway (abfd, name);
+      sect = bfd_make_section_anyway_with_flags (abfd, name, SEC_HAS_CONTENTS);
       if (sect == NULL)
        return FALSE;
 
@@ -7729,7 +7726,6 @@ elfcore_grok_win32pstatus (bfd *abfd, Elf_Internal_Note *note)
       sect->filepos = (note->descpos
                       + offsetof (struct win32_pstatus,
                                   data.thread_info.thread_context));
-      sect->flags = SEC_HAS_CONTENTS;
       sect->alignment_power = 2;
 
       if (pstatus.data.thread_info.is_active_thread)
@@ -7749,14 +7745,13 @@ elfcore_grok_win32pstatus (bfd *abfd, Elf_Internal_Note *note)
 
       memcpy (name, buf, len);
 
-      sect = bfd_make_section_anyway (abfd, name);
+      sect = bfd_make_section_anyway_with_flags (abfd, name, SEC_HAS_CONTENTS);
 
       if (sect == NULL)
        return FALSE;
 
       sect->size = note->descsz;
       sect->filepos = note->descpos;
-      sect->flags = SEC_HAS_CONTENTS;
       sect->alignment_power = 2;
       break;
 
@@ -7826,13 +7821,13 @@ elfcore_grok_note (bfd *abfd, Elf_Internal_Note *note)
 
     case NT_AUXV:
       {
-       asection *sect = bfd_make_section_anyway (abfd, ".auxv");
+       asection *sect = bfd_make_section_anyway_with_flags (abfd, ".auxv",
+                                                            SEC_HAS_CONTENTS);
 
        if (sect == NULL)
          return FALSE;
        sect->size = note->descsz;
        sect->filepos = note->descpos;
-       sect->flags = SEC_HAS_CONTENTS;
        sect->alignment_power = 1 + bfd_get_arch_size (abfd) / 32;
 
        return TRUE;
@@ -7979,13 +7974,12 @@ elfcore_grok_nto_status (bfd *abfd, Elf_Internal_Note *note, pid_t *tid)
     return FALSE;
   strcpy (name, buf);
 
-  sect = bfd_make_section_anyway (abfd, name);
+  sect = bfd_make_section_anyway_with_flags (abfd, name, SEC_HAS_CONTENTS);
   if (sect == NULL)
     return FALSE;
 
   sect->size            = note->descsz;
   sect->filepos         = note->descpos;
-  sect->flags           = SEC_HAS_CONTENTS;
   sect->alignment_power = 2;
 
   return (elfcore_maybe_make_sect (abfd, ".qnx_core_status", sect));
@@ -8009,13 +8003,12 @@ elfcore_grok_nto_regs (bfd *abfd,
     return FALSE;
   strcpy (name, buf);
 
-  sect = bfd_make_section_anyway (abfd, name);
+  sect = bfd_make_section_anyway_with_flags (abfd, name, SEC_HAS_CONTENTS);
   if (sect == NULL)
     return FALSE;
 
   sect->size            = note->descsz;
   sect->filepos         = note->descpos;
-  sect->flags           = SEC_HAS_CONTENTS;
   sect->alignment_power = 2;
 
   /* This is the current thread.  */
index ba6bc62..661d4bd 100644 (file)
@@ -1984,15 +1984,12 @@ bfin_check_relocs (bfd * abfd,
              srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
              if (srelgot == NULL)
                {
-                 srelgot = bfd_make_section (dynobj, ".rela.got");
+                 flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
+                                   | SEC_IN_MEMORY | SEC_LINKER_CREATED
+                                   | SEC_READONLY);
+                 srelgot = bfd_make_section_with_flags (dynobj, ".rela.got",
+                                                        flags);
                  if (srelgot == NULL
-                     || !bfd_set_section_flags (dynobj, srelgot,
-                                                (SEC_ALLOC
-                                                 | SEC_LOAD
-                                                 | SEC_HAS_CONTENTS
-                                                 | SEC_IN_MEMORY
-                                                 | SEC_LINKER_CREATED
-                                                 | SEC_READONLY))
                      || !bfd_set_section_alignment (dynobj, srelgot, 2))
                    return FALSE;
                }
@@ -3380,9 +3377,8 @@ elf32_bfinfdpic_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
   if (bed->plt_readonly)
     pltflags |= SEC_READONLY;
 
-  s = bfd_make_section (abfd, ".plt");
+  s = bfd_make_section_with_flags (abfd, ".plt", pltflags);
   if (s == NULL
-      || ! bfd_set_section_flags (abfd, s, pltflags)
       || ! bfd_set_section_alignment (abfd, s, bed->plt_alignment))
     return FALSE;
   /* Blackfin-specific: remember it.  */
@@ -3409,9 +3405,8 @@ elf32_bfinfdpic_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
     }
 
   /* Blackfin-specific: we want rel relocations for the plt.  */
-  s = bfd_make_section (abfd, ".rel.plt");
+  s = bfd_make_section_with_flags (abfd, ".rel.plt", flags | SEC_READONLY);
   if (s == NULL
-      || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
       || ! bfd_set_section_alignment (abfd, s, bed->s->log_file_align))
     return FALSE;
   /* Blackfin-specific: remember it.  */
@@ -3435,9 +3430,9 @@ elf32_bfinfdpic_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
         image and use a R_*_COPY reloc to tell the dynamic linker to
         initialize them at run time.  The linker script puts the .dynbss
         section into the .bss section of the final image.  */
-      s = bfd_make_section (abfd, ".dynbss");
-      if (s == NULL
-         || ! bfd_set_section_flags (abfd, s, SEC_ALLOC | SEC_LINKER_CREATED))
+      s = bfd_make_section_with_flags (abfd, ".dynbss",
+                                      SEC_ALLOC | SEC_LINKER_CREATED);
+      if (s == NULL)
        return FALSE;
 
       /* The .rel[a].bss section holds copy relocs.  This section is not
@@ -3453,11 +3448,11 @@ elf32_bfinfdpic_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
      copy relocs.  */
       if (! info->shared)
        {
-         s = bfd_make_section (abfd,
-                               (bed->default_use_rela_p
-                                ? ".rela.bss" : ".rel.bss"));
+         s = bfd_make_section_with_flags (abfd,
+                                          (bed->default_use_rela_p
+                                           ? ".rela.bss" : ".rel.bss"),
+                                          flags | SEC_READONLY);
          if (s == NULL
-             || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
              || ! bfd_set_section_alignment (abfd, s, bed->s->log_file_align))
            return FALSE;
        }
index 4320461..69e617f 100644 (file)
@@ -691,16 +691,11 @@ m32c_elf_check_relocs
              splt = bfd_get_section_by_name (dynobj, ".plt");
              if (splt == NULL)
                {
-                 splt = bfd_make_section (dynobj, ".plt");
+                 flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
+                                   | SEC_IN_MEMORY | SEC_LINKER_CREATED
+                                   | SEC_READONLY | SEC_CODE);
+                 splt = bfd_make_section_with_flags (dynobj, ".plt", flags);
                  if (splt == NULL
-                     || ! bfd_set_section_flags (dynobj, splt,
-                                                 (SEC_ALLOC
-                                                  | SEC_LOAD
-                                                  | SEC_HAS_CONTENTS
-                                                  | SEC_IN_MEMORY
-                                                  | SEC_LINKER_CREATED
-                                                  | SEC_READONLY
-                                                  | SEC_CODE))
                      || ! bfd_set_section_alignment (dynobj, splt, 1))
                    return FALSE;
                }
index 67627e7..5bf67ad 100644 (file)
@@ -1,6 +1,6 @@
 /* BFD back-end for HPPA BSD core files.
-   Copyright 1993, 1994, 1995, 1998, 1999, 2001, 2002, 2003, 2004, 2005
-   Free Software Foundation, Inc.
+   Copyright 1993, 1994, 1995, 1998, 1999, 2001, 2002, 2003, 2004, 2005,
+   2006 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -90,11 +90,10 @@ make_bfd_asection (abfd, name, flags, size, offset, alignment_power)
 {
   asection *asect;
 
-  asect = bfd_make_section (abfd, name);
+  asect = bfd_make_section_with_flags (abfd, name, flags);
   if (!asect)
     return NULL;
 
-  asect->flags = flags;
   asect->size = size;
   asect->filepos = offset;
   asect->alignment_power = alignment_power;
index 08adcd3..b3c070c 100644 (file)
@@ -1,5 +1,5 @@
 /* BFD back-end for HP/UX core files.
-   Copyright 1993, 1994, 1996, 1998, 1999, 2001, 2002, 2003, 2004
+   Copyright 1993, 1994, 1996, 1998, 1999, 2001, 2002, 2003, 2004, 2006
    Free Software Foundation, Inc.
    Written by Stu Grossman, Cygnus Support.
    Converted to back-end form by Ian Lance Taylor, Cygnus SUpport
@@ -124,11 +124,10 @@ make_bfd_asection (bfd *abfd, const char *name, flagword flags,
 
   strcpy (newname, name);
 
-  asect = bfd_make_section_anyway (abfd, newname);
+  asect = bfd_make_section_anyway_with_flags (abfd, newname, flags);
   if (!asect)
     return NULL;
 
-  asect->flags = flags;
   asect->size = size;
   asect->vma = vma;
   asect->filepos = bfd_tell (abfd);
index 17c6180..519c40e 100644 (file)
@@ -312,9 +312,8 @@ linux_link_create_dynamic_sections (abfd, info)
 
   /* We choose to use the name ".linux-dynamic" for the fixup table.
      Why not? */
-  s = bfd_make_section (abfd, ".linux-dynamic");
+  s = bfd_make_section_with_flags (abfd, ".linux-dynamic", flags);
   if (s == NULL
-      || ! bfd_set_section_flags (abfd, s, flags)
       || ! bfd_set_section_alignment (abfd, s, 2))
     return FALSE;
   s->size = 0;
index 09670d9..910f24e 100644 (file)
@@ -1080,7 +1080,6 @@ get_section_entry (bfd *abfd, ieee_data_type *ieee, unsigned int index)
       sprintf (tmp, " fsec%4d", index);
       section = bfd_make_section (abfd, tmp);
       ieee->section_table[index] = section;
-      section->flags = SEC_NO_FLAGS;
       section->target_index = index;
       ieee->section_table[index] = section;
     }
@@ -1268,14 +1267,15 @@ ieee_slurp_debug (bfd *abfd)
   ieee_data_type *ieee = IEEE_DATA (abfd);
   asection *sec;
   file_ptr debug_end;
+  flagword flags;
 
   if (ieee->w.r.debug_information_part == 0)
     return TRUE;
 
-  sec = bfd_make_section (abfd, ".debug");
+  flags = SEC_DEBUGGING | SEC_HAS_CONTENTS;
+  sec = bfd_make_section_with_flags (abfd, ".debug", flags);
   if (sec == NULL)
     return FALSE;
-  sec->flags |= SEC_DEBUGGING | SEC_HAS_CONTENTS;
   sec->filepos = ieee->w.r.debug_information_part;
 
   debug_end = ieee_part_after (ieee, ieee->w.r.debug_information_part);
index 6695fe5..ae28959 100644 (file)
@@ -1,6 +1,6 @@
 /* BFD back-end for Intel Hex objects.
-   Copyright 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
-   Free Software Foundation, Inc.
+   Copyright 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
+   2006 Free Software Foundation, Inc.
    Written by Ian Lance Taylor of Cygnus Support <ian@cygnus.com>.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -355,6 +355,7 @@ ihex_scan (bfd *abfd)
                  char secbuf[20];
                  char *secname;
                  bfd_size_type amt;
+                 flagword flags;
 
                  sprintf (secbuf, ".sec%d", bfd_count_sections (abfd) + 1);
                  amt = strlen (secbuf) + 1;
@@ -362,10 +363,10 @@ ihex_scan (bfd *abfd)
                  if (secname == NULL)
                    goto error_return;
                  strcpy (secname, secbuf);
-                 sec = bfd_make_section (abfd, secname);
+                 flags = SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC;
+                 sec = bfd_make_section_with_flags (abfd, secname, flags);
                  if (sec == NULL)
                    goto error_return;
-                 sec->flags = SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC;
                  sec->vma = extbase + segbase + addr;
                  sec->lma = extbase + segbase + addr;
                  sec->size = len;
index e633145..17b6e1c 100644 (file)
@@ -1,5 +1,5 @@
 /* BFD back-end for Irix core files.
-   Copyright 1993, 1994, 1996, 1999, 2001, 2002, 2004
+   Copyright 1993, 1994, 1996, 1999, 2001, 2002, 2004, 2006
    Free Software Foundation, Inc.
    Written by Stu Grossman, Cygnus Support.
    Converted to back-end form by Ian Lance Taylor, Cygnus Support
@@ -152,11 +152,10 @@ make_bfd_asection (bfd *abfd,
 {
   asection *asect;
 
-  asect = bfd_make_section_anyway (abfd, name);
+  asect = bfd_make_section_anyway_with_flags (abfd, name, flags);
   if (!asect)
     return NULL;
 
-  asect->flags = flags;
   asect->size = size;
   asect->vma = vma;
   asect->filepos = filepos;
index ef243fb..5f91b45 100644 (file)
@@ -1,5 +1,5 @@
 /* BFD back end for Lynx core files
-   Copyright 1993, 1994, 1995, 2001, 2002, 2004
+   Copyright 1993, 1994, 1995, 2001, 2002, 2004, 2006
    Free Software Foundation, Inc.
    Written by Stu Grossman of Cygnus Support.
 
@@ -73,11 +73,10 @@ make_bfd_asection (abfd, name, flags, size, vma, filepos)
 
   strcpy (newname, name);
 
-  asect = bfd_make_section (abfd, newname);
+  asect = bfd_make_section_with_flags (abfd, newname, flags);
   if (!asect)
     return NULL;
 
-  asect->flags = flags;
   asect->size = size;
   asect->vma = vma;
   asect->filepos = filepos;
index 2c12a7c..03f8eaa 100644 (file)
@@ -316,9 +316,8 @@ linux_link_create_dynamic_sections (abfd, info)
 
   /* We choose to use the name ".linux-dynamic" for the fixup table.
      Why not? */
-  s = bfd_make_section (abfd, ".linux-dynamic");
+  s = bfd_make_section_with_flags (abfd, ".linux-dynamic", flags);
   if (s == NULL
-      || ! bfd_set_section_flags (abfd, s, flags)
       || ! bfd_set_section_alignment (abfd, s, 2))
     return FALSE;
   s->size = 0;
index 03a7144..666cf65 100644 (file)
@@ -1,5 +1,5 @@
 /* Mach-O support for BFD.
-   Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005
+   Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
    Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -634,6 +634,7 @@ bfd_mach_o_make_bfd_section (bfd *abfd, bfd_mach_o_section *section)
   char *sname;
   const char *prefix = "LC_SEGMENT";
   unsigned int snamelen;
+  flagword flags;
 
   snamelen = strlen (prefix) + 1
     + strlen (section->segname) + 1
@@ -644,7 +645,10 @@ bfd_mach_o_make_bfd_section (bfd *abfd, bfd_mach_o_section *section)
     return NULL;
   sprintf (sname, "%s.%s.%s", prefix, section->segname, section->sectname);
 
-  bfdsec = bfd_make_section_anyway (abfd, sname);
+  flags = SEC_ALLOC;
+  if (!(section->flags & BFD_MACH_O_S_ZEROFILL))
+    flags = SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC | SEC_CODE;
+  bfdsec = bfd_make_section_anyway_with_flags (abfd, sname, flags);
   if (bfdsec == NULL)
     return NULL;
 
@@ -654,11 +658,6 @@ bfd_mach_o_make_bfd_section (bfd *abfd, bfd_mach_o_section *section)
   bfdsec->filepos = section->offset;
   bfdsec->alignment_power = section->align;
 
-  if (section->flags & BFD_MACH_O_S_ZEROFILL)
-    bfdsec->flags = SEC_ALLOC;
-  else
-    bfdsec->flags = SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC | SEC_CODE;
-
   return bfdsec;
 }
 
@@ -966,7 +965,7 @@ bfd_mach_o_scan_read_dylinker (bfd *abfd,
     return -1;
   strcpy (sname, prefix);
 
-  bfdsec = bfd_make_section_anyway (abfd, sname);
+  bfdsec = bfd_make_section_anyway_with_flags (abfd, sname, SEC_HAS_CONTENTS);
   if (bfdsec == NULL)
     return -1;
 
@@ -975,7 +974,6 @@ bfd_mach_o_scan_read_dylinker (bfd *abfd,
   bfdsec->size = command->len - 8;
   bfdsec->filepos = command->offset + 8;
   bfdsec->alignment_power = 0;
-  bfdsec->flags = SEC_HAS_CONTENTS;
 
   cmd->section = bfdsec;
 
@@ -1022,7 +1020,7 @@ bfd_mach_o_scan_read_dylib (bfd *abfd, bfd_mach_o_load_command *command)
     return -1;
   strcpy (sname, prefix);
 
-  bfdsec = bfd_make_section_anyway (abfd, sname);
+  bfdsec = bfd_make_section_anyway_with_flags (abfd, sname, SEC_HAS_CONTENTS);
   if (bfdsec == NULL)
     return -1;
 
@@ -1031,7 +1029,6 @@ bfd_mach_o_scan_read_dylib (bfd *abfd, bfd_mach_o_load_command *command)
   bfdsec->size = command->len - 8;
   bfdsec->filepos = command->offset + 8;
   bfdsec->alignment_power = 0;
-  bfdsec->flags = SEC_HAS_CONTENTS;
 
   cmd->section = bfdsec;
 
@@ -1142,14 +1139,13 @@ bfd_mach_o_scan_read_thread (bfd *abfd, bfd_mach_o_load_command *command)
          j++;
        }
 
-      bfdsec = bfd_make_section (abfd, sname);
+      bfdsec = bfd_make_section_with_flags (abfd, sname, SEC_HAS_CONTENTS);
 
       bfdsec->vma = 0;
       bfdsec->lma = 0;
       bfdsec->size = cmd->flavours[i].size;
       bfdsec->filepos = cmd->flavours[i].offset;
       bfdsec->alignment_power = 0x0;
-      bfdsec->flags = SEC_HAS_CONTENTS;
 
       cmd->section = bfdsec;
     }
@@ -1218,7 +1214,7 @@ bfd_mach_o_scan_read_symtab (bfd *abfd, bfd_mach_o_load_command *command)
     return -1;
   strcpy (sname, prefix);
 
-  bfdsec = bfd_make_section_anyway (abfd, sname);
+  bfdsec = bfd_make_section_anyway_with_flags (abfd, sname, SEC_HAS_CONTENTS);
   if (bfdsec == NULL)
     return -1;
 
@@ -1227,7 +1223,6 @@ bfd_mach_o_scan_read_symtab (bfd *abfd, bfd_mach_o_load_command *command)
   bfdsec->size = seg->nsyms * 12;
   bfdsec->filepos = seg->symoff;
   bfdsec->alignment_power = 0;
-  bfdsec->flags = SEC_HAS_CONTENTS;
 
   seg->stabs_segment = bfdsec;
 
@@ -1237,7 +1232,7 @@ bfd_mach_o_scan_read_symtab (bfd *abfd, bfd_mach_o_load_command *command)
     return -1;
   strcpy (sname, prefix);
 
-  bfdsec = bfd_make_section_anyway (abfd, sname);
+  bfdsec = bfd_make_section_anyway_with_flags (abfd, sname, SEC_HAS_CONTENTS);
   if (bfdsec == NULL)
     return -1;
 
@@ -1246,7 +1241,6 @@ bfd_mach_o_scan_read_symtab (bfd *abfd, bfd_mach_o_load_command *command)
   bfdsec->size = seg->strsize;
   bfdsec->filepos = seg->stroff;
   bfdsec->alignment_power = 0;
-  bfdsec->flags = SEC_HAS_CONTENTS;
 
   seg->stabstr_segment = bfdsec;
 
@@ -1263,6 +1257,7 @@ bfd_mach_o_scan_read_segment (bfd *abfd, bfd_mach_o_load_command *command)
   char *sname;
   const char *prefix = "LC_SEGMENT";
   unsigned int snamelen;
+  flagword flags;
 
   BFD_ASSERT (command->type == BFD_MACH_O_LC_SEGMENT);
 
@@ -1286,7 +1281,8 @@ bfd_mach_o_scan_read_segment (bfd *abfd, bfd_mach_o_load_command *command)
     return -1;
   sprintf (sname, "%s.%s", prefix, seg->segname);
 
-  bfdsec = bfd_make_section_anyway (abfd, sname);
+  flags = SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC | SEC_CODE;
+  bfdsec = bfd_make_section_anyway_with_flags (abfd, sname, flags);
   if (bfdsec == NULL)
     return -1;
 
@@ -1295,7 +1291,6 @@ bfd_mach_o_scan_read_segment (bfd *abfd, bfd_mach_o_load_command *command)
   bfdsec->size = seg->filesize;
   bfdsec->filepos = seg->fileoff;
   bfdsec->alignment_power = 0x0;
-  bfdsec->flags = SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC | SEC_CODE;
 
   seg->segment = bfdsec;
 
index e9111a9..6bba177 100644 (file)
@@ -1,6 +1,6 @@
 /* BFD back end for NetBSD style core files
    Copyright 1988, 1989, 1991, 1992, 1993, 1996, 1998, 1999, 2000, 2001,
-   2002, 2003, 2004, 2005
+   2002, 2003, 2004, 2005, 2006
    Free Software Foundation, Inc.
    Written by Paul Kranenburg, EUR
 
@@ -126,11 +126,10 @@ netbsd_core_file_p (bfd *abfd)
          flags = SEC_ALLOC + SEC_HAS_CONTENTS;
          break;
        }
-      asect = bfd_make_section_anyway (abfd, sname);
+      asect = bfd_make_section_anyway_with_flags (abfd, sname, flags);
       if (asect == NULL)
        goto punt;
 
-      asect->flags = flags;
       asect->size = coreseg.c_size;
       asect->vma = coreseg.c_addr;
       asect->filepos = offset;
@@ -159,11 +158,12 @@ netbsd_core_file_p (bfd *abfd)
              asect->size = wcookie_offset;
 
              /* And create the .wcookie section.  */
-             asect = bfd_make_section_anyway (abfd, ".wcookie");
+             flags = SEC_ALLOC + SEC_HAS_CONTENTS;
+             asect = bfd_make_section_anyway_with_flags (abfd, ".wcookie",
+                                                         flags);
              if (asect == NULL)
                goto punt;
 
-             asect->flags = SEC_ALLOC + SEC_HAS_CONTENTS;
              asect->size = coreseg.c_size - wcookie_offset;
              asect->vma = 0;
              asect->filepos = offset + wcookie_offset;
index 4773061..a7d3985 100644 (file)
@@ -1,6 +1,6 @@
 /* NLM (NetWare Loadable Module) executable support for BFD.
    Copyright 1993, 1994, 1995, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-   2005 Free Software Foundation, Inc.
+   2005, 2006 Free Software Foundation, Inc.
 
    Written by Fred Fish @ Cygnus Support, using ELF support as the
    template.
@@ -138,14 +138,13 @@ add_bfd_section (bfd *abfd,
 {
   asection *newsect;
 
-  newsect = bfd_make_section (abfd, name);
+  newsect = bfd_make_section_with_flags (abfd, name, flags);
   if (newsect == NULL)
     return FALSE;
 
   newsect->vma = 0;            /* NLM's are relocatable.  */
   newsect->size = size;
   newsect->filepos = offset;
-  newsect->flags = flags;
   newsect->alignment_power = bfd_log2 ((bfd_vma) 0);   /* FIXME */
 
   return TRUE;
index 7e62d06..4131f9d 100644 (file)
@@ -1345,6 +1345,7 @@ bfd_create_gnu_debuglink_section (bfd *abfd, const char *filename)
 {
   asection *sect;
   bfd_size_type debuglink_size;
+  flagword flags;
 
   if (abfd == NULL || filename == NULL)
     {
@@ -1363,16 +1364,11 @@ bfd_create_gnu_debuglink_section (bfd *abfd, const char *filename)
       return NULL;
     }
 
-  sect = bfd_make_section (abfd, GNU_DEBUGLINK);
+  flags = SEC_HAS_CONTENTS | SEC_READONLY | SEC_DEBUGGING;
+  sect = bfd_make_section_with_flags (abfd, GNU_DEBUGLINK, flags);
   if (sect == NULL)
     return NULL;
 
-  if (! bfd_set_section_flags (abfd, sect,
-                              SEC_HAS_CONTENTS | SEC_READONLY | SEC_DEBUGGING))
-    /* XXX Should we delete the section from the bfd ?  */
-    return NULL;
-
-
   debuglink_size = strlen (filename) + 1;
   debuglink_size += 3;
   debuglink_size &= ~3;
index cc6c4dc..1d3802b 100644 (file)
@@ -1,5 +1,5 @@
 /* BFD back-end for OSF/1 core files.
-   Copyright 1993, 1994, 1995, 1998, 1999, 2001, 2002, 2003, 2004
+   Copyright 1993, 1994, 1995, 1998, 1999, 2001, 2002, 2003, 2004, 2006
    Free Software Foundation, Inc.
 
 This file is part of BFD, the Binary File Descriptor library.
@@ -67,11 +67,10 @@ make_bfd_asection (abfd, name, flags, size, vma, filepos)
 {
   asection *asect;
 
-  asect = bfd_make_section_anyway (abfd, name);
+  asect = bfd_make_section_anyway_with_flags (abfd, name, flags);
   if (!asect)
     return NULL;
 
-  asect->flags = flags;
   asect->size = size;
   asect->vma = vma;
   asect->filepos = filepos;
index 7130021..d7a2991 100644 (file)
@@ -147,6 +147,7 @@ _bfd_XXi_swap_sym_in (bfd * abfd, void * ext1, void * in1)
          int unused_section_number = 0;
          asection *sec;
          char *name;
+         flagword flags;
 
          for (sec = abfd->sections; sec; sec = sec->next)
            if (unused_section_number <= sec->target_index)
@@ -156,7 +157,8 @@ _bfd_XXi_swap_sym_in (bfd * abfd, void * ext1, void * in1)
          if (name == NULL)
            return;
          strcpy (name, in->n_name);
-         sec = bfd_make_section_anyway (abfd, name);
+         flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_DATA | SEC_LOAD;
+         sec = bfd_make_section_anyway_with_flags (abfd, name, flags);
 
          sec->vma = 0;
          sec->lma = 0;
@@ -169,7 +171,6 @@ _bfd_XXi_swap_sym_in (bfd * abfd, void * ext1, void * in1)
          sec->userdata = NULL;
          sec->next = NULL;
          sec->alignment_power = 2;
-         sec->flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_DATA | SEC_LOAD;
 
          sec->target_index = unused_section_number;
 
index 7c8a419..9cd7c26 100644 (file)
@@ -1,5 +1,5 @@
 /* BFD back-end for PPCbug boot records.
-   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
+   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2006
    Free Software Foundation, Inc.
    Written by Michael Meissner, Cygnus Support, <meissner@cygnus.com>
 
@@ -151,6 +151,7 @@ ppcboot_object_p (abfd)
   ppcboot_hdr_t hdr;
   size_t i;
   ppcboot_data_t *tdata;
+  flagword flags;
 
   BFD_ASSERT (sizeof (ppcboot_hdr_t) == 1024);
 
@@ -205,10 +206,10 @@ ppcboot_object_p (abfd)
   abfd->symcount = PPCBOOT_SYMS;
 
   /* One data section.  */
-  sec = bfd_make_section (abfd, ".data");
+  flags = SEC_ALLOC | SEC_LOAD | SEC_DATA | SEC_CODE | SEC_HAS_CONTENTS;
+  sec = bfd_make_section_with_flags (abfd, ".data", flags);
   if (sec == NULL)
     return NULL;
-  sec->flags = SEC_ALLOC | SEC_LOAD | SEC_DATA | SEC_CODE | SEC_HAS_CONTENTS;
   sec->vma = 0;
   sec->size = statbuf.st_size - sizeof (ppcboot_hdr_t);
   sec->filepos = sizeof (ppcboot_hdr_t);
index 4ac28aa..8b4a86b 100644 (file)
@@ -1,5 +1,5 @@
 /* BFD backend for core files which use the ptrace_user structure
-   Copyright 1993, 1994, 1995, 1996, 1998, 1999, 2001, 2002, 2003, 2004
+   Copyright 1993, 1994, 1995, 1996, 1998, 1999, 2001, 2002, 2003, 2004, 2006
    Free Software Foundation, Inc.
    The structure of this file is based on trad-core.c written by John Gilmore
    of Cygnus Support.
@@ -63,6 +63,7 @@ ptrace_unix_core_file_p (abfd)
   struct ptrace_user u;
   struct trad_core_struct *rawptr;
   bfd_size_type amt;
+  flagword flags;
 
   val = bfd_bread ((void *)&u, (bfd_size_type) sizeof u, abfd);
   if (val != sizeof u || u.pt_magic != _BCS_PTRACE_MAGIC
@@ -89,13 +90,17 @@ ptrace_unix_core_file_p (abfd)
 
   /* Create the sections.  */
 
-  core_stacksec (abfd) = bfd_make_section_anyway (abfd, ".stack");
+  flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
+  core_stacksec (abfd) = bfd_make_section_anyway_with_flags (abfd, ".stack",
+                                                            flags);
   if (core_stacksec (abfd) == NULL)
     goto fail;
-  core_datasec (abfd) = bfd_make_section_anyway (abfd, ".data");
+  core_datasec (abfd) = bfd_make_section_anyway_with_flags (abfd, ".data",
+                                                           flags);
   if (core_datasec (abfd) == NULL)
     goto fail;
-  core_regsec (abfd) = bfd_make_section_anyway (abfd, ".reg");
+  core_regsec (abfd) = bfd_make_section_anyway_with_flags (abfd, ".reg",
+                                                          SEC_HAS_CONTENTS);
   if (core_regsec (abfd) == NULL)
     goto fail;
 
@@ -103,10 +108,6 @@ ptrace_unix_core_file_p (abfd)
      text.  I don't think that any of these things are supported on the
      system on which I am developing this for though.  */
 
-  core_stacksec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
-  core_datasec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
-  core_regsec (abfd)->flags = SEC_HAS_CONTENTS;
-
   core_datasec (abfd)->size =  u.pt_dsize;
   core_stacksec (abfd)->size = u.pt_ssize;
   core_regsec (abfd)->size = sizeof (u);
index 280a020..a848d08 100644 (file)
@@ -1,6 +1,6 @@
 /* IBM RS/6000 "XCOFF" back-end for BFD.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000,
-   2001, 2002, 2004
+   2001, 2002, 2004, 2006
    Free Software Foundation, Inc.
    FIXME: Can someone provide a transliteration of this name into ASCII?
    Using the following chars caused a compiler warning on HIUX (so I replaced
@@ -294,11 +294,10 @@ make_bfd_asection (bfd *abfd, const char *name, flagword flags,
 {
   asection *asect;
 
-  asect = bfd_make_section_anyway (abfd, name);
+  asect = bfd_make_section_anyway_with_flags (abfd, name, flags);
   if (!asect)
     return NULL;
 
-  asect->flags = flags;
   asect->size = size;
   asect->vma = vma;
   asect->filepos = filepos;
index 9a06b88..3a93a4e 100644 (file)
@@ -1,5 +1,5 @@
 /* BFD back end for SCO5 core files (U-area and raw sections)
-   Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
+   Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
    Free Software Foundation, Inc.
    Written by Jouke Numan <jnuman@hiscom.nl>
 
@@ -63,10 +63,9 @@ make_bfd_asection (abfd, name, flags, size, vma, filepos)
 {
   asection *asect;
 
-  asect = bfd_make_section_anyway (abfd, name);
+  asect = bfd_make_section_anyway_with_flags (abfd, name, flags);
   if (!asect)
     return NULL;
-  asect->flags = flags;
   asect->size = size;
   asect->vma = vma;
   asect->filepos = filepos;
index d8659ee..6b534e3 100644 (file)
@@ -313,9 +313,8 @@ linux_link_create_dynamic_sections (abfd, info)
 
   /* We choose to use the name ".linux-dynamic" for the fixup table.
      Why not?  */
-  s = bfd_make_section (abfd, ".linux-dynamic");
+  s = bfd_make_section_with_flags (abfd, ".linux-dynamic", flags);
   if (s == NULL
-      || ! bfd_set_section_flags (abfd, s, flags)
       || ! bfd_set_section_alignment (abfd, s, 2))
     return FALSE;
   s->size = 0;
index 2b24f46..836b81e 100644 (file)
@@ -1,6 +1,6 @@
 /* BFD back-end for s-record objects.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003, 2004, 2005
+   2000, 2001, 2002, 2003, 2004, 2005, 2006
    Free Software Foundation, Inc.
    Written by Steve Chamberlain of Cygnus Support <sac@cygnus.com>.
 
@@ -526,15 +526,16 @@ srec_scan (bfd *abfd)
                    char secbuf[20];
                    char *secname;
                    bfd_size_type amt;
+                   flagword flags;
 
                    sprintf (secbuf, ".sec%d", bfd_count_sections (abfd) + 1);
                    amt = strlen (secbuf) + 1;
                    secname = bfd_alloc (abfd, amt);
                    strcpy (secname, secbuf);
-                   sec = bfd_make_section (abfd, secname);
+                   flags = SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC;
+                   sec = bfd_make_section_with_flags (abfd, secname, flags);
                    if (sec == NULL)
                      goto error_return;
-                   sec->flags = SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC;
                    sec->vma = address;
                    sec->lma = address;
                    sec->size = bytes;
index ba3f934..4f48e8e 100644 (file)
@@ -187,6 +187,8 @@ _bfd_link_section_stabs (bfd *abfd,
 
   if (sinfo->stabstr == NULL)
     {
+      flagword flags;
+
       /* Initialize the stabs information we need to keep track of.  */
       first = TRUE;
       sinfo->strings = _bfd_stringtab_init ();
@@ -198,11 +200,12 @@ _bfd_link_section_stabs (bfd *abfd,
                                 stab_link_includes_newfunc,
                                 sizeof (struct stab_link_includes_entry)))
        goto error_return;
-      sinfo->stabstr = bfd_make_section_anyway (abfd, ".stabstr");
+      flags = (SEC_HAS_CONTENTS | SEC_READONLY | SEC_DEBUGGING
+              | SEC_LINKER_CREATED);
+      sinfo->stabstr = bfd_make_section_anyway_with_flags (abfd, ".stabstr",
+                                                          flags);
       if (sinfo->stabstr == NULL)
        goto error_return;
-      sinfo->stabstr->flags |= (SEC_HAS_CONTENTS | SEC_READONLY
-                               | SEC_DEBUGGING | SEC_LINKER_CREATED);
     }
 
   /* Initialize the information we are going to store for this .stab
index 024320f..a9117f4 100644 (file)
@@ -745,57 +745,50 @@ sunos_create_dynamic_sections (bfd *abfd,
       /* The .dynamic section holds the basic dynamic information: the
         sun4_dynamic structure, the dynamic debugger information, and
         the sun4_dynamic_link structure.  */
-      s = bfd_make_section (abfd, ".dynamic");
+      s = bfd_make_section_with_flags (abfd, ".dynamic", flags);
       if (s == NULL
-         || ! bfd_set_section_flags (abfd, s, flags)
          || ! bfd_set_section_alignment (abfd, s, 2))
        return FALSE;
 
       /* The .got section holds the global offset table.  The address
         is put in the ld_got field.  */
-      s = bfd_make_section (abfd, ".got");
+      s = bfd_make_section_with_flags (abfd, ".got", flags);
       if (s == NULL
-         || ! bfd_set_section_flags (abfd, s, flags)
          || ! bfd_set_section_alignment (abfd, s, 2))
        return FALSE;
 
       /* The .plt section holds the procedure linkage table.  The
         address is put in the ld_plt field.  */
-      s = bfd_make_section (abfd, ".plt");
+      s = bfd_make_section_with_flags (abfd, ".plt", flags | SEC_CODE);
       if (s == NULL
-         || ! bfd_set_section_flags (abfd, s, flags | SEC_CODE)
          || ! bfd_set_section_alignment (abfd, s, 2))
        return FALSE;
 
       /* The .dynrel section holds the dynamic relocs.  The address is
         put in the ld_rel field.  */
-      s = bfd_make_section (abfd, ".dynrel");
+      s = bfd_make_section_with_flags (abfd, ".dynrel", flags | SEC_READONLY);
       if (s == NULL
-         || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
          || ! bfd_set_section_alignment (abfd, s, 2))
        return FALSE;
 
       /* The .hash section holds the dynamic hash table.  The address
         is put in the ld_hash field.  */
-      s = bfd_make_section (abfd, ".hash");
+      s = bfd_make_section_with_flags (abfd, ".hash", flags | SEC_READONLY);
       if (s == NULL
-         || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
          || ! bfd_set_section_alignment (abfd, s, 2))
        return FALSE;
 
       /* The .dynsym section holds the dynamic symbols.  The address
         is put in the ld_stab field.  */
-      s = bfd_make_section (abfd, ".dynsym");
+      s = bfd_make_section_with_flags (abfd, ".dynsym", flags | SEC_READONLY);
       if (s == NULL
-         || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
          || ! bfd_set_section_alignment (abfd, s, 2))
        return FALSE;
 
       /* The .dynstr section holds the dynamic symbol string table.
         The address is put in the ld_symbols field.  */
-      s = bfd_make_section (abfd, ".dynstr");
+      s = bfd_make_section_with_flags (abfd, ".dynstr", flags | SEC_READONLY);
       if (s == NULL
-         || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
          || ! bfd_set_section_alignment (abfd, s, 2))
        return FALSE;
 
@@ -890,14 +883,10 @@ sunos_add_dynamic_symbols (bfd *abfd,
       /* The .need section holds the list of names of shared objets
         which must be included at runtime.  The address of this
         section is put in the ld_need field.  */
-      asection *s = bfd_make_section (dynobj, ".need");
+      flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
+                       | SEC_IN_MEMORY | SEC_READONLY);
+      asection *s = bfd_make_section_with_flags (dynobj, ".need", flags);
       if (s == NULL
-         || ! bfd_set_section_flags (dynobj, s,
-                                     (SEC_ALLOC
-                                      | SEC_LOAD
-                                      | SEC_HAS_CONTENTS
-                                      | SEC_IN_MEMORY
-                                      | SEC_READONLY))
          || ! bfd_set_section_alignment (dynobj, s, 2))
        return FALSE;
     }
@@ -907,14 +896,10 @@ sunos_add_dynamic_symbols (bfd *abfd,
       /* The .rules section holds the path to search for shared
         objects.  The address of this section is put in the ld_rules
         field.  */
-      asection *s = bfd_make_section (dynobj, ".rules");
+      flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
+                       | SEC_IN_MEMORY | SEC_READONLY);
+      asection *s = bfd_make_section_with_flags (dynobj, ".rules", flags);
       if (s == NULL
-         || ! bfd_set_section_flags (dynobj, s,
-                                     (SEC_ALLOC
-                                      | SEC_LOAD
-                                      | SEC_HAS_CONTENTS
-                                      | SEC_IN_MEMORY
-                                      | SEC_READONLY))
          || ! bfd_set_section_alignment (dynobj, s, 2))
        return FALSE;
     }
index cb4111f..2b309c0 100644 (file)
@@ -1,6 +1,6 @@
 /* BFD back end for traditional Unix core files (U-area and raw sections)
    Copyright 1988, 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999,
-   2000, 2001, 2002, 2003, 2004, 2005
+   2000, 2001, 2002, 2003, 2004, 2005, 2006
    Free Software Foundation, Inc.
    Written by John Gilmore of Cygnus Support.
 
@@ -79,6 +79,7 @@ trad_unix_core_file_p (abfd)
   struct user u;
   struct trad_core_struct *rawptr;
   bfd_size_type amt;
+  flagword flags;
 
 #ifdef TRAD_CORE_USER_OFFSET
   /* If defined, this macro is the file position of the user struct.  */
@@ -155,20 +156,20 @@ trad_unix_core_file_p (abfd)
 
   /* Create the sections.  */
 
-  core_stacksec(abfd) = bfd_make_section_anyway (abfd, ".stack");
+  flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
+  core_stacksec(abfd) = bfd_make_section_anyway_with_flags (abfd, ".stack",
+                                                           flags);
   if (core_stacksec (abfd) == NULL)
     goto fail;
-  core_datasec (abfd) = bfd_make_section_anyway (abfd, ".data");
+  core_datasec (abfd) = bfd_make_section_anyway_with_flags (abfd, ".data",
+                                                           flags);
   if (core_datasec (abfd) == NULL)
     goto fail;
-  core_regsec (abfd) = bfd_make_section_anyway (abfd, ".reg");
+  core_regsec (abfd) = bfd_make_section_anyway_with_flags (abfd, ".reg",
+                                                          SEC_HAS_CONTENTS);
   if (core_regsec (abfd) == NULL)
     goto fail;
 
-  core_stacksec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
-  core_datasec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
-  core_regsec (abfd)->flags = SEC_HAS_CONTENTS;
-
   core_datasec (abfd)->size =  NBPG * u.u_dsize
 #ifdef TRAD_CORE_DSIZE_INCLUDES_TSIZE
     - NBPG * u.u_tsize
index 47c330b..e76b95c 100644 (file)
@@ -794,27 +794,27 @@ xcoff_link_create_extra_sections (bfd * abfd, struct bfd_link_info *info)
       if (xcoff_hash_table (info)->loader_section == NULL)
        {
          asection *lsec;
+         flagword flags = SEC_HAS_CONTENTS | SEC_IN_MEMORY;
 
-         lsec = bfd_make_section_anyway (abfd, ".loader");
+         lsec = bfd_make_section_anyway_with_flags (abfd, ".loader", flags);
          if (lsec == NULL)
            goto end_return;
 
          xcoff_hash_table (info)->loader_section = lsec;
-         lsec->flags |= SEC_HAS_CONTENTS | SEC_IN_MEMORY;
        }
 
       /* Likewise for the linkage section.  */
       if (xcoff_hash_table (info)->linkage_section == NULL)
        {
          asection *lsec;
+         flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
+                           | SEC_IN_MEMORY);
 
-         lsec = bfd_make_section_anyway (abfd, ".gl");
+         lsec = bfd_make_section_anyway_with_flags (abfd, ".gl", flags);
          if (lsec == NULL)
            goto end_return;
 
          xcoff_hash_table (info)->linkage_section = lsec;
-         lsec->flags |= (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
-                         | SEC_IN_MEMORY);
          lsec->alignment_power = 2;
        }
 
@@ -822,14 +822,14 @@ xcoff_link_create_extra_sections (bfd * abfd, struct bfd_link_info *info)
       if (xcoff_hash_table (info)->toc_section == NULL)
        {
          asection *tsec;
+         flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
+                           | SEC_IN_MEMORY);
 
-         tsec = bfd_make_section_anyway (abfd, ".tc");
+         tsec = bfd_make_section_anyway_with_flags (abfd, ".tc", flags);
          if (tsec == NULL)
            goto end_return;
 
          xcoff_hash_table (info)->toc_section = tsec;
-         tsec->flags |= (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
-                         | SEC_IN_MEMORY);
          tsec->alignment_power = 2;
        }
 
@@ -837,14 +837,14 @@ xcoff_link_create_extra_sections (bfd * abfd, struct bfd_link_info *info)
       if (xcoff_hash_table (info)->descriptor_section == NULL)
        {
          asection *dsec;
+         flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
+                           | SEC_IN_MEMORY);
 
-         dsec = bfd_make_section_anyway (abfd, ".ds");
+         dsec = bfd_make_section_anyway_with_flags (abfd, ".ds", flags);
          if (dsec == NULL)
            goto end_return;
 
          xcoff_hash_table (info)->descriptor_section = dsec;
-         dsec->flags |= (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
-                         | SEC_IN_MEMORY);
          dsec->alignment_power = 2;
        }
 
@@ -853,13 +853,13 @@ xcoff_link_create_extra_sections (bfd * abfd, struct bfd_link_info *info)
          && info->strip != strip_all)
        {
          asection *dsec;
+         flagword flags = SEC_HAS_CONTENTS | SEC_IN_MEMORY;
 
-         dsec = bfd_make_section_anyway (abfd, ".debug");
+         dsec = bfd_make_section_anyway_with_flags (abfd, ".debug", flags);
          if (dsec == NULL)
            goto end_return;
 
          xcoff_hash_table (info)->debug_section = dsec;
-         dsec->flags |= SEC_HAS_CONTENTS | SEC_IN_MEMORY;
        }
     }
 
@@ -1552,16 +1552,17 @@ xcoff_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
            {
              /* The linker script puts the .td section in the data
                 section after the .tc section.  */
-             csect = bfd_make_section_anyway (abfd, ".td");
+             csect = bfd_make_section_anyway_with_flags (abfd, ".td",
+                                                         SEC_ALLOC);
            }
          else
-           csect = bfd_make_section_anyway (abfd, ".bss");
+           csect = bfd_make_section_anyway_with_flags (abfd, ".bss",
+                                                       SEC_ALLOC);
 
          if (csect == NULL)
            goto error_return;
          csect->vma = sym.n_value;
          csect->size = aux.x_csect.x_scnlen.l;
-         csect->flags |= SEC_ALLOC;
          csect->alignment_power = SMTYP_ALIGN (aux.x_csect.x_smtyp);
          /* There are a number of other fields and section flags
             which we do not bother to set.  */
@@ -5460,8 +5461,8 @@ _bfd_xcoff_bfd_final_link (bfd *abfd, struct bfd_link_info *info)
                         that needs padding.  This requires unlinking and
                         relinking the bfd's section list.  */
 
-                     n = bfd_make_section_anyway (abfd, ".pad");
-                     n->flags = SEC_HAS_CONTENTS;
+                     n = bfd_make_section_anyway_with_flags (abfd, ".pad",
+                                                             SEC_HAS_CONTENTS);
                      n->alignment_power = 0;
 
                      bfd_section_list_remove (abfd, n);
index 9659a65..dfd7505 100644 (file)
@@ -1,5 +1,5 @@
 /* xSYM symbol-file support for BFD.
-   Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005
+   Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
    Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -2228,7 +2228,7 @@ bfd_sym_scan (bfd *abfd, bfd_sym_version version, bfd_sym_data_struct *mdata)
   if (mdata->name_table == NULL)
     return -1;
 
-  bfdsec = bfd_make_section_anyway (abfd, name);
+  bfdsec = bfd_make_section_anyway_with_flags (abfd, name, SEC_HAS_CONTENTS);
   if (bfdsec == NULL)
     return -1;
 
@@ -2238,8 +2238,6 @@ bfd_sym_scan (bfd *abfd, bfd_sym_version version, bfd_sym_data_struct *mdata)
   bfdsec->filepos = 0;
   bfdsec->alignment_power = 0;
 
-  bfdsec->flags = SEC_HAS_CONTENTS;
-
   abfd->tdata.sym_data = mdata;
 
   return 0;