From 0eb80fd3e5ec31277b9df363ae066233783e4cbb Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Mon, 7 Jul 2008 00:44:41 +0000 Subject: [PATCH] * ieee.c (write_ieee_debugging_info): Use bfd_make_section_with_flags. * nlmconv.c (main, powerpc_build_stubs): Likewise. * rescoff.c (write_coff_file): Likewise. * resres.c (write_res_file): Likewise. * windmc.c (windmc_write_bin): Likewise. --- binutils/ChangeLog | 8 +++++ binutils/ieee.c | 10 ++---- binutils/nlmconv.c | 80 +++++++++++++++++++++------------------------- binutils/rescoff.c | 11 +++---- binutils/resres.c | 10 +++--- binutils/windmc.c | 10 +++--- 6 files changed, 60 insertions(+), 69 deletions(-) diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 22ed7f0b2ac..ce2fa3bf250 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,11 @@ +2008-07-07 Alan Modra + + * ieee.c (write_ieee_debugging_info): Use bfd_make_section_with_flags. + * nlmconv.c (main, powerpc_build_stubs): Likewise. + * rescoff.c (write_coff_file): Likewise. + * resres.c (write_res_file): Likewise. + * windmc.c (windmc_write_bin): Likewise. + 2008-06-18 M R Swami Reddy * readelf.c (guess_is_rela): Add EM_CR16_OLD. diff --git a/binutils/ieee.c b/binutils/ieee.c index 0645db93781..9a61132bfa2 100644 --- a/binutils/ieee.c +++ b/binutils/ieee.c @@ -1,5 +1,5 @@ /* ieee.c -- Read and write IEEE-695 debugging information. - Copyright 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2006, 2007 + Copyright 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2006, 2007, 2008 Free Software Foundation, Inc. Written by Ian Lance Taylor . @@ -4676,14 +4676,10 @@ write_ieee_debugging_info (bfd *abfd, void *dhandle) return TRUE; } err = NULL; - s = bfd_make_section (abfd, ".debug"); + s = bfd_make_section_with_flags (abfd, ".debug", + SEC_DEBUGGING | SEC_HAS_CONTENTS); if (s == NULL) err = "bfd_make_section"; - if (err == NULL) - { - if (! bfd_set_section_flags (abfd, s, SEC_DEBUGGING | SEC_HAS_CONTENTS)) - err = "bfd_set_section_flags"; - } if (err == NULL) { bfd_size_type size; diff --git a/binutils/nlmconv.c b/binutils/nlmconv.c index 2fb74bfe0e8..f8fec731585 100644 --- a/binutils/nlmconv.c +++ b/binutils/nlmconv.c @@ -1,6 +1,6 @@ /* nlmconv.c -- NLM conversion program Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, - 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. + 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. This file is part of GNU Binutils. @@ -395,9 +395,10 @@ main (int argc, char **argv) bss_sec = bfd_get_section_by_name (outbfd, NLM_UNINITIALIZED_DATA_NAME); if (bss_sec == NULL) { - bss_sec = bfd_make_section (outbfd, NLM_UNINITIALIZED_DATA_NAME); + bss_sec = bfd_make_section_with_flags (outbfd, + NLM_UNINITIALIZED_DATA_NAME, + SEC_ALLOC); if (bss_sec == NULL - || ! bfd_set_section_flags (outbfd, bss_sec, SEC_ALLOC) || ! bfd_set_section_alignment (outbfd, bss_sec, 1)) bfd_fatal (_("make .bss section")); } @@ -406,11 +407,10 @@ main (int argc, char **argv) so that programs which understand it can resurrect the original sections from the NLM. We will put a pointer to .nlmsections in the NLM header area. */ - secsec = bfd_make_section (outbfd, ".nlmsections"); + secsec = bfd_make_section_with_flags (outbfd, ".nlmsections", + SEC_HAS_CONTENTS); if (secsec == NULL) bfd_fatal (_("make .nlmsections section")); - if (! bfd_set_section_flags (outbfd, secsec, SEC_HAS_CONTENTS)) - bfd_fatal (_("set .nlmsections flags")); #ifdef NLMCONV_POWERPC /* For PowerPC NetWare we need to build stubs for calls to undefined @@ -714,11 +714,10 @@ main (int argc, char **argv) else { custom_size = st.st_size; - custom_section = bfd_make_section (outbfd, ".nlmcustom"); + custom_section = bfd_make_section_with_flags (outbfd, ".nlmcustom", + SEC_HAS_CONTENTS); if (custom_section == NULL - || ! bfd_set_section_size (outbfd, custom_section, custom_size) - || ! bfd_set_section_flags (outbfd, custom_section, - SEC_HAS_CONTENTS)) + || ! bfd_set_section_size (outbfd, custom_section, custom_size)) bfd_fatal (_("custom section")); } } @@ -735,11 +734,10 @@ main (int argc, char **argv) else { help_size = st.st_size; - help_section = bfd_make_section (outbfd, ".nlmhelp"); + help_section = bfd_make_section_with_flags (outbfd, ".nlmhelp", + SEC_HAS_CONTENTS); if (help_section == NULL - || ! bfd_set_section_size (outbfd, help_section, help_size) - || ! bfd_set_section_flags (outbfd, help_section, - SEC_HAS_CONTENTS)) + || ! bfd_set_section_size (outbfd, help_section, help_size)) bfd_fatal (_("help section")); LITMEMCPY (nlm_extended_header (outbfd)->stamp, "MeSsAgEs"); } @@ -757,11 +755,11 @@ main (int argc, char **argv) else { message_size = st.st_size; - message_section = bfd_make_section (outbfd, ".nlmmessages"); + message_section = bfd_make_section_with_flags (outbfd, + ".nlmmessages", + SEC_HAS_CONTENTS); if (message_section == NULL - || ! bfd_set_section_size (outbfd, message_section, message_size) - || ! bfd_set_section_flags (outbfd, message_section, - SEC_HAS_CONTENTS)) + || ! bfd_set_section_size (outbfd, message_section, message_size)) bfd_fatal (_("message section")); LITMEMCPY (nlm_extended_header (outbfd)->stamp, "MeSsAgEs"); } @@ -773,11 +771,10 @@ main (int argc, char **argv) module_size = 0; for (l = modules; l != NULL; l = l->next) module_size += strlen (l->string) + 1; - module_section = bfd_make_section (outbfd, ".nlmmodules"); + module_section = bfd_make_section_with_flags (outbfd, ".nlmmodules", + SEC_HAS_CONTENTS); if (module_section == NULL - || ! bfd_set_section_size (outbfd, module_section, module_size) - || ! bfd_set_section_flags (outbfd, module_section, - SEC_HAS_CONTENTS)) + || ! bfd_set_section_size (outbfd, module_section, module_size)) bfd_fatal (_("module section")); } if (rpc_file != NULL) @@ -793,11 +790,10 @@ main (int argc, char **argv) else { rpc_size = st.st_size; - rpc_section = bfd_make_section (outbfd, ".nlmrpc"); + rpc_section = bfd_make_section_with_flags (outbfd, ".nlmrpc", + SEC_HAS_CONTENTS); if (rpc_section == NULL - || ! bfd_set_section_size (outbfd, rpc_section, rpc_size) - || ! bfd_set_section_flags (outbfd, rpc_section, - SEC_HAS_CONTENTS)) + || ! bfd_set_section_size (outbfd, rpc_section, rpc_size)) bfd_fatal (_("rpc section")); LITMEMCPY (nlm_extended_header (outbfd)->stamp, "MeSsAgEs"); } @@ -849,12 +845,12 @@ main (int argc, char **argv) if (shared_offset > (size_t) sharedhdr.publicsOffset) shared_offset = sharedhdr.publicsOffset; shared_size = st.st_size - shared_offset; - shared_section = bfd_make_section (outbfd, ".nlmshared"); + shared_section = bfd_make_section_with_flags (outbfd, + ".nlmshared", + SEC_HAS_CONTENTS); if (shared_section == NULL || ! bfd_set_section_size (outbfd, shared_section, - shared_size) - || ! bfd_set_section_flags (outbfd, shared_section, - SEC_HAS_CONTENTS)) + shared_size)) bfd_fatal (_("shared section")); LITMEMCPY (nlm_extended_header (outbfd)->stamp, "MeSsAgEs"); } @@ -1701,13 +1697,12 @@ powerpc_build_stubs (bfd *inbfd, bfd *outbfd ATTRIBUTE_UNUSED, /* Make a section to hold stubs. We don't set SEC_HAS_CONTENTS for the section to prevent copy_sections from reading from it. */ - stub_sec = bfd_make_section (inbfd, ".stubs"); + stub_sec = bfd_make_section_with_flags (inbfd, ".stubs", + (SEC_CODE + | SEC_RELOC + | SEC_ALLOC + | SEC_LOAD)); if (stub_sec == (asection *) NULL - || ! bfd_set_section_flags (inbfd, stub_sec, - (SEC_CODE - | SEC_RELOC - | SEC_ALLOC - | SEC_LOAD)) || ! bfd_set_section_alignment (inbfd, stub_sec, 2)) bfd_fatal (".stubs"); @@ -1715,14 +1710,13 @@ powerpc_build_stubs (bfd *inbfd, bfd *outbfd ATTRIBUTE_UNUSED, got_sec = bfd_get_section_by_name (inbfd, ".got"); if (got_sec == (asection *) NULL) { - got_sec = bfd_make_section (inbfd, ".got"); + got_sec = bfd_make_section_with_flags (inbfd, ".got", + (SEC_DATA + | SEC_RELOC + | SEC_ALLOC + | SEC_LOAD + | SEC_HAS_CONTENTS)); if (got_sec == (asection *) NULL - || ! bfd_set_section_flags (inbfd, got_sec, - (SEC_DATA - | SEC_RELOC - | SEC_ALLOC - | SEC_LOAD - | SEC_HAS_CONTENTS)) || ! bfd_set_section_alignment (inbfd, got_sec, 2)) bfd_fatal (".got"); } diff --git a/binutils/rescoff.c b/binutils/rescoff.c index e19f58a20c5..6fc63dc84a0 100644 --- a/binutils/rescoff.c +++ b/binutils/rescoff.c @@ -1,5 +1,5 @@ /* rescoff.c -- read and write resources in Windows COFF files. - Copyright 1997, 1998, 1999, 2000, 2003, 2007 + Copyright 1997, 1998, 1999, 2000, 2003, 2007, 2008 Free Software Foundation, Inc. Written by Ian Lance Taylor, Cygnus Support. Rewritten by Kai Tietz, Onevision. @@ -455,15 +455,12 @@ write_coff_file (const char *filename, const char *target, if (! bfd_set_file_flags (abfd, HAS_SYMS | HAS_RELOC)) bfd_fatal ("bfd_set_file_flags"); - sec = bfd_make_section (abfd, ".rsrc"); + sec = bfd_make_section_with_flags (abfd, ".rsrc", + (SEC_HAS_CONTENTS | SEC_ALLOC + | SEC_LOAD | SEC_DATA)); if (sec == NULL) bfd_fatal ("bfd_make_section"); - if (! bfd_set_section_flags (abfd, sec, - (SEC_HAS_CONTENTS | SEC_ALLOC - | SEC_LOAD | SEC_DATA))) - bfd_fatal ("bfd_set_section_flags"); - if (! bfd_set_symtab (abfd, sec->symbol_ptr_ptr, 1)) bfd_fatal ("bfd_set_symtab"); diff --git a/binutils/resres.c b/binutils/resres.c index 49fb3fd14a9..0ae5694a871 100644 --- a/binutils/resres.c +++ b/binutils/resres.c @@ -1,5 +1,5 @@ /* resres.c: read_res_file and write_res_file implementation for windres. - Copyright 1998, 1999, 2001, 2002, 2007 + Copyright 1998, 1999, 2001, 2002, 2007, 2008 Free Software Foundation, Inc. Written by Anders Norlander . Rewritten by Kai Tietz, Onevision. @@ -128,13 +128,11 @@ write_res_file (const char *fn,const rc_res_directory *resdir) filename = fn; abfd = windres_open_as_binary (filename, 0); - sec = bfd_make_section (abfd, ".data"); + sec = bfd_make_section_with_flags (abfd, ".data", + (SEC_HAS_CONTENTS | SEC_ALLOC + | SEC_LOAD | SEC_DATA)); if (sec == NULL) bfd_fatal ("bfd_make_section"); - if (! bfd_set_section_flags (abfd, sec, - (SEC_HAS_CONTENTS | SEC_ALLOC - | SEC_LOAD | SEC_DATA))) - bfd_fatal ("bfd_set_section_flags"); /* Requiring this is probably a bug in BFD. */ sec->output_section = sec; diff --git a/binutils/windmc.c b/binutils/windmc.c index 2c6da4283db..70c9160aba9 100644 --- a/binutils/windmc.c +++ b/binutils/windmc.c @@ -1,5 +1,5 @@ /* windmc.c -- a program to compile Windows message files. - Copyright 2007 + Copyright 2007, 2008 Free Software Foundation, Inc. Written by Kai Tietz, Onevision. @@ -707,13 +707,11 @@ windmc_write_bin (const char *filename, mc_node_lang **nl, int elems) if (elems <= 0) return; mc_bfd.abfd = windmc_open_as_binary (filename); - mc_bfd.sec = bfd_make_section (mc_bfd.abfd, ".data"); + mc_bfd.sec = bfd_make_section_with_flags (mc_bfd.abfd, ".data", + (SEC_HAS_CONTENTS | SEC_ALLOC + | SEC_LOAD | SEC_DATA)); if (mc_bfd.sec == NULL) bfd_fatal ("bfd_make_section"); - if (! bfd_set_section_flags (mc_bfd.abfd, mc_bfd.sec, - (SEC_HAS_CONTENTS | SEC_ALLOC - | SEC_LOAD | SEC_DATA))) - bfd_fatal ("bfd_set_section_flags"); /* Requiring this is probably a bug in BFD. */ mc_bfd.sec->output_section = mc_bfd.sec; -- 2.30.2