aboutsummaryrefslogtreecommitdiff
path: root/binutils
diff options
context:
space:
mode:
Diffstat (limited to 'binutils')
-rw-r--r--binutils/ChangeLog7
-rw-r--r--binutils/objcopy.c69
2 files changed, 33 insertions, 43 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 3e25586..2498494 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,10 @@
+2005-07-04 Alan Modra <amodra@bigpond.net.au>
+
+ PR 1004
+ * objcopy.c (copy_object): Use bfd_make_section_with_flags.
+ (write_debugging_info): Likewise.
+ (setup_section): Use bfd_make_section_anyway_with_flags.
+
2005-07-01 Steve Ellcey <sje@cup.hp.com>
* configure.in (AM_BINUTILS_WARNINGS): Add.
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index 4dfba3c..abc0eb1 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -1290,7 +1290,15 @@ copy_object (bfd *ibfd, bfd *obfd)
{
flagword flags;
- padd->section = bfd_make_section (obfd, padd->name);
+ pset = find_section_list (padd->name, FALSE);
+ if (pset != NULL)
+ pset->used = TRUE;
+
+ flags = SEC_HAS_CONTENTS | SEC_READONLY | SEC_DATA;
+ if (pset != NULL && pset->set_flags)
+ flags = pset->flags | SEC_HAS_CONTENTS;
+
+ padd->section = bfd_make_section_with_flags (obfd, padd->name, flags);
if (padd->section == NULL)
{
non_fatal (_("can't create section `%s': %s"),
@@ -1304,21 +1312,6 @@ copy_object (bfd *ibfd, bfd *obfd)
return FALSE;
}
- pset = find_section_list (padd->name, FALSE);
- if (pset != NULL)
- pset->used = TRUE;
-
- if (pset != NULL && pset->set_flags)
- flags = pset->flags | SEC_HAS_CONTENTS;
- else
- flags = SEC_HAS_CONTENTS | SEC_READONLY | SEC_DATA;
-
- if (! bfd_set_section_flags (obfd, padd->section, flags))
- {
- bfd_nonfatal (bfd_get_filename (obfd));
- return FALSE;
- }
-
if (pset != NULL)
{
if (pset->change_vma != CHANGE_IGNORE)
@@ -2001,7 +1994,12 @@ setup_section (bfd *ibfd, sec_ptr isection, void *obfdarg)
name = n;
}
- osection = bfd_make_section_anyway (obfd, name);
+ if (p != NULL && p->set_flags)
+ flags = p->flags | (flags & (SEC_HAS_CONTENTS | SEC_RELOC));
+ else if (strip_symbols == STRIP_NONDEBUG && (flags & SEC_ALLOC) != 0)
+ flags &= ~(SEC_HAS_CONTENTS | SEC_LOAD);
+
+ osection = bfd_make_section_anyway_with_flags (obfd, name, flags);
if (osection == NULL)
{
@@ -2009,6 +2007,12 @@ setup_section (bfd *ibfd, sec_ptr isection, void *obfdarg)
goto loser;
}
+ if (strip_symbols == STRIP_NONDEBUG
+ && obfd->xvec->flavour == bfd_target_elf_flavour
+ && (flags & SEC_ALLOC) != 0
+ && (p == NULL || !p->set_flags))
+ elf_section_type (osection) = SHT_NOBITS;
+
size = bfd_section_size (ibfd, isection);
if (copy_byte >= 0)
size = (size + interleave - 1) / interleave;
@@ -2057,21 +2061,6 @@ setup_section (bfd *ibfd, sec_ptr isection, void *obfdarg)
goto loser;
}
- if (p != NULL && p->set_flags)
- flags = p->flags | (flags & (SEC_HAS_CONTENTS | SEC_RELOC));
- else if (strip_symbols == STRIP_NONDEBUG && (flags & SEC_ALLOC) != 0)
- {
- flags &= ~(SEC_HAS_CONTENTS | SEC_LOAD);
- if (obfd->xvec->flavour == bfd_target_elf_flavour)
- elf_section_type (osection) = SHT_NOBITS;
- }
-
- if (!bfd_set_section_flags (obfd, osection, flags))
- {
- err = _("flags");
- goto loser;
- }
-
/* Copy merge entity size. */
osection->entsize = isection->entsize;
@@ -2353,28 +2342,22 @@ write_debugging_info (bfd *obfd, void *dhandle,
bfd_byte *syms, *strings;
bfd_size_type symsize, stringsize;
asection *stabsec, *stabstrsec;
+ flagword flags;
if (! write_stabs_in_sections_debugging_info (obfd, dhandle, &syms,
&symsize, &strings,
&stringsize))
return FALSE;
- stabsec = bfd_make_section (obfd, ".stab");
- stabstrsec = bfd_make_section (obfd, ".stabstr");
+ flags = SEC_HAS_CONTENTS | SEC_READONLY | SEC_DEBUGGING;
+ stabsec = bfd_make_section_with_flags (obfd, ".stab", flags);
+ stabstrsec = bfd_make_section_with_flags (obfd, ".stabstr", flags);
if (stabsec == NULL
|| stabstrsec == NULL
|| ! bfd_set_section_size (obfd, stabsec, symsize)
|| ! bfd_set_section_size (obfd, stabstrsec, stringsize)
|| ! bfd_set_section_alignment (obfd, stabsec, 2)
- || ! bfd_set_section_alignment (obfd, stabstrsec, 0)
- || ! bfd_set_section_flags (obfd, stabsec,
- (SEC_HAS_CONTENTS
- | SEC_READONLY
- | SEC_DEBUGGING))
- || ! bfd_set_section_flags (obfd, stabstrsec,
- (SEC_HAS_CONTENTS
- | SEC_READONLY
- | SEC_DEBUGGING)))
+ || ! bfd_set_section_alignment (obfd, stabstrsec, 0))
{
non_fatal (_("%s: can't create debugging section: %s"),
bfd_get_filename (obfd),