diff options
-rw-r--r-- | bfd/ChangeLog | 82 | ||||
-rw-r--r-- | bfd/elf-m10300.c | 55 | ||||
-rw-r--r-- | bfd/elf.c | 9 | ||||
-rw-r--r-- | bfd/elf32-arm.c | 26 | ||||
-rw-r--r-- | bfd/elf32-cris.c | 31 | ||||
-rw-r--r-- | bfd/elf32-frv.c | 45 | ||||
-rw-r--r-- | bfd/elf32-hppa.c | 20 | ||||
-rw-r--r-- | bfd/elf32-i370.c | 18 | ||||
-rw-r--r-- | bfd/elf32-i386.c | 16 | ||||
-rw-r--r-- | bfd/elf32-m32r.c | 51 | ||||
-rw-r--r-- | bfd/elf32-m68k.c | 32 | ||||
-rw-r--r-- | bfd/elf32-ppc.c | 41 | ||||
-rw-r--r-- | bfd/elf32-s390.c | 16 | ||||
-rw-r--r-- | bfd/elf32-sh.c | 47 | ||||
-rw-r--r-- | bfd/elf32-vax.c | 32 | ||||
-rw-r--r-- | bfd/elf32-xstormy16.c | 18 | ||||
-rw-r--r-- | bfd/elf32-xtensa.c | 17 | ||||
-rw-r--r-- | bfd/elf64-alpha.c | 60 | ||||
-rw-r--r-- | bfd/elf64-hppa.c | 116 | ||||
-rw-r--r-- | bfd/elf64-mmix.c | 12 | ||||
-rw-r--r-- | bfd/elf64-ppc.c | 29 | ||||
-rw-r--r-- | bfd/elf64-s390.c | 16 | ||||
-rw-r--r-- | bfd/elf64-sh64.c | 48 | ||||
-rw-r--r-- | bfd/elf64-x86-64.c | 16 | ||||
-rw-r--r-- | bfd/elflink.c | 82 | ||||
-rw-r--r-- | bfd/elfxx-ia64.c | 98 | ||||
-rw-r--r-- | bfd/elfxx-mips.c | 35 | ||||
-rw-r--r-- | bfd/elfxx-sparc.c | 19 | ||||
-rw-r--r-- | bfd/section.c | 67 |
29 files changed, 640 insertions, 514 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index dadf6be..1f8c056 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,5 +1,87 @@ 2005-05-05 H.J. Lu <hongjiu.lu@intel.com> + * section.c (bfd_make_section_anyway_with_flags): New. + (bfd_make_section_anyway): Call bfd_make_section_anyway_with_flags, + (bfd_make_section_with_flags): New. + (bfd_make_section): Call bfd_make_section_with_flags. + + * elf-m10300.c (_bfd_mn10300_elf_create_got_section): Call + bfd_make_section_with_flags/bfd_make_section_anyway_with_flags + instead of bfd_make_section/bfd_make_section and don't call + bfd_set_section_flags. + (mn10300_elf_check_relocs): Likewise. + (_bfd_mn10300_elf_create_dynamic_sections): Likewise. + * elf32-arm.c (create_got_section): Likewise. + (bfd_elf32_arm_add_glue_sections_to_bfd): Likewise. + (elf32_arm_check_relocs): Likewise. + * elf32-cris.c (cris_elf_check_relocs): Likewise. + * elf32-frv.c (elf32_frv_add_symbol_hook): Likewise. + (_frv_create_got_section): Likewise. + (elf32_frvfdpic_create_dynamic_sections): Likewise. + * elf32-hppa.c (elf32_hppa_create_dynamic_sections): Likewise. + (elf32_hppa_check_relocs): Likewise. + * elf32-i370.c (i370_elf_create_dynamic_sections): Likewise. + (i370_elf_check_relocs): Likewise. + * elf32-i386.c (create_got_section): Likewise. + (elf_i386_check_relocs): Likewise. + * elf32-m32r.c (m32r_elf_add_symbol_hook): Likewise. + (create_got_section): Likewise. + (m32r_elf_create_dynamic_sections): Likewise. + (m32r_elf_check_relocs): Likewise. + * elf32-m68k.c (elf_m68k_check_relocs): Likewise. + * elf32-ppc.c (ppc_elf_create_got): Likewise. + (ppc_elf_create_dynamic_sections): Likewise. + (ppc_elf_add_symbol_hook): Likewise. + (ppc_elf_check_relocs): Likewise. + * elf32-s390.c (create_got_section): Likewise. + (elf_s390_check_relocs): Likewise. + * elf32-sh.c (create_got_section): Likewise. + (sh_elf_create_dynamic_sections): Likewise. + (sh_elf_check_relocs): Likewise. + * elf32-vax.c (elf_vax_check_relocs): Likewise. + * elf32-xstormy16.c (xstormy16_elf_check_relocs): Likewise. + * elf32-xtensa.c (elf_xtensa_create_dynamic_sections): Likewise. + (add_extra_plt_sections): Likewise. + * elf64-alpha.c (elf64_alpha_add_symbol_hook): Likewise. + (elf64_alpha_create_got_section): Likewise. + (elf64_alpha_create_dynamic_sections): Likewise. + (elf64_alpha_check_relocs): Likewise. + * elf64-hppa.c (get_reloc_section): Likewise. + (get_opd): Likewise. + (get_plt): Likewise. + (get_dlt): Likewise. + (get_stub): Likewise. + (elf64_hppa_create_dynamic_sectionso): Likewise. + * elf64-mmix.c (mmix_elf_check_common_relocs): Likewise. + * elf64-ppc.c (create_linkage_sections): Likewise. + (ppc64_elf_check_relocs): Likewise. + * elf64-s390.c (create_got_section): Likewise. + (elf_s390_check_relocs): Likewise. + * elf64-sh64.c (sh_elf64_check_relocs): Likewise. + (sh64_elf64_create_dynamic_sections): Likewise. + * elf64-x86-64.c (create_got_section): Likewise. + (elf64_x86_64_check_relocs): Likewise. + * elflink.c (_bfd_elf_create_got_section): Likewise. + (_bfd_elf_link_create_dynamic_sections): Likewise. + (elf_link_add_object_symbols): Likewise. + * elfxx-ia64.c (elfNN_ia64_add_symbol_hook): Likewise. + (elfNN_ia64_create_dynamic_sections): Likewise. + (get_fptr): Likewise. + (get_pltoff): Likewise. + (get_reloc_section): Likewise. + (elfNN_ia64_object_p): Likewise. + * elfxx-mips.c (mips_elf_rel_dyn_section): Likewise. + (mips_elf_create_compact_rel_section): Likewise. + (mips_elf_create_got_section): Likewise. + (_bfd_mips_elf_create_dynamic_sections): Likewise. + * elfxx-sparc.c (create_got_section): Likewise. + (_bfd_sparc_elf_check_relocs): Likewise. + + * elf.c (_bfd_elf_new_section_hook): Call _bfd_elf_get_sec_type_attr + on linker created sections. + +2005-05-05 H.J. Lu <hongjiu.lu@intel.com> + PR 882 * elflink.c (_bfd_elf_link_assign_sym_version): Allow version script on executable. diff --git a/bfd/elf-m10300.c b/bfd/elf-m10300.c index cfb2231..c9a9848 100644 --- a/bfd/elf-m10300.c +++ b/bfd/elf-m10300.c @@ -576,9 +576,8 @@ _bfd_mn10300_elf_create_got_section (abfd, 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; @@ -601,17 +600,15 @@ _bfd_mn10300_elf_create_got_section (abfd, info) return FALSE; } - 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, ptralign)) return FALSE; if (bed->want_got_plt) { - s = bfd_make_section (abfd, ".got.plt"); + s = bfd_make_section_with_flags (abfd, ".got.plt", flags); if (s == NULL - || ! bfd_set_section_flags (abfd, s, flags) || ! bfd_set_section_alignment (abfd, s, ptralign)) return FALSE; } @@ -778,15 +775,15 @@ mn10300_elf_check_relocs (abfd, info, sec, relocs) srelgot = bfd_get_section_by_name (dynobj, ".rela.got"); if (srelgot == NULL) { - srelgot = bfd_make_section (dynobj, ".rela.got"); + srelgot = bfd_make_section_with_flags (dynobj, + ".rela.got", + (SEC_ALLOC + | SEC_LOAD + | SEC_HAS_CONTENTS + | SEC_IN_MEMORY + | SEC_LINKER_CREATED + | SEC_READONLY)); 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; } @@ -910,13 +907,14 @@ mn10300_elf_check_relocs (abfd, info, sec, relocs) { flagword flags; - sreloc = bfd_make_section (dynobj, name); flags = (SEC_HAS_CONTENTS | SEC_READONLY | SEC_IN_MEMORY | SEC_LINKER_CREATED); if ((sec->flags & SEC_ALLOC) != 0) flags |= SEC_ALLOC | SEC_LOAD; + sreloc = bfd_make_section_with_flags (dynobj, + name, + flags); if (sreloc == NULL - || ! bfd_set_section_flags (dynobj, sreloc, flags) || ! bfd_set_section_alignment (dynobj, sreloc, 2)) return FALSE; } @@ -3925,10 +3923,11 @@ _bfd_mn10300_elf_create_dynamic_sections (abfd, info) flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED); - s = bfd_make_section (abfd, - bed->default_use_rela_p ? ".rela.plt" : ".rel.plt"); + s = bfd_make_section_with_flags (abfd, + (bed->default_use_rela_p + ? ".rela.plt" : ".rel.plt"), + flags | SEC_READONLY); if (s == NULL - || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY) || ! bfd_set_section_alignment (abfd, s, ptralign)) return FALSE; @@ -3953,9 +3952,9 @@ _bfd_mn10300_elf_create_dynamic_sections (abfd, info) strcpy (relname, ".rela"); strcat (relname, secname); - s = bfd_make_section (abfd, relname); + s = bfd_make_section_with_flags (abfd, relname, + flags | SEC_READONLY); if (s == NULL - || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY) || ! bfd_set_section_alignment (abfd, s, ptralign)) return FALSE; } @@ -3969,9 +3968,9 @@ _bfd_mn10300_elf_create_dynamic_sections (abfd, 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)) + 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 @@ -3987,11 +3986,11 @@ _bfd_mn10300_elf_create_dynamic_sections (abfd, 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, ptralign)) return FALSE; } @@ -2245,10 +2245,11 @@ _bfd_elf_new_section_hook (bfd *abfd, asection *sec) sec->used_by_bfd = sdata; } - /* When we read a file, we don't need section type and flags. - They will be overridden in _bfd_elf_make_section_from_shdr - anyway. */ - if (abfd->direction != read_direction) + /* When we read a file, we don't need section type and flags unless + it is a linker created section. They will be overridden in + _bfd_elf_make_section_from_shdr anyway. */ + if (abfd->direction != read_direction + || (sec->flags & SEC_LINKER_CREATED) != 0) { ssect = _bfd_elf_get_sec_type_attr (abfd, sec->name); if (ssect != NULL) diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index 624d995..7fdcfb0 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -1414,12 +1414,13 @@ create_got_section (bfd *dynobj, struct bfd_link_info *info) if (!htab->sgot || !htab->sgotplt) abort (); - htab->srelgot = bfd_make_section (dynobj, ".rel.got"); + htab->srelgot = bfd_make_section_with_flags (dynobj, ".rel.got", + (SEC_ALLOC | SEC_LOAD + | SEC_HAS_CONTENTS + | SEC_IN_MEMORY + | SEC_LINKER_CREATED + | SEC_READONLY)); if (htab->srelgot == NULL - || ! bfd_set_section_flags (dynobj, htab->srelgot, - (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS - | SEC_IN_MEMORY | SEC_LINKER_CREATED - | SEC_READONLY)) || ! bfd_set_section_alignment (dynobj, htab->srelgot, 2)) return FALSE; return TRUE; @@ -1897,10 +1898,11 @@ bfd_elf32_arm_add_glue_sections_to_bfd (bfd *abfd, of this section. */ flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_CODE | SEC_READONLY; - sec = bfd_make_section (abfd, ARM2THUMB_GLUE_SECTION_NAME); + 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; @@ -1916,10 +1918,11 @@ bfd_elf32_arm_add_glue_sections_to_bfd (bfd *abfd, flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_CODE | SEC_READONLY; - sec = bfd_make_section (abfd, THUMB2ARM_GLUE_SECTION_NAME); + 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; @@ -4690,7 +4693,6 @@ elf32_arm_check_relocs (bfd *abfd, struct bfd_link_info *info, { flagword flags; - sreloc = bfd_make_section (dynobj, name); flags = (SEC_HAS_CONTENTS | SEC_READONLY | SEC_IN_MEMORY | SEC_LINKER_CREATED); if ((sec->flags & SEC_ALLOC) != 0 @@ -4698,8 +4700,10 @@ elf32_arm_check_relocs (bfd *abfd, struct bfd_link_info *info, relocations mapped. */ && !htab->symbian_p) flags |= SEC_ALLOC | SEC_LOAD; + sreloc = bfd_make_section_with_flags (dynobj, + name, + flags); if (sreloc == NULL - || ! bfd_set_section_flags (dynobj, sreloc, flags) || ! bfd_set_section_alignment (dynobj, sreloc, 2)) return FALSE; } diff --git a/bfd/elf32-cris.c b/bfd/elf32-cris.c index 6b21de7..368e4c7 100644 --- a/bfd/elf32-cris.c +++ b/bfd/elf32-cris.c @@ -2542,15 +2542,15 @@ cris_elf_check_relocs (abfd, info, sec, relocs) srelgot = bfd_get_section_by_name (dynobj, ".rela.got"); if (srelgot == NULL) { - srelgot = bfd_make_section (dynobj, ".rela.got"); + srelgot = bfd_make_section_with_flags (dynobj, + ".rela.got", + (SEC_ALLOC + | SEC_LOAD + | SEC_HAS_CONTENTS + | SEC_IN_MEMORY + | SEC_LINKER_CREATED + | SEC_READONLY)); 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; } @@ -2787,15 +2787,14 @@ cris_elf_check_relocs (abfd, info, sec, relocs) sreloc = bfd_get_section_by_name (dynobj, name); if (sreloc == NULL) { - sreloc = bfd_make_section (dynobj, name); + sreloc = bfd_make_section_with_flags (dynobj, name, + (SEC_ALLOC + | SEC_LOAD + | SEC_HAS_CONTENTS + | SEC_IN_MEMORY + | SEC_LINKER_CREATED + | SEC_READONLY)); if (sreloc == NULL - || !bfd_set_section_flags (dynobj, sreloc, - (SEC_ALLOC - | SEC_LOAD - | SEC_HAS_CONTENTS - | SEC_IN_MEMORY - | SEC_LINKER_CREATED - | SEC_READONLY)) || !bfd_set_section_alignment (dynobj, sreloc, 2)) return FALSE; } diff --git a/bfd/elf32-frv.c b/bfd/elf32-frv.c index e1fbd44..49768ad 100644 --- a/bfd/elf32-frv.c +++ b/bfd/elf32-frv.c @@ -4213,11 +4213,11 @@ elf32_frv_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp) if (scomm == NULL) { - scomm = bfd_make_section (abfd, ".scommon"); - if (scomm == NULL - || !bfd_set_section_flags (abfd, scomm, (SEC_ALLOC - | SEC_IS_COMMON - | SEC_LINKER_CREATED))) + scomm = bfd_make_section_with_flags (abfd, ".scommon", + (SEC_ALLOC + | SEC_IS_COMMON + | SEC_LINKER_CREATED)); + if (scomm == NULL) return FALSE; } @@ -4282,17 +4282,15 @@ _frv_create_got_section (bfd *abfd, struct bfd_link_info *info) | SEC_LINKER_CREATED); pltflags = flags; - 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, ptralign)) return FALSE; if (bed->want_got_plt) { - s = bfd_make_section (abfd, ".got.plt"); + s = bfd_make_section_with_flags (abfd, ".got.plt", flags); if (s == NULL - || !bfd_set_section_flags (abfd, s, flags) || !bfd_set_section_alignment (abfd, s, ptralign)) return FALSE; } @@ -4337,18 +4335,18 @@ _frv_create_got_section (bfd *abfd, struct bfd_link_info *info) if (! frvfdpic_relocs_info (info)) return FALSE; - s = bfd_make_section (abfd, ".rel.got"); + s = bfd_make_section_with_flags (abfd, ".rel.got", + (flags | SEC_READONLY)); if (s == NULL - || ! bfd_set_section_flags (abfd, s, (flags | SEC_READONLY)) || ! bfd_set_section_alignment (abfd, s, 2)) return FALSE; frvfdpic_gotrel_section (info) = s; /* Machine-specific. */ - s = bfd_make_section (abfd, ".rofixup"); + s = bfd_make_section_with_flags (abfd, ".rofixup", + (flags | SEC_READONLY)); if (s == NULL - || ! bfd_set_section_flags (abfd, s, (flags | SEC_READONLY)) || ! bfd_set_section_alignment (abfd, s, 2)) return FALSE; @@ -4395,9 +4393,8 @@ _frv_create_got_section (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; /* FRV-specific: remember it. */ @@ -4425,9 +4422,9 @@ _frv_create_got_section (bfd *abfd, struct bfd_link_info *info) } /* FRV-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; /* FRV-specific: remember it. */ @@ -4473,9 +4470,9 @@ elf32_frvfdpic_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 @@ -4491,11 +4488,11 @@ elf32_frvfdpic_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; } diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c index d79cc49..b2f131c 100644 --- a/bfd/elf32-hppa.c +++ b/bfd/elf32-hppa.c @@ -952,15 +952,14 @@ elf32_hppa_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) htab->srelplt = bfd_get_section_by_name (abfd, ".rela.plt"); htab->sgot = bfd_get_section_by_name (abfd, ".got"); - htab->srelgot = bfd_make_section (abfd, ".rela.got"); + htab->srelgot = bfd_make_section_with_flags (abfd, ".rela.got", + (SEC_ALLOC + | SEC_LOAD + | SEC_HAS_CONTENTS + | SEC_IN_MEMORY + | SEC_LINKER_CREATED + | SEC_READONLY)); if (htab->srelgot == NULL - || ! bfd_set_section_flags (abfd, htab->srelgot, - (SEC_ALLOC - | SEC_LOAD - | SEC_HAS_CONTENTS - | SEC_IN_MEMORY - | SEC_LINKER_CREATED - | SEC_READONLY)) || ! bfd_set_section_alignment (abfd, htab->srelgot, 2)) return FALSE; @@ -1388,13 +1387,14 @@ elf32_hppa_check_relocs (bfd *abfd, { flagword flags; - sreloc = bfd_make_section (dynobj, name); flags = (SEC_HAS_CONTENTS | SEC_READONLY | SEC_IN_MEMORY | SEC_LINKER_CREATED); if ((sec->flags & SEC_ALLOC) != 0) flags |= SEC_ALLOC | SEC_LOAD; + sreloc = bfd_make_section_with_flags (dynobj, + name, + flags); if (sreloc == NULL - || !bfd_set_section_flags (dynobj, sreloc, flags) || !bfd_set_section_alignment (dynobj, sreloc, 2)) return FALSE; } diff --git a/bfd/elf32-i370.c b/bfd/elf32-i370.c index 5a72d74..3fba82b 100644 --- a/bfd/elf32-i370.c +++ b/bfd/elf32-i370.c @@ -449,24 +449,24 @@ i370_elf_create_dynamic_sections (abfd, info) flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED); - s = bfd_make_section (abfd, ".dynsbss"); - if (s == NULL - || ! bfd_set_section_flags (abfd, s, SEC_ALLOC)) + s = bfd_make_section_with_flags (abfd, ".dynsbss", + SEC_ALLOC | SEC_LINKER_CREATED); + if (s == NULL) return FALSE; if (! info->shared) { - s = bfd_make_section (abfd, ".rela.sbss"); + s = bfd_make_section_with_flags (abfd, ".rela.sbss", + flags | SEC_READONLY); if (s == NULL - || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY) || ! bfd_set_section_alignment (abfd, s, 2)) return FALSE; } /* xxx beats me, seem to need a rela.text ... */ - s = bfd_make_section (abfd, ".rela.text"); + s = bfd_make_section_with_flags (abfd, ".rela.text", + flags | SEC_READONLY); if (s == NULL - || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY) || ! bfd_set_section_alignment (abfd, s, 2)) return FALSE; return TRUE; @@ -930,13 +930,13 @@ i370_elf_check_relocs (abfd, info, sec, relocs) { flagword flags; - sreloc = bfd_make_section (dynobj, name); flags = (SEC_HAS_CONTENTS | SEC_READONLY | SEC_IN_MEMORY | SEC_LINKER_CREATED); if ((sec->flags & SEC_ALLOC) != 0) flags |= SEC_ALLOC | SEC_LOAD; + sreloc = bfd_make_section_with_flags (dynobj, name, + flags); if (sreloc == NULL - || ! bfd_set_section_flags (dynobj, sreloc, flags) || ! bfd_set_section_alignment (dynobj, sreloc, 2)) return FALSE; } diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index 5cfe6f7..934e6d9 100644 --- a/bfd/elf32-i386.c +++ b/bfd/elf32-i386.c @@ -689,12 +689,13 @@ create_got_section (bfd *dynobj, struct bfd_link_info *info) if (!htab->sgot || !htab->sgotplt) abort (); - htab->srelgot = bfd_make_section (dynobj, ".rel.got"); + htab->srelgot = bfd_make_section_with_flags (dynobj, ".rel.got", + (SEC_ALLOC | SEC_LOAD + | SEC_HAS_CONTENTS + | SEC_IN_MEMORY + | SEC_LINKER_CREATED + | SEC_READONLY)); if (htab->srelgot == NULL - || ! bfd_set_section_flags (dynobj, htab->srelgot, - (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS - | SEC_IN_MEMORY | SEC_LINKER_CREATED - | SEC_READONLY)) || ! bfd_set_section_alignment (dynobj, htab->srelgot, 2)) return FALSE; return TRUE; @@ -1098,13 +1099,14 @@ elf_i386_check_relocs (bfd *abfd, { flagword flags; - sreloc = bfd_make_section (dynobj, name); flags = (SEC_HAS_CONTENTS | SEC_READONLY | SEC_IN_MEMORY | SEC_LINKER_CREATED); if ((sec->flags & SEC_ALLOC) != 0) flags |= SEC_ALLOC | SEC_LOAD; + sreloc = bfd_make_section_with_flags (dynobj, + name, + flags); if (sreloc == NULL - || ! bfd_set_section_flags (dynobj, sreloc, flags) || ! bfd_set_section_alignment (dynobj, sreloc, 2)) return FALSE; } diff --git a/bfd/elf32-m32r.c b/bfd/elf32-m32r.c index 67e63dc..55c36f2 100644 --- a/bfd/elf32-m32r.c +++ b/bfd/elf32-m32r.c @@ -1461,10 +1461,10 @@ m32r_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp) flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED); - s = bfd_make_section_anyway (abfd, ".sdata"); + s = bfd_make_section_anyway_with_flags (abfd, ".sdata", + flags); if (s == NULL) return FALSE; - bfd_set_section_flags (abfd, s, flags); bfd_set_section_alignment (abfd, s, 2); } @@ -1719,15 +1719,14 @@ create_got_section (dynobj, info) if (! htab->sgot || ! htab->sgotplt) abort (); - htab->srelgot = bfd_make_section (dynobj, ".rela.got"); + htab->srelgot = bfd_make_section_with_flags (dynobj, ".rela.got", + (SEC_ALLOC + | SEC_LOAD + | SEC_HAS_CONTENTS + | SEC_IN_MEMORY + | SEC_LINKER_CREATED + | SEC_READONLY)); if (htab->srelgot == NULL - || ! bfd_set_section_flags (dynobj, htab->srelgot, - (SEC_ALLOC - | SEC_LOAD - | SEC_HAS_CONTENTS - | SEC_IN_MEMORY - | SEC_LINKER_CREATED - | SEC_READONLY)) || ! bfd_set_section_alignment (dynobj, htab->srelgot, 2)) return FALSE; @@ -1762,10 +1761,9 @@ m32r_elf_create_dynamic_sections (abfd, info) if (bed->plt_readonly) pltflags |= SEC_READONLY; - s = bfd_make_section (abfd, ".plt"); + s = bfd_make_section_with_flags (abfd, ".plt", pltflags); htab->splt = s; if (s == NULL - || ! bfd_set_section_flags (abfd, s, pltflags) || ! bfd_set_section_alignment (abfd, s, bed->plt_alignment)) return FALSE; @@ -1789,11 +1787,11 @@ m32r_elf_create_dynamic_sections (abfd, info) return FALSE; } - s = bfd_make_section (abfd, - bed->default_use_rela_p ? ".rela.plt" : ".rel.plt"); + s = bfd_make_section_with_flags (abfd, + bed->default_use_rela_p ? ".rela.plt" : ".rel.plt", + flags | SEC_READONLY); htab->srelplt = s; if (s == NULL - || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY) || ! bfd_set_section_alignment (abfd, s, ptralign)) return FALSE; @@ -1819,9 +1817,9 @@ m32r_elf_create_dynamic_sections (abfd, info) strcat (relname, secname); if (bfd_get_section_by_name (abfd, secname)) continue; - s = bfd_make_section (abfd, relname); + s = bfd_make_section_with_flags (abfd, relname, + flags | SEC_READONLY); if (s == NULL - || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY) || ! bfd_set_section_alignment (abfd, s, ptralign)) return FALSE; } @@ -1835,10 +1833,10 @@ m32r_elf_create_dynamic_sections (abfd, 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"); + s = bfd_make_section_with_flags (abfd, ".dynbss", + SEC_ALLOC | SEC_LINKER_CREATED); htab->sdynbss = s; - if (s == NULL - || ! bfd_set_section_flags (abfd, s, SEC_ALLOC)) + if (s == NULL) return FALSE; /* The .rel[a].bss section holds copy relocs. This section is not normally needed. We need to create it here, though, so that the @@ -1853,12 +1851,12 @@ m32r_elf_create_dynamic_sections (abfd, 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); htab->srelbss = s; if (s == NULL - || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY) || ! bfd_set_section_alignment (abfd, s, ptralign)) return FALSE; } @@ -4108,13 +4106,14 @@ m32r_elf_check_relocs (abfd, info, sec, relocs) { flagword flags; - sreloc = bfd_make_section (dynobj, name); flags = (SEC_HAS_CONTENTS | SEC_READONLY | SEC_IN_MEMORY | SEC_LINKER_CREATED); if ((sec->flags & SEC_ALLOC) != 0) flags |= SEC_ALLOC | SEC_LOAD; + sreloc = bfd_make_section_with_flags (dynobj, + name, + flags); if (sreloc == NULL - || ! bfd_set_section_flags (dynobj, sreloc, flags) || ! bfd_set_section_alignment (dynobj, sreloc, 2)) return FALSE; } diff --git a/bfd/elf32-m68k.c b/bfd/elf32-m68k.c index 2f9dad6..2c6e29b 100644 --- a/bfd/elf32-m68k.c +++ b/bfd/elf32-m68k.c @@ -517,15 +517,15 @@ elf_m68k_check_relocs (abfd, info, sec, relocs) srelgot = bfd_get_section_by_name (dynobj, ".rela.got"); if (srelgot == NULL) { - srelgot = bfd_make_section (dynobj, ".rela.got"); + srelgot = bfd_make_section_with_flags (dynobj, + ".rela.got", + (SEC_ALLOC + | SEC_LOAD + | SEC_HAS_CONTENTS + | SEC_IN_MEMORY + | SEC_LINKER_CREATED + | SEC_READONLY)); 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; } @@ -691,15 +691,15 @@ elf_m68k_check_relocs (abfd, info, sec, relocs) sreloc = bfd_get_section_by_name (dynobj, name); if (sreloc == NULL) { - sreloc = bfd_make_section (dynobj, name); + sreloc = bfd_make_section_with_flags (dynobj, + name, + (SEC_ALLOC + | SEC_LOAD + | SEC_HAS_CONTENTS + | SEC_IN_MEMORY + | SEC_LINKER_CREATED + | SEC_READONLY)); if (sreloc == NULL - || !bfd_set_section_flags (dynobj, sreloc, - (SEC_ALLOC - | SEC_LOAD - | SEC_HAS_CONTENTS - | SEC_IN_MEMORY - | SEC_LINKER_CREATED - | SEC_READONLY)) || !bfd_set_section_alignment (dynobj, sreloc, 2)) return FALSE; } diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c index 832bb45..6287921 100644 --- a/bfd/elf32-ppc.c +++ b/bfd/elf32-ppc.c @@ -2220,12 +2220,13 @@ ppc_elf_create_got (bfd *abfd, struct bfd_link_info *info) if (!bfd_set_section_flags (abfd, s, flags)) return FALSE; - htab->relgot = bfd_make_section (abfd, ".rela.got"); + htab->relgot = bfd_make_section_with_flags (abfd, ".rela.got", + SEC_ALLOC | SEC_LOAD + | SEC_HAS_CONTENTS + | SEC_IN_MEMORY + | SEC_LINKER_CREATED + | SEC_READONLY); if (!htab->relgot - || ! bfd_set_section_flags (abfd, htab->relgot, - (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS - | SEC_IN_MEMORY | SEC_LINKER_CREATED - | SEC_READONLY)) || ! bfd_set_section_alignment (abfd, htab->relgot, 2)) return FALSE; @@ -2256,17 +2257,19 @@ ppc_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) | SEC_LINKER_CREATED); htab->dynbss = bfd_get_section_by_name (abfd, ".dynbss"); - htab->dynsbss = s = bfd_make_section (abfd, ".dynsbss"); - if (s == NULL - || ! bfd_set_section_flags (abfd, s, SEC_ALLOC | SEC_LINKER_CREATED)) + htab->dynsbss = s = bfd_make_section_with_flags (abfd, ".dynsbss", + SEC_ALLOC + | SEC_LINKER_CREATED); + if (s == NULL) return FALSE; if (! info->shared) { htab->relbss = bfd_get_section_by_name (abfd, ".rela.bss"); - htab->relsbss = s = bfd_make_section (abfd, ".rela.sbss"); + htab->relsbss = s = bfd_make_section_with_flags (abfd, + ".rela.sbss", + flags | SEC_READONLY); if (s == NULL - || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY) || ! bfd_set_section_alignment (abfd, s, 2)) return FALSE; } @@ -2384,9 +2387,10 @@ ppc_elf_add_symbol_hook (bfd *abfd, if (!htab->elf.dynobj) htab->elf.dynobj = abfd; - htab->sbss = bfd_make_section_anyway (htab->elf.dynobj, ".sbss"); - if (htab->sbss == NULL - || ! bfd_set_section_flags (htab->elf.dynobj, htab->sbss, flags)) + htab->sbss = bfd_make_section_anyway_with_flags (htab->elf.dynobj, + ".sbss", + flags); + if (htab->sbss == NULL) return FALSE; } @@ -2415,9 +2419,10 @@ ppc_elf_create_linker_section (bfd *abfd, if (!htab->elf.dynobj) htab->elf.dynobj = abfd; - s = bfd_make_section_anyway (htab->elf.dynobj, lsect->name); + s = bfd_make_section_anyway_with_flags (htab->elf.dynobj, + lsect->name, + flags); if (s == NULL - || !bfd_set_section_flags (htab->elf.dynobj, s, flags) || !bfd_set_section_alignment (htab->elf.dynobj, s, 2)) return FALSE; lsect->section = s; @@ -2947,13 +2952,13 @@ ppc_elf_check_relocs (bfd *abfd, { flagword flags; - sreloc = bfd_make_section (htab->elf.dynobj, name); flags = (SEC_HAS_CONTENTS | SEC_READONLY | SEC_IN_MEMORY | SEC_LINKER_CREATED | SEC_ALLOC | SEC_LOAD); + sreloc = bfd_make_section_with_flags (htab->elf.dynobj, + name, + flags); if (sreloc == NULL - || ! bfd_set_section_flags (htab->elf.dynobj, - sreloc, flags) || ! bfd_set_section_alignment (htab->elf.dynobj, sreloc, 2)) return FALSE; diff --git a/bfd/elf32-s390.c b/bfd/elf32-s390.c index 2276b31..62ed07a 100644 --- a/bfd/elf32-s390.c +++ b/bfd/elf32-s390.c @@ -803,12 +803,13 @@ create_got_section (dynobj, info) if (!htab->sgot || !htab->sgotplt) abort (); - htab->srelgot = bfd_make_section (dynobj, ".rela.got"); + htab->srelgot = bfd_make_section_with_flags (dynobj, ".rela.got", + (SEC_ALLOC | SEC_LOAD + | SEC_HAS_CONTENTS + | SEC_IN_MEMORY + | SEC_LINKER_CREATED + | SEC_READONLY)); if (htab->srelgot == NULL - || ! bfd_set_section_flags (dynobj, htab->srelgot, - (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS - | SEC_IN_MEMORY | SEC_LINKER_CREATED - | SEC_READONLY)) || ! bfd_set_section_alignment (dynobj, htab->srelgot, 2)) return FALSE; return TRUE; @@ -1281,13 +1282,14 @@ elf_s390_check_relocs (abfd, info, sec, relocs) { flagword flags; - sreloc = bfd_make_section (dynobj, name); flags = (SEC_HAS_CONTENTS | SEC_READONLY | SEC_IN_MEMORY | SEC_LINKER_CREATED); if ((sec->flags & SEC_ALLOC) != 0) flags |= SEC_ALLOC | SEC_LOAD; + sreloc = bfd_make_section_with_flags (dynobj, + name, + flags); if (sreloc == NULL - || ! bfd_set_section_flags (dynobj, sreloc, flags) || ! bfd_set_section_alignment (dynobj, sreloc, 2)) return FALSE; } diff --git a/bfd/elf32-sh.c b/bfd/elf32-sh.c index a811fe3..9b57f35 100644 --- a/bfd/elf32-sh.c +++ b/bfd/elf32-sh.c @@ -3649,15 +3649,13 @@ create_got_section (bfd *dynobj, struct bfd_link_info *info) if (! htab->sgot || ! htab->sgotplt) abort (); - htab->srelgot = bfd_make_section (dynobj, ".rela.got"); + htab->srelgot = bfd_make_section_with_flags (dynobj, ".rela.got", + (SEC_ALLOC | SEC_LOAD + | SEC_HAS_CONTENTS + | SEC_IN_MEMORY + | SEC_LINKER_CREATED + | SEC_READONLY)); if (htab->srelgot == NULL - || ! bfd_set_section_flags (dynobj, htab->srelgot, - (SEC_ALLOC - | SEC_LOAD - | SEC_HAS_CONTENTS - | SEC_IN_MEMORY - | SEC_LINKER_CREATED - | SEC_READONLY)) || ! bfd_set_section_alignment (dynobj, htab->srelgot, 2)) return FALSE; return TRUE; @@ -3706,10 +3704,9 @@ sh_elf_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); htab->splt = s; if (s == NULL - || ! bfd_set_section_flags (abfd, s, pltflags) || ! bfd_set_section_alignment (abfd, s, bed->plt_alignment)) return FALSE; @@ -3735,11 +3732,11 @@ sh_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) return FALSE; } - s = bfd_make_section (abfd, - bed->default_use_rela_p ? ".rela.plt" : ".rel.plt"); + s = bfd_make_section_with_flags (abfd, + bed->default_use_rela_p ? ".rela.plt" : ".rel.plt", + flags | SEC_READONLY); htab->srelplt = s; if (s == NULL - || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY) || ! bfd_set_section_alignment (abfd, s, ptralign)) return FALSE; @@ -3765,9 +3762,9 @@ sh_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) strcat (relname, secname); if (bfd_get_section_by_name (abfd, secname)) continue; - s = bfd_make_section (abfd, relname); + s = bfd_make_section_with_flags (abfd, relname, + flags | SEC_READONLY); if (s == NULL - || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY) || ! bfd_set_section_alignment (abfd, s, ptralign)) return FALSE; } @@ -3781,10 +3778,10 @@ sh_elf_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"); + s = bfd_make_section_with_flags (abfd, ".dynbss", + SEC_ALLOC | SEC_LINKER_CREATED); htab->sdynbss = s; - if (s == NULL - || ! bfd_set_section_flags (abfd, s, SEC_ALLOC)) + if (s == NULL) return FALSE; /* The .rel[a].bss section holds copy relocs. This section is not @@ -3800,12 +3797,12 @@ sh_elf_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); htab->srelbss = s; if (s == NULL - || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY) || ! bfd_set_section_alignment (abfd, s, ptralign)) return FALSE; } @@ -6531,14 +6528,14 @@ sh_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, asection *sec, { flagword flags; - sreloc = bfd_make_section (htab->root.dynobj, name); flags = (SEC_HAS_CONTENTS | SEC_READONLY | SEC_IN_MEMORY | SEC_LINKER_CREATED); if ((sec->flags & SEC_ALLOC) != 0) flags |= SEC_ALLOC | SEC_LOAD; + sreloc = bfd_make_section_with_flags (htab->root.dynobj, + name, + flags); if (sreloc == NULL - || ! bfd_set_section_flags (htab->root.dynobj, - sreloc, flags) || ! bfd_set_section_alignment (htab->root.dynobj, sreloc, 2)) return FALSE; diff --git a/bfd/elf32-vax.c b/bfd/elf32-vax.c index 5a554fd..0693eaf 100644 --- a/bfd/elf32-vax.c +++ b/bfd/elf32-vax.c @@ -631,15 +631,15 @@ elf_vax_check_relocs (abfd, info, sec, relocs) srelgot = bfd_get_section_by_name (dynobj, ".rela.got"); if (srelgot == NULL) { - srelgot = bfd_make_section (dynobj, ".rela.got"); + srelgot = bfd_make_section_with_flags (dynobj, + ".rela.got", + (SEC_ALLOC + | SEC_LOAD + | SEC_HAS_CONTENTS + | SEC_IN_MEMORY + | SEC_LINKER_CREATED + | SEC_READONLY)); 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; } @@ -760,15 +760,15 @@ elf_vax_check_relocs (abfd, info, sec, relocs) sreloc = bfd_get_section_by_name (dynobj, name); if (sreloc == NULL) { - sreloc = bfd_make_section (dynobj, name); + sreloc = bfd_make_section_with_flags (dynobj, + name, + (SEC_ALLOC + | SEC_LOAD + | SEC_HAS_CONTENTS + | SEC_IN_MEMORY + | SEC_LINKER_CREATED + | SEC_READONLY)); if (sreloc == NULL - || !bfd_set_section_flags (dynobj, sreloc, - (SEC_ALLOC - | SEC_LOAD - | SEC_HAS_CONTENTS - | SEC_IN_MEMORY - | SEC_LINKER_CREATED - | SEC_READONLY)) || !bfd_set_section_alignment (dynobj, sreloc, 2)) return FALSE; } diff --git a/bfd/elf32-xstormy16.c b/bfd/elf32-xstormy16.c index 3a9f047..d8c4e11 100644 --- a/bfd/elf32-xstormy16.c +++ b/bfd/elf32-xstormy16.c @@ -470,16 +470,16 @@ xstormy16_elf_check_relocs (abfd, info, sec, relocs) splt = bfd_get_section_by_name (dynobj, ".plt"); if (splt == NULL) { - splt = bfd_make_section (dynobj, ".plt"); + splt = bfd_make_section_with_flags (dynobj, ".plt", + (SEC_ALLOC + | SEC_LOAD + | SEC_HAS_CONTENTS + | SEC_IN_MEMORY + | SEC_LINKER_CREATED + | SEC_READONLY + | SEC_CODE)); + 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; } diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c index 7b4a3f0..b6b2959 100644 --- a/bfd/elf32-xtensa.c +++ b/bfd/elf32-xtensa.c @@ -1105,23 +1105,21 @@ elf_xtensa_create_dynamic_sections (bfd *dynobj, struct bfd_link_info *info) return FALSE; /* Create ".rela.got". */ - s = bfd_make_section (dynobj, ".rela.got"); + s = bfd_make_section_with_flags (dynobj, ".rela.got", flags); if (s == NULL - || ! bfd_set_section_flags (dynobj, s, flags) || ! bfd_set_section_alignment (dynobj, s, 2)) return FALSE; /* Create ".got.loc" (literal tables for use by dynamic linker). */ - s = bfd_make_section (dynobj, ".got.loc"); + s = bfd_make_section_with_flags (dynobj, ".got.loc", flags); if (s == NULL - || ! bfd_set_section_flags (dynobj, s, flags) || ! bfd_set_section_alignment (dynobj, s, 2)) return FALSE; /* Create ".xt.lit.plt" (literal table for ".got.plt*"). */ - s = bfd_make_section (dynobj, ".xt.lit.plt"); + s = bfd_make_section_with_flags (dynobj, ".xt.lit.plt", + noalloc_flags); if (s == NULL - || ! bfd_set_section_flags (dynobj, s, noalloc_flags) || ! bfd_set_section_alignment (dynobj, s, 2)) return FALSE; @@ -1151,17 +1149,16 @@ add_extra_plt_sections (bfd *dynobj, int count) sname = (char *) bfd_malloc (10); sprintf (sname, ".plt.%u", chunk); - s = bfd_make_section (dynobj, sname); + s = bfd_make_section_with_flags (dynobj, sname, + flags | SEC_CODE); if (s == NULL - || ! bfd_set_section_flags (dynobj, s, flags | SEC_CODE) || ! bfd_set_section_alignment (dynobj, s, 2)) return FALSE; sname = (char *) bfd_malloc (14); sprintf (sname, ".got.plt.%u", chunk); - s = bfd_make_section (dynobj, sname); + s = bfd_make_section_with_flags (dynobj, sname, flags); if (s == NULL - || ! bfd_set_section_flags (dynobj, s, flags) || ! bfd_set_section_alignment (dynobj, s, 2)) return FALSE; } diff --git a/bfd/elf64-alpha.c b/bfd/elf64-alpha.c index 9a01ae1..6b24734 100644 --- a/bfd/elf64-alpha.c +++ b/bfd/elf64-alpha.c @@ -2371,11 +2371,11 @@ elf64_alpha_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp) if (scomm == NULL) { - scomm = bfd_make_section (abfd, ".scommon"); - if (scomm == NULL - || !bfd_set_section_flags (abfd, scomm, (SEC_ALLOC - | SEC_IS_COMMON - | SEC_LINKER_CREATED))) + scomm = bfd_make_section_with_flags (abfd, ".scommon", + (SEC_ALLOC + | SEC_IS_COMMON + | SEC_LINKER_CREATED)); + if (scomm == NULL) return FALSE; } @@ -2403,12 +2403,11 @@ elf64_alpha_create_got_section(abfd, info) return TRUE; } - s = bfd_make_section (abfd, ".got"); + s = bfd_make_section_with_flags (abfd, ".got", (SEC_ALLOC | SEC_LOAD + | SEC_HAS_CONTENTS + | SEC_IN_MEMORY + | SEC_LINKER_CREATED)); if (s == NULL - || !bfd_set_section_flags (abfd, s, (SEC_ALLOC | SEC_LOAD - | SEC_HAS_CONTENTS - | SEC_IN_MEMORY - | SEC_LINKER_CREATED)) || !bfd_set_section_alignment (abfd, s, 3)) return FALSE; @@ -2430,13 +2429,13 @@ elf64_alpha_create_dynamic_sections (abfd, info) /* We need to create .plt, .rela.plt, .got, and .rela.got sections. */ - s = bfd_make_section (abfd, ".plt"); + s = bfd_make_section_with_flags (abfd, ".plt", + (SEC_ALLOC | SEC_LOAD + | SEC_HAS_CONTENTS + | SEC_IN_MEMORY + | SEC_LINKER_CREATED + | SEC_CODE)); if (s == NULL - || ! bfd_set_section_flags (abfd, s, (SEC_ALLOC | SEC_LOAD - | SEC_HAS_CONTENTS - | SEC_IN_MEMORY - | SEC_LINKER_CREATED - | SEC_CODE)) || ! bfd_set_section_alignment (abfd, s, 3)) return FALSE; @@ -2456,13 +2455,13 @@ elf64_alpha_create_dynamic_sections (abfd, info) && ! bfd_elf_link_record_dynamic_symbol (info, h)) return FALSE; - s = bfd_make_section (abfd, ".rela.plt"); + s = bfd_make_section_with_flags (abfd, ".rela.plt", + (SEC_ALLOC | SEC_LOAD + | SEC_HAS_CONTENTS + | SEC_IN_MEMORY + | SEC_LINKER_CREATED + | SEC_READONLY)); if (s == NULL - || !bfd_set_section_flags (abfd, s, (SEC_ALLOC | SEC_LOAD - | SEC_HAS_CONTENTS - | SEC_IN_MEMORY - | SEC_LINKER_CREATED - | SEC_READONLY)) || ! bfd_set_section_alignment (abfd, s, 3)) return FALSE; @@ -2472,13 +2471,13 @@ elf64_alpha_create_dynamic_sections (abfd, info) if (!elf64_alpha_create_got_section (abfd, info)) return FALSE; - s = bfd_make_section(abfd, ".rela.got"); + s = bfd_make_section_with_flags (abfd, ".rela.got", + (SEC_ALLOC | SEC_LOAD + | SEC_HAS_CONTENTS + | SEC_IN_MEMORY + | SEC_LINKER_CREATED + | SEC_READONLY)); if (s == NULL - || !bfd_set_section_flags (abfd, s, (SEC_ALLOC | SEC_LOAD - | SEC_HAS_CONTENTS - | SEC_IN_MEMORY - | SEC_LINKER_CREATED - | SEC_READONLY)) || !bfd_set_section_alignment (abfd, s, 3)) return FALSE; @@ -3147,13 +3146,14 @@ elf64_alpha_check_relocs (abfd, info, sec, relocs) { flagword flags; - sreloc = bfd_make_section (dynobj, rel_sec_name); flags = (SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED | SEC_READONLY); if (sec->flags & SEC_ALLOC) flags |= SEC_ALLOC | SEC_LOAD; + sreloc = bfd_make_section_with_flags (dynobj, + rel_sec_name, + flags); if (sreloc == NULL - || !bfd_set_section_flags (dynobj, sreloc, flags) || !bfd_set_section_alignment (dynobj, sreloc, 3)) return FALSE; } diff --git a/bfd/elf64-hppa.c b/bfd/elf64-hppa.c index d78442b..1ca533b 100644 --- a/bfd/elf64-hppa.c +++ b/bfd/elf64-hppa.c @@ -532,15 +532,14 @@ get_reloc_section (abfd, hppa_info, sec) srel = bfd_get_section_by_name (dynobj, srel_name); if (srel == NULL) { - srel = bfd_make_section (dynobj, srel_name); + srel = bfd_make_section_with_flags (dynobj, srel_name, + (SEC_ALLOC + | SEC_LOAD + | SEC_HAS_CONTENTS + | SEC_IN_MEMORY + | SEC_LINKER_CREATED + | SEC_READONLY)); if (srel == NULL - || !bfd_set_section_flags (dynobj, srel, - (SEC_ALLOC - | SEC_LOAD - | SEC_HAS_CONTENTS - | SEC_IN_MEMORY - | SEC_LINKER_CREATED - | SEC_READONLY)) || !bfd_set_section_alignment (dynobj, srel, 3)) return FALSE; } @@ -1232,14 +1231,13 @@ get_opd (abfd, info, hppa_info) if (!dynobj) hppa_info->root.dynobj = dynobj = abfd; - opd = bfd_make_section (dynobj, ".opd"); + opd = bfd_make_section_with_flags (dynobj, ".opd", + (SEC_ALLOC + | SEC_LOAD + | SEC_HAS_CONTENTS + | SEC_IN_MEMORY + | SEC_LINKER_CREATED)); if (!opd - || !bfd_set_section_flags (dynobj, opd, - (SEC_ALLOC - | SEC_LOAD - | SEC_HAS_CONTENTS - | SEC_IN_MEMORY - | SEC_LINKER_CREATED)) || !bfd_set_section_alignment (abfd, opd, 3)) { BFD_ASSERT (0); @@ -1270,14 +1268,13 @@ get_plt (abfd, info, hppa_info) if (!dynobj) hppa_info->root.dynobj = dynobj = abfd; - plt = bfd_make_section (dynobj, ".plt"); + plt = bfd_make_section_with_flags (dynobj, ".plt", + (SEC_ALLOC + | SEC_LOAD + | SEC_HAS_CONTENTS + | SEC_IN_MEMORY + | SEC_LINKER_CREATED)); if (!plt - || !bfd_set_section_flags (dynobj, plt, - (SEC_ALLOC - | SEC_LOAD - | SEC_HAS_CONTENTS - | SEC_IN_MEMORY - | SEC_LINKER_CREATED)) || !bfd_set_section_alignment (abfd, plt, 3)) { BFD_ASSERT (0); @@ -1308,14 +1305,13 @@ get_dlt (abfd, info, hppa_info) if (!dynobj) hppa_info->root.dynobj = dynobj = abfd; - dlt = bfd_make_section (dynobj, ".dlt"); + dlt = bfd_make_section_with_flags (dynobj, ".dlt", + (SEC_ALLOC + | SEC_LOAD + | SEC_HAS_CONTENTS + | SEC_IN_MEMORY + | SEC_LINKER_CREATED)); if (!dlt - || !bfd_set_section_flags (dynobj, dlt, - (SEC_ALLOC - | SEC_LOAD - | SEC_HAS_CONTENTS - | SEC_IN_MEMORY - | SEC_LINKER_CREATED)) || !bfd_set_section_alignment (abfd, dlt, 3)) { BFD_ASSERT (0); @@ -1346,15 +1342,13 @@ get_stub (abfd, info, hppa_info) if (!dynobj) hppa_info->root.dynobj = dynobj = abfd; - stub = bfd_make_section (dynobj, ".stub"); + stub = bfd_make_section_with_flags (dynobj, ".stub", + (SEC_ALLOC | SEC_LOAD + | SEC_HAS_CONTENTS + | SEC_IN_MEMORY + | SEC_READONLY + | SEC_LINKER_CREATED)); if (!stub - || !bfd_set_section_flags (dynobj, stub, - (SEC_ALLOC - | SEC_LOAD - | SEC_HAS_CONTENTS - | SEC_IN_MEMORY - | SEC_READONLY - | SEC_LINKER_CREATED)) || !bfd_set_section_alignment (abfd, stub, 3)) { BFD_ASSERT (0); @@ -1424,46 +1418,46 @@ elf64_hppa_create_dynamic_sections (abfd, info) if (! get_opd (abfd, info, elf64_hppa_hash_table (info))) return FALSE; - s = bfd_make_section(abfd, ".rela.dlt"); + s = bfd_make_section_with_flags (abfd, ".rela.dlt", + (SEC_ALLOC | SEC_LOAD + | SEC_HAS_CONTENTS + | SEC_IN_MEMORY + | SEC_READONLY + | SEC_LINKER_CREATED)); if (s == NULL - || !bfd_set_section_flags (abfd, s, (SEC_ALLOC | SEC_LOAD - | SEC_HAS_CONTENTS - | SEC_IN_MEMORY - | SEC_READONLY - | SEC_LINKER_CREATED)) || !bfd_set_section_alignment (abfd, s, 3)) return FALSE; elf64_hppa_hash_table (info)->dlt_rel_sec = s; - s = bfd_make_section(abfd, ".rela.plt"); + s = bfd_make_section_with_flags (abfd, ".rela.plt", + (SEC_ALLOC | SEC_LOAD + | SEC_HAS_CONTENTS + | SEC_IN_MEMORY + | SEC_READONLY + | SEC_LINKER_CREATED)); if (s == NULL - || !bfd_set_section_flags (abfd, s, (SEC_ALLOC | SEC_LOAD - | SEC_HAS_CONTENTS - | SEC_IN_MEMORY - | SEC_READONLY - | SEC_LINKER_CREATED)) || !bfd_set_section_alignment (abfd, s, 3)) return FALSE; elf64_hppa_hash_table (info)->plt_rel_sec = s; - s = bfd_make_section(abfd, ".rela.data"); + s = bfd_make_section_with_flags (abfd, ".rela.data", + (SEC_ALLOC | SEC_LOAD + | SEC_HAS_CONTENTS + | SEC_IN_MEMORY + | SEC_READONLY + | SEC_LINKER_CREATED)); if (s == NULL - || !bfd_set_section_flags (abfd, s, (SEC_ALLOC | SEC_LOAD - | SEC_HAS_CONTENTS - | SEC_IN_MEMORY - | SEC_READONLY - | SEC_LINKER_CREATED)) || !bfd_set_section_alignment (abfd, s, 3)) return FALSE; elf64_hppa_hash_table (info)->other_rel_sec = s; - s = bfd_make_section(abfd, ".rela.opd"); + s = bfd_make_section_with_flags (abfd, ".rela.opd", + (SEC_ALLOC | SEC_LOAD + | SEC_HAS_CONTENTS + | SEC_IN_MEMORY + | SEC_READONLY + | SEC_LINKER_CREATED)); if (s == NULL - || !bfd_set_section_flags (abfd, s, (SEC_ALLOC | SEC_LOAD - | SEC_HAS_CONTENTS - | SEC_IN_MEMORY - | SEC_READONLY - | SEC_LINKER_CREATED)) || !bfd_set_section_alignment (abfd, s, 3)) return FALSE; elf64_hppa_hash_table (info)->opd_rel_sec = s; diff --git a/bfd/elf64-mmix.c b/bfd/elf64-mmix.c index c37130c..3c5336b 100644 --- a/bfd/elf64-mmix.c +++ b/bfd/elf64-mmix.c @@ -1890,19 +1890,17 @@ mmix_elf_check_common_relocs (abfd, info, sec, relocs) if (allocated_gregs_section == NULL) { allocated_gregs_section - = bfd_make_section (bpo_greg_owner, - MMIX_LD_ALLOCATED_REG_CONTENTS_SECTION_NAME); + = bfd_make_section_with_flags (bpo_greg_owner, + MMIX_LD_ALLOCATED_REG_CONTENTS_SECTION_NAME, + (SEC_HAS_CONTENTS + | SEC_IN_MEMORY + | SEC_LINKER_CREATED)); /* Setting both SEC_ALLOC and SEC_LOAD means the section is treated like any other section, and we'd get errors for address overlap with the text section. Let's set none of those flags, as that is what currently happens for usual GREG allocations, and that works. */ if (allocated_gregs_section == NULL - || !bfd_set_section_flags (bpo_greg_owner, - allocated_gregs_section, - (SEC_HAS_CONTENTS - | SEC_IN_MEMORY - | SEC_LINKER_CREATED)) || !bfd_set_section_alignment (bpo_greg_owner, allocated_gregs_section, 3)) diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c index 4bb0d3b..0eaa754 100644 --- a/bfd/elf64-ppc.c +++ b/bfd/elf64-ppc.c @@ -3667,25 +3667,25 @@ create_linkage_sections (bfd *dynobj, struct bfd_link_info *info) /* Create .sfpr for code to save and restore fp regs. */ flags = (SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_READONLY | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED); - htab->sfpr = bfd_make_section_anyway (dynobj, ".sfpr"); + htab->sfpr = bfd_make_section_anyway_with_flags (dynobj, ".sfpr", + flags); if (htab->sfpr == NULL - || ! bfd_set_section_flags (dynobj, htab->sfpr, flags) || ! bfd_set_section_alignment (dynobj, htab->sfpr, 2)) return FALSE; /* Create .glink for lazy dynamic linking support. */ - htab->glink = bfd_make_section_anyway (dynobj, ".glink"); + htab->glink = bfd_make_section_anyway_with_flags (dynobj, ".glink", + flags); if (htab->glink == NULL - || ! bfd_set_section_flags (dynobj, htab->glink, flags) || ! bfd_set_section_alignment (dynobj, htab->glink, 2)) return FALSE; /* Create .branch_lt for plt_branch stubs. */ flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED); - htab->brlt = bfd_make_section_anyway (dynobj, ".branch_lt"); + htab->brlt = bfd_make_section_anyway_with_flags (dynobj, ".branch_lt", + flags); if (htab->brlt == NULL - || ! bfd_set_section_flags (dynobj, htab->brlt, flags) || ! bfd_set_section_alignment (dynobj, htab->brlt, 3)) return FALSE; @@ -3693,9 +3693,10 @@ create_linkage_sections (bfd *dynobj, struct bfd_link_info *info) { flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED); - htab->relbrlt = bfd_make_section_anyway (dynobj, ".rela.branch_lt"); + htab->relbrlt = bfd_make_section_anyway_with_flags (dynobj, + ".rela.branch_lt", + flags); if (!htab->relbrlt - || ! bfd_set_section_flags (dynobj, htab->relbrlt, flags) || ! bfd_set_section_alignment (dynobj, htab->relbrlt, 3)) return FALSE; } @@ -3725,15 +3726,14 @@ create_got_section (bfd *abfd, struct bfd_link_info *info) flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED); - got = bfd_make_section (abfd, ".got"); + got = bfd_make_section_with_flags (abfd, ".got", flags); if (!got - || !bfd_set_section_flags (abfd, got, flags) || !bfd_set_section_alignment (abfd, got, 3)) return FALSE; - relgot = bfd_make_section (abfd, ".rela.got"); + relgot = bfd_make_section_with_flags (abfd, ".rela.got", + flags | SEC_READONLY); if (!relgot - || ! bfd_set_section_flags (abfd, relgot, flags | SEC_READONLY) || ! bfd_set_section_alignment (abfd, relgot, 3)) return FALSE; @@ -4686,12 +4686,13 @@ ppc64_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, { flagword flags; - sreloc = bfd_make_section (dynobj, name); flags = (SEC_HAS_CONTENTS | SEC_READONLY | SEC_IN_MEMORY | SEC_LINKER_CREATED | SEC_ALLOC | SEC_LOAD); + sreloc = bfd_make_section_with_flags (dynobj, + name, + flags); if (sreloc == NULL - || ! bfd_set_section_flags (dynobj, sreloc, flags) || ! bfd_set_section_alignment (dynobj, sreloc, 3)) return FALSE; } diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c index cc9a1a9..9142d2a 100644 --- a/bfd/elf64-s390.c +++ b/bfd/elf64-s390.c @@ -756,12 +756,13 @@ create_got_section (dynobj, info) if (!htab->sgot || !htab->sgotplt) abort (); - htab->srelgot = bfd_make_section (dynobj, ".rela.got"); + htab->srelgot = bfd_make_section_with_flags (dynobj, ".rela.got", + (SEC_ALLOC | SEC_LOAD + | SEC_HAS_CONTENTS + | SEC_IN_MEMORY + | SEC_LINKER_CREATED + | SEC_READONLY)); if (htab->srelgot == NULL - || ! bfd_set_section_flags (dynobj, htab->srelgot, - (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS - | SEC_IN_MEMORY | SEC_LINKER_CREATED - | SEC_READONLY)) || ! bfd_set_section_alignment (dynobj, htab->srelgot, 3)) return FALSE; return TRUE; @@ -1246,13 +1247,14 @@ elf_s390_check_relocs (abfd, info, sec, relocs) { flagword flags; - sreloc = bfd_make_section (dynobj, name); flags = (SEC_HAS_CONTENTS | SEC_READONLY | SEC_IN_MEMORY | SEC_LINKER_CREATED); if ((sec->flags & SEC_ALLOC) != 0) flags |= SEC_ALLOC | SEC_LOAD; + sreloc = bfd_make_section_with_flags (dynobj, + name, + flags); if (sreloc == NULL - || ! bfd_set_section_flags (dynobj, sreloc, flags) || ! bfd_set_section_alignment (dynobj, sreloc, 3)) return FALSE; } diff --git a/bfd/elf64-sh64.c b/bfd/elf64-sh64.c index 7de00c9..2b1278b 100644 --- a/bfd/elf64-sh64.c +++ b/bfd/elf64-sh64.c @@ -2530,15 +2530,15 @@ sh_elf64_check_relocs (bfd *abfd, struct bfd_link_info *info, srelgot = bfd_get_section_by_name (dynobj, ".rela.got"); if (srelgot == NULL) { - srelgot = bfd_make_section (dynobj, ".rela.got"); + srelgot = bfd_make_section_with_flags (dynobj, + ".rela.got", + (SEC_ALLOC + | SEC_LOAD + | SEC_HAS_CONTENTS + | SEC_IN_MEMORY + | SEC_LINKER_CREATED + | SEC_READONLY)); 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; } @@ -2732,13 +2732,14 @@ sh_elf64_check_relocs (bfd *abfd, struct bfd_link_info *info, { flagword flags; - sreloc = bfd_make_section (dynobj, name); flags = (SEC_HAS_CONTENTS | SEC_READONLY | SEC_IN_MEMORY | SEC_LINKER_CREATED); if ((sec->flags & SEC_ALLOC) != 0) flags |= SEC_ALLOC | SEC_LOAD; + sreloc = bfd_make_section_with_flags (dynobj, + name, + flags); if (sreloc == NULL - || ! bfd_set_section_flags (dynobj, sreloc, flags) || ! bfd_set_section_alignment (dynobj, sreloc, 2)) return FALSE; } @@ -3211,9 +3212,8 @@ sh64_elf64_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; @@ -3238,10 +3238,10 @@ sh64_elf64_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) return FALSE; } - s = bfd_make_section (abfd, - bed->default_use_rela_p ? ".rela.plt" : ".rel.plt"); + s = bfd_make_section_with_flags (abfd, + bed->default_use_rela_p ? ".rela.plt" : ".rel.plt", + flags | SEC_READONLY); if (s == NULL - || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY) || ! bfd_set_section_alignment (abfd, s, ptralign)) return FALSE; @@ -3264,9 +3264,9 @@ sh64_elf64_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) relname = (char *) bfd_malloc (strlen (secname) + 6); strcpy (relname, ".rela"); strcat (relname, secname); - s = bfd_make_section (abfd, relname); + s = bfd_make_section_with_flags (abfd, relname, + flags | SEC_READONLY); if (s == NULL - || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY) || ! bfd_set_section_alignment (abfd, s, ptralign)) return FALSE; } @@ -3280,9 +3280,9 @@ sh64_elf64_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)) + 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 @@ -3298,11 +3298,11 @@ sh64_elf64_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, ptralign)) return FALSE; } diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c index 58148bb..a1c2ea8 100644 --- a/bfd/elf64-x86-64.c +++ b/bfd/elf64-x86-64.c @@ -459,12 +459,13 @@ create_got_section (bfd *dynobj, struct bfd_link_info *info) if (!htab->sgot || !htab->sgotplt) abort (); - htab->srelgot = bfd_make_section (dynobj, ".rela.got"); + htab->srelgot = bfd_make_section_with_flags (dynobj, ".rela.got", + (SEC_ALLOC | SEC_LOAD + | SEC_HAS_CONTENTS + | SEC_IN_MEMORY + | SEC_LINKER_CREATED + | SEC_READONLY)); if (htab->srelgot == NULL - || ! bfd_set_section_flags (dynobj, htab->srelgot, - (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS - | SEC_IN_MEMORY | SEC_LINKER_CREATED - | SEC_READONLY)) || ! bfd_set_section_alignment (dynobj, htab->srelgot, 3)) return FALSE; return TRUE; @@ -893,13 +894,14 @@ elf64_x86_64_check_relocs (bfd *abfd, struct bfd_link_info *info, asection *sec, { flagword flags; - sreloc = bfd_make_section (dynobj, name); flags = (SEC_HAS_CONTENTS | SEC_READONLY | SEC_IN_MEMORY | SEC_LINKER_CREATED); if ((sec->flags & SEC_ALLOC) != 0) flags |= SEC_ALLOC | SEC_LOAD; + sreloc = bfd_make_section_with_flags (dynobj, + name, + flags); if (sreloc == NULL - || ! bfd_set_section_flags (dynobj, sreloc, flags) || ! bfd_set_section_alignment (dynobj, sreloc, 3)) return FALSE; } diff --git a/bfd/elflink.c b/bfd/elflink.c index 5a65d23..4f91c53 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -59,17 +59,15 @@ _bfd_elf_create_got_section (bfd *abfd, struct bfd_link_info *info) flags = bed->dynamic_sec_flags; - 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, ptralign)) return FALSE; if (bed->want_got_plt) { - s = bfd_make_section (abfd, ".got.plt"); + s = bfd_make_section_with_flags (abfd, ".got.plt", flags); if (s == NULL - || !bfd_set_section_flags (abfd, s, flags) || !bfd_set_section_alignment (abfd, s, ptralign)) return FALSE; } @@ -156,17 +154,17 @@ _bfd_elf_link_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) shared library does not. */ if (info->executable) { - s = bfd_make_section (abfd, ".interp"); - if (s == NULL - || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)) + s = bfd_make_section_with_flags (abfd, ".interp", + flags | SEC_READONLY); + if (s == NULL) return FALSE; } if (! info->traditional_format) { - s = bfd_make_section (abfd, ".eh_frame_hdr"); + s = bfd_make_section_with_flags (abfd, ".eh_frame_hdr", + flags | SEC_READONLY); if (s == NULL - || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY) || ! bfd_set_section_alignment (abfd, s, 2)) return FALSE; elf_hash_table (info)->eh_info.hdr_sec = s; @@ -174,38 +172,37 @@ _bfd_elf_link_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) /* Create sections to hold version informations. These are removed if they are not needed. */ - s = bfd_make_section (abfd, ".gnu.version_d"); + s = bfd_make_section_with_flags (abfd, ".gnu.version_d", + 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; - s = bfd_make_section (abfd, ".gnu.version"); + s = bfd_make_section_with_flags (abfd, ".gnu.version", + flags | SEC_READONLY); if (s == NULL - || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY) || ! bfd_set_section_alignment (abfd, s, 1)) return FALSE; - s = bfd_make_section (abfd, ".gnu.version_r"); + s = bfd_make_section_with_flags (abfd, ".gnu.version_r", + 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; - 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, bed->s->log_file_align)) return FALSE; - s = bfd_make_section (abfd, ".dynstr"); - if (s == NULL - || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)) + s = bfd_make_section_with_flags (abfd, ".dynstr", + flags | SEC_READONLY); + if (s == NULL) return FALSE; - 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, bed->s->log_file_align)) return FALSE; @@ -238,9 +235,9 @@ _bfd_elf_link_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) && ! bfd_elf_link_record_dynamic_symbol (info, h)) return FALSE; - 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, bed->s->log_file_align)) return FALSE; elf_section_data (s)->this_hdr.sh_entsize = bed->s->sizeof_hash_entry; @@ -280,9 +277,8 @@ _bfd_elf_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; @@ -306,10 +302,11 @@ _bfd_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) return FALSE; } - s = bfd_make_section (abfd, - bed->default_use_rela_p ? ".rela.plt" : ".rel.plt"); + s = bfd_make_section_with_flags (abfd, + (bed->default_use_rela_p + ? ".rela.plt" : ".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; @@ -324,9 +321,10 @@ _bfd_elf_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 @@ -342,11 +340,11 @@ _bfd_elf_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; } @@ -3626,12 +3624,12 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info) if (tcomm == NULL) { - tcomm = bfd_make_section (abfd, ".tcommon"); - if (tcomm == NULL - || !bfd_set_section_flags (abfd, tcomm, (SEC_ALLOC - | SEC_IS_COMMON - | SEC_LINKER_CREATED - | SEC_THREAD_LOCAL))) + tcomm = bfd_make_section_with_flags (abfd, ".tcommon", + (SEC_ALLOC + | SEC_IS_COMMON + | SEC_LINKER_CREATED + | SEC_THREAD_LOCAL)); + if (tcomm == NULL) goto error_free_vers; } sec = tcomm; diff --git a/bfd/elfxx-ia64.c b/bfd/elfxx-ia64.c index dc464a8..ca6e54d 100644 --- a/bfd/elfxx-ia64.c +++ b/bfd/elfxx-ia64.c @@ -1436,11 +1436,11 @@ elfNN_ia64_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp) if (scomm == NULL) { - scomm = bfd_make_section (abfd, ".scommon"); - if (scomm == NULL - || !bfd_set_section_flags (abfd, scomm, (SEC_ALLOC - | SEC_IS_COMMON - | SEC_LINKER_CREATED))) + scomm = bfd_make_section_with_flags (abfd, ".scommon", + (SEC_ALLOC + | SEC_IS_COMMON + | SEC_LINKER_CREATED)); + if (scomm == NULL) return FALSE; } @@ -1874,24 +1874,24 @@ elfNN_ia64_create_dynamic_sections (abfd, info) if (!get_pltoff (abfd, info, ia64_info)) return FALSE; - s = bfd_make_section(abfd, ".rela.IA_64.pltoff"); + s = bfd_make_section_with_flags (abfd, ".rela.IA_64.pltoff", + (SEC_ALLOC | SEC_LOAD + | SEC_HAS_CONTENTS + | SEC_IN_MEMORY + | SEC_LINKER_CREATED + | SEC_READONLY)); if (s == NULL - || !bfd_set_section_flags (abfd, s, (SEC_ALLOC | SEC_LOAD - | SEC_HAS_CONTENTS - | SEC_IN_MEMORY - | SEC_LINKER_CREATED - | SEC_READONLY)) || !bfd_set_section_alignment (abfd, s, LOG_SECTION_ALIGN)) return FALSE; ia64_info->rel_pltoff_sec = s; - s = bfd_make_section(abfd, ".rela.got"); + s = bfd_make_section_with_flags (abfd, ".rela.got", + (SEC_ALLOC | SEC_LOAD + | SEC_HAS_CONTENTS + | SEC_IN_MEMORY + | SEC_LINKER_CREATED + | SEC_READONLY)); if (s == NULL - || !bfd_set_section_flags (abfd, s, (SEC_ALLOC | SEC_LOAD - | SEC_HAS_CONTENTS - | SEC_IN_MEMORY - | SEC_LINKER_CREATED - | SEC_READONLY)) || !bfd_set_section_alignment (abfd, s, LOG_SECTION_ALIGN)) return FALSE; ia64_info->rel_got_sec = s; @@ -2038,15 +2038,14 @@ get_fptr (abfd, info, ia64_info) if (!dynobj) ia64_info->root.dynobj = dynobj = abfd; - fptr = bfd_make_section (dynobj, ".opd"); + fptr = bfd_make_section_with_flags (dynobj, ".opd", + (SEC_ALLOC + | SEC_LOAD + | SEC_HAS_CONTENTS + | SEC_IN_MEMORY + | (info->pie ? 0 : SEC_READONLY) + | SEC_LINKER_CREATED)); if (!fptr - || !bfd_set_section_flags (dynobj, fptr, - (SEC_ALLOC - | SEC_LOAD - | SEC_HAS_CONTENTS - | SEC_IN_MEMORY - | (info->pie ? 0 : SEC_READONLY) - | SEC_LINKER_CREATED)) || !bfd_set_section_alignment (abfd, fptr, 4)) { BFD_ASSERT (0); @@ -2058,14 +2057,13 @@ get_fptr (abfd, info, ia64_info) if (info->pie) { asection *fptr_rel; - fptr_rel = bfd_make_section(dynobj, ".rela.opd"); + fptr_rel = bfd_make_section_with_flags (dynobj, ".rela.opd", + (SEC_ALLOC | SEC_LOAD + | SEC_HAS_CONTENTS + | SEC_IN_MEMORY + | SEC_LINKER_CREATED + | SEC_READONLY)); if (fptr_rel == NULL - || !bfd_set_section_flags (dynobj, fptr_rel, - (SEC_ALLOC | SEC_LOAD - | SEC_HAS_CONTENTS - | SEC_IN_MEMORY - | SEC_LINKER_CREATED - | SEC_READONLY)) || !bfd_set_section_alignment (abfd, fptr_rel, LOG_SECTION_ALIGN)) { @@ -2096,15 +2094,15 @@ get_pltoff (abfd, info, ia64_info) if (!dynobj) ia64_info->root.dynobj = dynobj = abfd; - pltoff = bfd_make_section (dynobj, ELF_STRING_ia64_pltoff); + pltoff = bfd_make_section_with_flags (dynobj, + ELF_STRING_ia64_pltoff, + (SEC_ALLOC + | SEC_LOAD + | SEC_HAS_CONTENTS + | SEC_IN_MEMORY + | SEC_SMALL_DATA + | SEC_LINKER_CREATED)); if (!pltoff - || !bfd_set_section_flags (dynobj, pltoff, - (SEC_ALLOC - | SEC_LOAD - | SEC_HAS_CONTENTS - | SEC_IN_MEMORY - | SEC_SMALL_DATA - | SEC_LINKER_CREATED)) || !bfd_set_section_alignment (abfd, pltoff, 4)) { BFD_ASSERT (0); @@ -2148,15 +2146,13 @@ get_reloc_section (abfd, ia64_info, sec, create) srel = bfd_get_section_by_name (dynobj, srel_name); if (srel == NULL && create) { - srel = bfd_make_section (dynobj, srel_name); + srel = bfd_make_section_with_flags (dynobj, srel_name, + (SEC_ALLOC | SEC_LOAD + | SEC_HAS_CONTENTS + | SEC_IN_MEMORY + | SEC_LINKER_CREATED + | SEC_READONLY)); if (srel == NULL - || !bfd_set_section_flags (dynobj, srel, - (SEC_ALLOC - | SEC_LOAD - | SEC_HAS_CONTENTS - | SEC_IN_MEMORY - | SEC_LINKER_CREATED - | SEC_READONLY)) || !bfd_set_section_alignment (dynobj, srel, LOG_SECTION_ALIGN)) return NULL; @@ -4965,9 +4961,9 @@ elfNN_ia64_object_p (bfd *abfd) /* We need to create a fake group section for it and its unwind sections. */ - group = bfd_make_section_anyway (abfd, name); - if (group == NULL - || ! bfd_set_section_flags (abfd, group, flags)) + group = bfd_make_section_anyway_with_flags (abfd, name, + flags); + if (group == NULL) return FALSE; /* Move the fake group section to the beginning. */ diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c index 259f81a..2868ba9 100644 --- a/bfd/elfxx-mips.c +++ b/bfd/elfxx-mips.c @@ -1908,15 +1908,14 @@ mips_elf_rel_dyn_section (bfd *dynobj, bfd_boolean create_p) sreloc = bfd_get_section_by_name (dynobj, dname); if (sreloc == NULL && create_p) { - sreloc = bfd_make_section (dynobj, dname); + sreloc = bfd_make_section_with_flags (dynobj, dname, + (SEC_ALLOC + | SEC_LOAD + | SEC_HAS_CONTENTS + | SEC_IN_MEMORY + | SEC_LINKER_CREATED + | SEC_READONLY)); if (sreloc == NULL - || ! bfd_set_section_flags (dynobj, sreloc, - (SEC_ALLOC - | SEC_LOAD - | SEC_HAS_CONTENTS - | SEC_IN_MEMORY - | SEC_LINKER_CREATED - | SEC_READONLY)) || ! bfd_set_section_alignment (dynobj, sreloc, MIPS_ELF_LOG_FILE_ALIGN (dynobj))) return NULL; @@ -3512,9 +3511,8 @@ mips_elf_create_compact_rel_section flags = (SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED | SEC_READONLY); - s = bfd_make_section (abfd, ".compact_rel"); + s = bfd_make_section_with_flags (abfd, ".compact_rel", flags); if (s == NULL - || ! bfd_set_section_flags (abfd, s, flags) || ! bfd_set_section_alignment (abfd, s, MIPS_ELF_LOG_FILE_ALIGN (abfd))) return FALSE; @@ -3555,9 +3553,8 @@ mips_elf_create_got_section (bfd *abfd, struct bfd_link_info *info, /* We have to use an alignment of 2**4 here because this is hardcoded in the function stub generation and in the linker script. */ - 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, 4)) return FALSE; @@ -5588,9 +5585,10 @@ _bfd_mips_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) if (bfd_get_section_by_name (abfd, MIPS_ELF_STUB_SECTION_NAME (abfd)) == NULL) { - s = bfd_make_section (abfd, MIPS_ELF_STUB_SECTION_NAME (abfd)); + s = bfd_make_section_with_flags (abfd, + MIPS_ELF_STUB_SECTION_NAME (abfd), + flags | SEC_CODE); if (s == NULL - || ! bfd_set_section_flags (abfd, s, flags | SEC_CODE) || ! bfd_set_section_alignment (abfd, s, MIPS_ELF_LOG_FILE_ALIGN (abfd))) return FALSE; @@ -5600,9 +5598,9 @@ _bfd_mips_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) && !info->shared && bfd_get_section_by_name (abfd, ".rld_map") == NULL) { - s = bfd_make_section (abfd, ".rld_map"); + s = bfd_make_section_with_flags (abfd, ".rld_map", + flags &~ (flagword) SEC_READONLY); if (s == NULL - || ! bfd_set_section_flags (abfd, s, flags &~ (flagword) SEC_READONLY) || ! bfd_set_section_alignment (abfd, s, MIPS_ELF_LOG_FILE_ALIGN (abfd))) return FALSE; @@ -9213,9 +9211,10 @@ _bfd_mips_elf_final_link (bfd *abfd, struct bfd_link_info *info) flagword flags = (SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED | SEC_READONLY); - rtproc_sec = bfd_make_section (abfd, ".rtproc"); + rtproc_sec = bfd_make_section_with_flags (abfd, + ".rtproc", + flags); if (rtproc_sec == NULL - || ! bfd_set_section_flags (abfd, rtproc_sec, flags) || ! bfd_set_section_alignment (abfd, rtproc_sec, 4)) return FALSE; } diff --git a/bfd/elfxx-sparc.c b/bfd/elfxx-sparc.c index 86a42ad..8f6ff7d 100644 --- a/bfd/elfxx-sparc.c +++ b/bfd/elfxx-sparc.c @@ -829,14 +829,14 @@ create_got_section (bfd *dynobj, struct bfd_link_info *info) htab->sgot = bfd_get_section_by_name (dynobj, ".got"); BFD_ASSERT (htab->sgot != NULL); - htab->srelgot = bfd_make_section (dynobj, ".rela.got"); + htab->srelgot = bfd_make_section_with_flags (dynobj, ".rela.got", + SEC_ALLOC + | SEC_LOAD + | SEC_HAS_CONTENTS + | SEC_IN_MEMORY + | SEC_LINKER_CREATED + | SEC_READONLY); if (htab->srelgot == NULL - || ! bfd_set_section_flags (dynobj, htab->srelgot, SEC_ALLOC - | SEC_LOAD - | SEC_HAS_CONTENTS - | SEC_IN_MEMORY - | SEC_LINKER_CREATED - | SEC_READONLY) || ! bfd_set_section_alignment (dynobj, htab->srelgot, htab->word_align_power)) return FALSE; @@ -1345,13 +1345,14 @@ _bfd_sparc_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, { flagword flags; - sreloc = bfd_make_section (dynobj, name); flags = (SEC_HAS_CONTENTS | SEC_READONLY | SEC_IN_MEMORY | SEC_LINKER_CREATED); if ((sec->flags & SEC_ALLOC) != 0) flags |= SEC_ALLOC | SEC_LOAD; + sreloc = bfd_make_section_with_flags (dynobj, + name, + flags); if (sreloc == NULL - || ! bfd_set_section_flags (dynobj, sreloc, flags) || ! bfd_set_section_alignment (dynobj, sreloc, htab->word_align_power)) return FALSE; diff --git a/bfd/section.c b/bfd/section.c index 2683cea..4e46a5d 100644 --- a/bfd/section.c +++ b/bfd/section.c @@ -1004,15 +1004,17 @@ bfd_make_section_old_way (bfd *abfd, const char *name) /* FUNCTION - bfd_make_section_anyway + bfd_make_section_anyway_with_flags SYNOPSIS - asection *bfd_make_section_anyway (bfd *abfd, const char *name); + asection *bfd_make_section_anyway_with_flags + (bfd *abfd, const char *name, flagword flags); DESCRIPTION Create a new empty section called @var{name} and attach it to the end of the chain of sections for @var{abfd}. Create a new section even if there - is already a section with that name. + is already a section with that name. Also set the attributes of the + new section to the value @var{flags}. Return <<NULL>> and set <<bfd_error>> on error; possible errors are: o <<bfd_error_invalid_operation>> - If output has already started for @var{abfd}. @@ -1020,7 +1022,8 @@ DESCRIPTION */ sec_ptr -bfd_make_section_anyway (bfd *abfd, const char *name) +bfd_make_section_anyway_with_flags (bfd *abfd, const char *name, + flagword flags) { struct section_hash_entry *sh; asection *newsect; @@ -1053,26 +1056,53 @@ bfd_make_section_anyway (bfd *abfd, const char *name) newsect = &new_sh->section; } + newsect->flags = flags; newsect->name = name; return bfd_section_init (abfd, newsect); } /* FUNCTION - bfd_make_section + bfd_make_section_anyway SYNOPSIS - asection *bfd_make_section (bfd *, const char *name); + asection *bfd_make_section_anyway (bfd *abfd, const char *name); + +DESCRIPTION + Create a new empty section called @var{name} and attach it to the end of + the chain of sections for @var{abfd}. Create a new section even if there + is already a section with that name. + + Return <<NULL>> and set <<bfd_error>> on error; possible errors are: + o <<bfd_error_invalid_operation>> - If output has already started for @var{abfd}. + o <<bfd_error_no_memory>> - If memory allocation fails. +*/ + +sec_ptr +bfd_make_section_anyway (bfd *abfd, const char *name) +{ + return bfd_make_section_anyway_with_flags (abfd, name, 0); +} + +/* +FUNCTION + bfd_make_section_with_flags + +SYNOPSIS + asection *bfd_make_section_with_flags + (bfd *, const char *name, flagword flags); DESCRIPTION Like <<bfd_make_section_anyway>>, but return <<NULL>> (without calling bfd_set_error ()) without changing the section chain if there is already a - section named @var{name}. If there is an error, return <<NULL>> and set + section named @var{name}. Also set the attributes of the new section to + the value @var{flags}. If there is an error, return <<NULL>> and set <<bfd_error>>. */ asection * -bfd_make_section (bfd *abfd, const char *name) +bfd_make_section_with_flags (bfd *abfd, const char *name, + flagword flags) { struct section_hash_entry *sh; asection *newsect; @@ -1101,11 +1131,32 @@ bfd_make_section (bfd *abfd, const char *name) } newsect->name = name; + newsect->flags = flags; return bfd_section_init (abfd, newsect); } /* FUNCTION + bfd_make_section + +SYNOPSIS + asection *bfd_make_section (bfd *, const char *name); + +DESCRIPTION + Like <<bfd_make_section_anyway>>, but return <<NULL>> (without calling + bfd_set_error ()) without changing the section chain if there is already a + section named @var{name}. If there is an error, return <<NULL>> and set + <<bfd_error>>. +*/ + +asection * +bfd_make_section (bfd *abfd, const char *name) +{ + return bfd_make_section_with_flags (abfd, name, 0); +} + +/* +FUNCTION bfd_set_section_flags SYNOPSIS |