Tidy ups for objcopy.c

Nick Clifton nickc@redhat.com
Wed Jul 23 17:33:00 GMT 2003


Hi Guys,

  I am checking in the patch below to tidy up the code in objcopy.c
  and also update it to ISO C.

Cheers
        Nick

binutils/ChangeLog
2003-07-23  Nick Clifton  <nickc@redhat.com>

	* objcopy.c: Switch to ISO C.  Remove debugging code accidentally
	left in.  Some formatting tidy ups.

Index: objcopy.c
===================================================================
RCS file: /cvs/src/src/binutils/objcopy.c,v
retrieving revision 1.51
diff -c -3 -p -r1.51 objcopy.c
*** objcopy.c	27 Jun 2003 08:01:28 -0000	1.51
--- objcopy.c	23 Jul 2003 17:25:27 -0000
*************** typedef struct section_rename
*** 58,122 ****
  section_rename;
  
  /* List of sections to be renamed.  */
! static section_rename * section_rename_list;
  
  static void copy_usage
!   PARAMS ((FILE *, int));
  static void strip_usage
!   PARAMS ((FILE *, int));
  static flagword parse_flags
!   PARAMS ((const char *));
  static struct section_list *find_section_list
!   PARAMS ((const char *, bfd_boolean));
  static void setup_section
!   PARAMS ((bfd *, asection *, PTR));
  static void copy_section
!   PARAMS ((bfd *, asection *, PTR));
  static void get_sections
!   PARAMS ((bfd *, asection *, PTR));
  static int compare_section_lma
!   PARAMS ((const PTR, const PTR));
  static void add_specific_symbol
!   PARAMS ((const char *, struct symlist **));
  static void add_specific_symbols
!   PARAMS ((const char *, struct symlist **));
  static bfd_boolean is_specified_symbol
!   PARAMS ((const char *, struct symlist *));
  static bfd_boolean is_strip_section
!   PARAMS ((bfd *, asection *));
  static unsigned int filter_symbols
!   PARAMS ((bfd *, bfd *, asymbol **, asymbol **, long));
  static void mark_symbols_used_in_relocations
!   PARAMS ((bfd *, asection *, PTR));
  static void filter_bytes
!   PARAMS ((char *, bfd_size_type *));
  static bfd_boolean write_debugging_info
!   PARAMS ((bfd *, PTR, long *, asymbol ***));
  static void copy_object
!   PARAMS ((bfd *, bfd *));
  static void copy_archive
!   PARAMS ((bfd *, bfd *, const char *));
  static void copy_file
!   PARAMS ((const char *, const char *, const char *, const char *));
  static int strip_main
!   PARAMS ((int, char **));
  static int copy_main
!   PARAMS ((int, char **));
  static const char *lookup_sym_redefinition
!   PARAMS((const char *));
  static void redefine_list_append
!   PARAMS ((const char *, const char *, const char *));
  static const char * find_section_rename
!   PARAMS ((bfd *, sec_ptr, flagword *));
  static void add_section_rename
!   PARAMS ((const char *, const char *, flagword));
  static void add_redefine_syms_file 
!   PARAMS ((const char *));
  
  #define RETURN_NONFATAL(s) {bfd_nonfatal (s); status = 1; return;}
  
! static asymbol **isympp = NULL;	/* Input symbols */
! static asymbol **osympp = NULL;	/* Output symbols that survive stripping */
  
  /* If `copy_byte' >= 0, copy only that byte of every `interleave' bytes.  */
  static int copy_byte = -1;
--- 58,122 ----
  section_rename;
  
  /* List of sections to be renamed.  */
! static section_rename *section_rename_list;
  
  static void copy_usage
!   (FILE *, int);
  static void strip_usage
!   (FILE *, int);
  static flagword parse_flags
!   (const char *);
  static struct section_list *find_section_list
!   (const char *, bfd_boolean);
  static void setup_section
!   (bfd *, asection *, void *);
  static void copy_section
!   (bfd *, asection *, void *);
  static void get_sections
!   (bfd *, asection *, void *);
  static int compare_section_lma
!   (const void *, const void *);
  static void add_specific_symbol
!   (const char *, struct symlist **);
  static void add_specific_symbols
!   (const char *, struct symlist **);
  static bfd_boolean is_specified_symbol
!   (const char *, struct symlist *);
  static bfd_boolean is_strip_section
!   (bfd *, asection *);
  static unsigned int filter_symbols
!   (bfd *, bfd *, asymbol **, asymbol **, long);
  static void mark_symbols_used_in_relocations
!   (bfd *, asection *, void *);
  static void filter_bytes
!   (char *, bfd_size_type *);
  static bfd_boolean write_debugging_info
!   (bfd *, void *, long *, asymbol ***);
  static void copy_object
!   (bfd *, bfd *);
  static void copy_archive
!   (bfd *, bfd *, const char *);
  static void copy_file
!   (const char *, const char *, const char *, const char *);
  static int strip_main
!   (int, char **);
  static int copy_main
!   (int, char **);
  static const char *lookup_sym_redefinition
!   (const char *);
  static void redefine_list_append
!   (const char *, const char *, const char *);
  static const char * find_section_rename
!   (bfd *, sec_ptr, flagword *);
  static void add_section_rename
!   (const char *, const char *, flagword);
  static void add_redefine_syms_file 
!   (const char *);
  
  #define RETURN_NONFATAL(s) {bfd_nonfatal (s); status = 1; return;}
  
! static asymbol **isympp = NULL;	/* Input symbols.  */
! static asymbol **osympp = NULL;	/* Output symbols that survive stripping.  */
  
  /* If `copy_byte' >= 0, copy only that byte of every `interleave' bytes.  */
  static int copy_byte = -1;
*************** static int status = 0;		/* Exit status. 
*** 129,139 ****
  enum strip_action
    {
      STRIP_UNDEF,
!     STRIP_NONE,			/* don't strip */
!     STRIP_DEBUG,		/* strip all debugger symbols */
!     STRIP_UNNEEDED,		/* strip unnecessary symbols */
      STRIP_NONDEBUG,		/* Strip everything but debug info.  */
!     STRIP_ALL			/* strip all symbols */
    };
  
  /* Which symbols to remove.  */
--- 129,139 ----
  enum strip_action
    {
      STRIP_UNDEF,
!     STRIP_NONE,			/* Don't strip.  */
!     STRIP_DEBUG,		/* Strip all debugger symbols.  */
!     STRIP_UNNEEDED,		/* Strip unnecessary symbols.  */
      STRIP_NONDEBUG,		/* Strip everything but debug info.  */
!     STRIP_ALL			/* Strip all symbols.  */
    };
  
  /* Which symbols to remove.  */
*************** static enum strip_action strip_symbols;
*** 142,149 ****
  enum locals_action
    {
      LOCALS_UNDEF,
!     LOCALS_START_L,		/* discard locals starting with L */
!     LOCALS_ALL			/* discard all locals */
    };
  
  /* Which local symbols to remove.  Overrides STRIP_ALL.  */
--- 142,149 ----
  enum locals_action
    {
      LOCALS_UNDEF,
!     LOCALS_START_L,		/* Discard locals starting with L.  */
!     LOCALS_ALL			/* Discard all locals.  */
    };
  
  /* Which local symbols to remove.  Overrides STRIP_ALL.  */
*************** static char *prefix_sections_string = 0;
*** 251,291 ****
  static char *prefix_alloc_sections_string = 0;
  
  /* 150 isn't special; it's just an arbitrary non-ASCII char value.  */
! 
! #define OPTION_ADD_SECTION 150
! #define OPTION_CHANGE_ADDRESSES (OPTION_ADD_SECTION + 1)
! #define OPTION_CHANGE_LEADING_CHAR (OPTION_CHANGE_ADDRESSES + 1)
! #define OPTION_CHANGE_START (OPTION_CHANGE_LEADING_CHAR + 1)
! #define OPTION_CHANGE_SECTION_ADDRESS (OPTION_CHANGE_START + 1)
! #define OPTION_CHANGE_SECTION_LMA (OPTION_CHANGE_SECTION_ADDRESS + 1)
! #define OPTION_CHANGE_SECTION_VMA (OPTION_CHANGE_SECTION_LMA + 1)
! #define OPTION_CHANGE_WARNINGS (OPTION_CHANGE_SECTION_VMA + 1)
! #define OPTION_DEBUGGING (OPTION_CHANGE_WARNINGS + 1)
! #define OPTION_GAP_FILL (OPTION_DEBUGGING + 1)
! #define OPTION_NO_CHANGE_WARNINGS (OPTION_GAP_FILL + 1)
! #define OPTION_PAD_TO (OPTION_NO_CHANGE_WARNINGS + 1)
! #define OPTION_REMOVE_LEADING_CHAR (OPTION_PAD_TO + 1)
! #define OPTION_SET_SECTION_FLAGS (OPTION_REMOVE_LEADING_CHAR + 1)
! #define OPTION_SET_START (OPTION_SET_SECTION_FLAGS + 1)
! #define OPTION_STRIP_UNNEEDED (OPTION_SET_START + 1)
! #define OPTION_WEAKEN (OPTION_STRIP_UNNEEDED + 1)
! #define OPTION_REDEFINE_SYM (OPTION_WEAKEN + 1)
! #define OPTION_REDEFINE_SYMS (OPTION_REDEFINE_SYM + 1)
! #define OPTION_SREC_LEN (OPTION_REDEFINE_SYMS + 1)
! #define OPTION_SREC_FORCES3 (OPTION_SREC_LEN + 1)
! #define OPTION_STRIP_SYMBOLS (OPTION_SREC_FORCES3 + 1)
! #define OPTION_KEEP_SYMBOLS (OPTION_STRIP_SYMBOLS + 1)
! #define OPTION_LOCALIZE_SYMBOLS (OPTION_KEEP_SYMBOLS + 1)
! #define OPTION_KEEPGLOBAL_SYMBOLS (OPTION_LOCALIZE_SYMBOLS + 1)
! #define OPTION_WEAKEN_SYMBOLS (OPTION_KEEPGLOBAL_SYMBOLS + 1)
! #define OPTION_RENAME_SECTION (OPTION_WEAKEN_SYMBOLS + 1)
! #define OPTION_ALT_MACH_CODE (OPTION_RENAME_SECTION + 1)
! #define OPTION_PREFIX_SYMBOLS (OPTION_ALT_MACH_CODE + 1)
! #define OPTION_PREFIX_SECTIONS (OPTION_PREFIX_SYMBOLS + 1)
! #define OPTION_PREFIX_ALLOC_SECTIONS (OPTION_PREFIX_SECTIONS + 1)
! #define OPTION_FORMATS_INFO (OPTION_PREFIX_ALLOC_SECTIONS + 1)
! #define OPTION_ADD_GNU_DEBUGLINK (OPTION_FORMATS_INFO + 1)
! #define OPTION_ONLY_KEEP_DEBUG (OPTION_ADD_GNU_DEBUGLINK + 1)
  
  /* Options to handle if running as "strip".  */
  
--- 251,293 ----
  static char *prefix_alloc_sections_string = 0;
  
  /* 150 isn't special; it's just an arbitrary non-ASCII char value.  */
! enum command_line_switch
!   {
!     OPTION_ADD_SECTION=150,
!     OPTION_CHANGE_ADDRESSES,
!     OPTION_CHANGE_LEADING_CHAR,
!     OPTION_CHANGE_START,
!     OPTION_CHANGE_SECTION_ADDRESS,
!     OPTION_CHANGE_SECTION_LMA,
!     OPTION_CHANGE_SECTION_VMA,
!     OPTION_CHANGE_WARNINGS,
!     OPTION_DEBUGGING,
!     OPTION_GAP_FILL,
!     OPTION_NO_CHANGE_WARNINGS,
!     OPTION_PAD_TO,
!     OPTION_REMOVE_LEADING_CHAR,
!     OPTION_SET_SECTION_FLAGS,
!     OPTION_SET_START,
!     OPTION_STRIP_UNNEEDED,
!     OPTION_WEAKEN,
!     OPTION_REDEFINE_SYM,
!     OPTION_REDEFINE_SYMS,
!     OPTION_SREC_LEN,
!     OPTION_SREC_FORCES3,
!     OPTION_STRIP_SYMBOLS,
!     OPTION_KEEP_SYMBOLS,
!     OPTION_LOCALIZE_SYMBOLS,
!     OPTION_KEEPGLOBAL_SYMBOLS,
!     OPTION_WEAKEN_SYMBOLS,
!     OPTION_RENAME_SECTION,
!     OPTION_ALT_MACH_CODE,
!     OPTION_PREFIX_SYMBOLS,
!     OPTION_PREFIX_SECTIONS,
!     OPTION_PREFIX_ALLOC_SECTIONS,
!     OPTION_FORMATS_INFO,
!     OPTION_ADD_GNU_DEBUGLINK,
!     OPTION_ONLY_KEEP_DEBUG
!   };
  
  /* Options to handle if running as "strip".  */
  
*************** extern enum bfd_architecture bfd_externa
*** 407,415 ****
  
  
  static void
! copy_usage (stream, exit_status)
!      FILE *stream;
!      int exit_status;
  {
    fprintf (stream, _("Usage: %s [option(s)] in-file [out-file]\n"), program_name);
    fprintf (stream, _(" Copies a binary file, possibly transforming it in the process\n"));
--- 409,415 ----
  
  
  static void
! copy_usage (FILE *stream, int exit_status)
  {
    fprintf (stream, _("Usage: %s [option(s)] in-file [out-file]\n"), program_name);
    fprintf (stream, _(" Copies a binary file, possibly transforming it in the process\n"));
*************** copy_usage (stream, exit_status)
*** 486,494 ****
  }
  
  static void
! strip_usage (stream, exit_status)
!      FILE *stream;
!      int exit_status;
  {
    fprintf (stream, _("Usage: %s <option(s)> in-file(s)\n"), program_name);
    fprintf (stream, _(" Removes symbols and sections from files\n"));
--- 486,492 ----
  }
  
  static void
! strip_usage (FILE *stream, int exit_status)
  {
    fprintf (stream, _("Usage: %s <option(s)> in-file(s)\n"), program_name);
    fprintf (stream, _(" Removes symbols and sections from files\n"));
*************** strip_usage (stream, exit_status)
*** 523,530 ****
     string can't be parsed.  */
  
  static flagword
! parse_flags (s)
!      const char *s;
  {
    flagword ret;
    const char *snext;
--- 521,527 ----
     string can't be parsed.  */
  
  static flagword
! parse_flags (const char *s)
  {
    flagword ret;
    const char *snext;
*************** parse_flags (s)
*** 579,589 ****
  /* Find and optionally add an entry in the change_sections list.  */
  
  static struct section_list *
! find_section_list (name, add)
!      const char *name;
!      bfd_boolean add;
  {
!   register struct section_list *p;
  
    for (p = change_sections; p != NULL; p = p->next)
      if (strcmp (p->name, name) == 0)
--- 576,584 ----
  /* Find and optionally add an entry in the change_sections list.  */
  
  static struct section_list *
! find_section_list (const char *name, bfd_boolean add)
  {
!   struct section_list *p;
  
    for (p = change_sections; p != NULL; p = p->next)
      if (strcmp (p->name, name) == 0)
*************** find_section_list (name, add)
*** 613,621 ****
  /* Add a symbol to strip_specific_list.  */
  
  static void
! add_specific_symbol (name, list)
!      const char *name;
!      struct symlist **list;
  {
    struct symlist *tmp_list;
  
--- 608,614 ----
  /* Add a symbol to strip_specific_list.  */
  
  static void
! add_specific_symbol (const char *name, struct symlist **list)
  {
    struct symlist *tmp_list;
  
*************** add_specific_symbol (name, list)
*** 631,639 ****
  #define IS_LINE_TERMINATOR(c) ((c) == '\n' || (c) == '\r' || (c) == '\0')
  
  static void
! add_specific_symbols (filename, list)
!      const char *filename;
!      struct symlist **list;
  {
    struct stat st;
    FILE * f;
--- 624,630 ----
  #define IS_LINE_TERMINATOR(c) ((c) == '\n' || (c) == '\r' || (c) == '\0')
  
  static void
! add_specific_symbols (const char *filename, struct symlist **list)
  {
    struct stat st;
    FILE * f;
*************** add_specific_symbols (filename, list)
*** 745,753 ****
     strip_specific_list and keep_symbols.  */
  
  static bfd_boolean
! is_specified_symbol (name, list)
!      const char *name;
!      struct symlist *list;
  {
    struct symlist *tmp_list;
  
--- 736,742 ----
     strip_specific_list and keep_symbols.  */
  
  static bfd_boolean
! is_specified_symbol (const char *name, struct symlist *list)
  {
    struct symlist *tmp_list;
  
*************** is_specified_symbol (name, list)
*** 761,769 ****
  /* See if a section is being removed.  */
  
  static bfd_boolean
! is_strip_section (abfd, sec)
!      bfd *abfd ATTRIBUTE_UNUSED;
!      asection *sec;
  {
    if (sections_removed || sections_copied)
      {
--- 750,756 ----
  /* See if a section is being removed.  */
  
  static bfd_boolean
! is_strip_section (bfd *abfd ATTRIBUTE_UNUSED, asection *sec)
  {
    if (sections_removed || sections_copied)
      {
*************** is_strip_section (abfd, sec)
*** 798,810 ****
     Return the number of symbols to print.  */
  
  static unsigned int
! filter_symbols (abfd, obfd, osyms, isyms, symcount)
!      bfd *abfd;
!      bfd *obfd;
!      asymbol **osyms, **isyms;
!      long symcount;
  {
!   register asymbol **from = isyms, **to = osyms;
    long src_count = 0, dst_count = 0;
    int relocatable = (abfd->flags & (HAS_RELOC | EXEC_P | DYNAMIC))
  		    == HAS_RELOC;
--- 785,794 ----
     Return the number of symbols to print.  */
  
  static unsigned int
! filter_symbols (bfd *abfd, bfd *obfd, asymbol **osyms,
! 		asymbol **isyms, long symcount)
  {
!   asymbol **from = isyms, **to = osyms;
    long src_count = 0, dst_count = 0;
    int relocatable = (abfd->flags & (HAS_RELOC | EXEC_P | DYNAMIC))
  		    == HAS_RELOC;
*************** filter_symbols (abfd, obfd, osyms, isyms
*** 865,871 ****
          {
            char *n, *ptr;
  
!           ptr = n = xmalloc (1 + strlen (prefix_symbols_string) + strlen (name) + 1);
            if (add_leading_char)
  	    *ptr++ = bfd_get_symbol_leading_char (obfd);
  
--- 849,856 ----
          {
            char *n, *ptr;
  
!           ptr = n = xmalloc (1 + strlen (prefix_symbols_string)
! 			     + strlen (name) + 1);
            if (add_leading_char)
  	    *ptr++ = bfd_get_symbol_leading_char (obfd);
  
*************** filter_symbols (abfd, obfd, osyms, isyms
*** 949,956 ****
  /* Find the redefined name of symbol SOURCE.  */
  
  static const char *
! lookup_sym_redefinition (source)
!      const char *source;
  {
    struct redefine_node *list;
  
--- 934,940 ----
  /* Find the redefined name of symbol SOURCE.  */
  
  static const char *
! lookup_sym_redefinition (const char *source)
  {
    struct redefine_node *list;
  
*************** lookup_sym_redefinition (source)
*** 964,973 ****
  /* Add a node to a symbol redefine list.  */
  
  static void
! redefine_list_append (cause, source, target)
!      const char *cause;
!      const char *source;
!      const char *target;
  {
    struct redefine_node **p;
    struct redefine_node *list;
--- 948,954 ----
  /* Add a node to a symbol redefine list.  */
  
  static void
! redefine_list_append (const char *cause, const char *source, const char *target)
  {
    struct redefine_node **p;
    struct redefine_node *list;
*************** redefine_list_append (cause, source, tar
*** 997,1008 ****
     from the file, and add them to the symbol redefine list.  */
  
  static void
! add_redefine_syms_file (filename)
!      const char *filename;
  {
    FILE *file;
    char *buf;
!   size_t bufsize, len, outsym_off;
    int c, lineno;
  
    file = fopen (filename, "r");
--- 978,990 ----
     from the file, and add them to the symbol redefine list.  */
  
  static void
! add_redefine_syms_file (const char *filename)
  {
    FILE *file;
    char *buf;
!   size_t bufsize;
!   size_t len;
!   size_t outsym_off;
    int c, lineno;
  
    file = fopen (filename, "r");
*************** add_redefine_syms_file (filename)
*** 1107,1115 ****
     Adjust *SIZE.  */
  
  static void
! filter_bytes (memhunk, size)
!      char *memhunk;
!      bfd_size_type *size;
  {
    char *from = memhunk + copy_byte, *to = memhunk, *end = memhunk + *size;
  
--- 1089,1095 ----
     Adjust *SIZE.  */
  
  static void
! filter_bytes (char *memhunk, bfd_size_type *size)
  {
    char *from = memhunk + copy_byte, *to = memhunk, *end = memhunk + *size;
  
*************** filter_bytes (memhunk, size)
*** 1125,1142 ****
  /* Copy object file IBFD onto OBFD.  */
  
  static void
! copy_object (ibfd, obfd)
!      bfd *ibfd;
!      bfd *obfd;
  {
    bfd_vma start;
    long symcount;
    asection **osections = NULL;
!   asection * gnu_debuglink_section = NULL;
    bfd_size_type *gaps = NULL;
    bfd_size_type max_gap = 0;
    long symsize;
!   PTR dhandle;
    enum bfd_architecture iarch;
    unsigned int imach;
  
--- 1105,1120 ----
  /* Copy object file IBFD onto OBFD.  */
  
  static void
! copy_object (bfd *ibfd, bfd *obfd)
  {
    bfd_vma start;
    long symcount;
    asection **osections = NULL;
!   asection *gnu_debuglink_section = NULL;
    bfd_size_type *gaps = NULL;
    bfd_size_type max_gap = 0;
    long symsize;
!   void *dhandle;
    enum bfd_architecture iarch;
    unsigned int imach;
  
*************** copy_object (ibfd, obfd)
*** 1232,1238 ****
  	  if (pset != NULL)
  	    {
  	      if (pset->change_vma != CHANGE_IGNORE)
! 		if (! bfd_set_section_vma (obfd, padd->section, pset->vma_val))
  		  RETURN_NONFATAL (bfd_get_filename (obfd));
  
  	      if (pset->change_lma != CHANGE_IGNORE)
--- 1210,1217 ----
  	  if (pset != NULL)
  	    {
  	      if (pset->change_vma != CHANGE_IGNORE)
! 		if (! bfd_set_section_vma (obfd, padd->section,
! 					   pset->vma_val))
  		  RETURN_NONFATAL (bfd_get_filename (obfd));
  
  	      if (pset->change_lma != CHANGE_IGNORE)
*************** copy_object (ibfd, obfd)
*** 1250,1262 ****
  
    if (gnu_debuglink_filename != NULL)
      {
!       gnu_debuglink_section = bfd_create_gnu_debuglink_section (obfd, gnu_debuglink_filename);
  
        if (gnu_debuglink_section == NULL)
- 	{
- 	  fprintf (stderr, "UGG\n");
  	RETURN_NONFATAL (gnu_debuglink_filename);
- 	}
      }
  
    if (gap_fill_set || pad_to_set)
--- 1229,1239 ----
  
    if (gnu_debuglink_filename != NULL)
      {
!       gnu_debuglink_section = bfd_create_gnu_debuglink_section
! 	(obfd, gnu_debuglink_filename);
  
        if (gnu_debuglink_section == NULL)
  	RETURN_NONFATAL (gnu_debuglink_filename);
      }
  
    if (gap_fill_set || pad_to_set)
*************** copy_object (ibfd, obfd)
*** 1386,1392 ****
        if (strip_symbols != STRIP_ALL)
  	bfd_map_over_sections (ibfd,
  			       mark_symbols_used_in_relocations,
! 			       (PTR)isympp);
        osympp = (asymbol **) xmalloc ((symcount + 1) * sizeof (asymbol *));
        symcount = filter_symbols (ibfd, obfd, osympp, isympp, symcount);
      }
--- 1363,1369 ----
        if (strip_symbols != STRIP_ALL)
  	bfd_map_over_sections (ibfd,
  			       mark_symbols_used_in_relocations,
! 			       (void *) isympp);
        osympp = (asymbol **) xmalloc ((symcount + 1) * sizeof (asymbol *));
        symcount = filter_symbols (ibfd, obfd, osympp, isympp, symcount);
      }
*************** copy_object (ibfd, obfd)
*** 1412,1418 ****
        for (padd = add_sections; padd != NULL; padd = padd->next)
  	{
  	  if (! bfd_set_section_contents (obfd, padd->section,
! 					  (PTR) padd->contents,
  					  (file_ptr) 0,
  					  (bfd_size_type) padd->size))
  	    RETURN_NONFATAL (bfd_get_filename (obfd));
--- 1389,1395 ----
        for (padd = add_sections; padd != NULL; padd = padd->next)
  	{
  	  if (! bfd_set_section_contents (obfd, padd->section,
! 					  (void *) padd->contents,
  					  (file_ptr) 0,
  					  (bfd_size_type) padd->size))
  	    RETURN_NONFATAL (bfd_get_filename (obfd));
*************** copy_object (ibfd, obfd)
*** 1423,1432 ****
      {
        if (! bfd_fill_in_gnu_debuglink_section
  	  (obfd, gnu_debuglink_section, gnu_debuglink_filename))
! 	{
! 	  fprintf (stderr, "UGG 2\n");
! 	  RETURN_NONFATAL (gnu_debuglink_filename);
! 	}
      }
  
    if (gap_fill_set || pad_to_set)
--- 1400,1406 ----
      {
        if (! bfd_fill_in_gnu_debuglink_section
  	  (obfd, gnu_debuglink_section, gnu_debuglink_filename))
! 	RETURN_NONFATAL (gnu_debuglink_filename);
      }
  
    if (gap_fill_set || pad_to_set)
*************** copy_object (ibfd, obfd)
*** 1510,1519 ****
     contents to temp file, and keep the temp file handle.  */
  
  static void
! copy_archive (ibfd, obfd, output_target)
!      bfd *ibfd;
!      bfd *obfd;
!      const char *output_target;
  {
    struct name_list
      {
--- 1484,1490 ----
     contents to temp file, and keep the temp file handle.  */
  
  static void
! copy_archive (bfd *ibfd, bfd *obfd, const char *output_target)
  {
    struct name_list
      {
*************** copy_archive (ibfd, obfd, output_target)
*** 1527,1536 ****
  
    /* Make a temp directory to hold the contents.  */
    if (MKDIR (dir, 0700) != 0)
!     {
!       fatal (_("cannot mkdir %s for archive copying (error: %s)"),
! 	     dir, strerror (errno));
!     }
    obfd->has_armap = ibfd->has_armap;
  
    list = NULL;
--- 1498,1506 ----
  
    /* Make a temp directory to hold the contents.  */
    if (MKDIR (dir, 0700) != 0)
!     fatal (_("cannot mkdir %s for archive copying (error: %s)"),
! 	   dir, strerror (errno));
! 
    obfd->has_armap = ibfd->has_armap;
  
    list = NULL;
*************** copy_archive (ibfd, obfd, output_target)
*** 1557,1566 ****
  	{
  	  output_name = make_tempname (output_name);
  	  if (MKDIR (output_name, 0700) != 0)
! 	    {
! 	      fatal (_("cannot mkdir %s for archive copying (error: %s)"),
! 		     output_name, strerror (errno));
! 	    }
  	  l = (struct name_list *) xmalloc (sizeof (struct name_list));
  	  l->name = output_name;
  	  l->next = list;
--- 1527,1535 ----
  	{
  	  output_name = make_tempname (output_name);
  	  if (MKDIR (output_name, 0700) != 0)
! 	    fatal (_("cannot mkdir %s for archive copying (error: %s)"),
! 		   output_name, strerror (errno));
! 
  	  l = (struct name_list *) xmalloc (sizeof (struct name_list));
  	  l->name = output_name;
  	  l->next = list;
*************** copy_archive (ibfd, obfd, output_target)
*** 1640,1650 ****
  /* The top-level control.  */
  
  static void
! copy_file (input_filename, output_filename, input_target, output_target)
!      const char *input_filename;
!      const char *output_filename;
!      const char *input_target;
!      const char *output_target;
  {
    bfd *ibfd;
    char **obj_matching;
--- 1609,1616 ----
  /* The top-level control.  */
  
  static void
! copy_file (const char *input_filename, const char *output_filename,
! 	   const char *input_target,   const char *output_target)
  {
    bfd *ibfd;
    char **obj_matching;
*************** copy_file (input_filename, output_filena
*** 1730,1739 ****
  /* Add a name to the section renaming list.  */
  
  static void
! add_section_rename (old_name, new_name, flags)
!      const char * old_name;
!      const char * new_name;
!      flagword flags;
  {
    section_rename * rename;
  
--- 1696,1703 ----
  /* Add a name to the section renaming list.  */
  
  static void
! add_section_rename (const char * old_name, const char * new_name,
! 		    flagword flags)
  {
    section_rename * rename;
  
*************** add_section_rename (old_name, new_name, 
*** 1764,1773 ****
     Also set RETURNED_FLAGS to the flags to be used for this section.  */
  
  static const char *
! find_section_rename (ibfd, isection, returned_flags)
!      bfd * ibfd ATTRIBUTE_UNUSED;
!      sec_ptr isection;
!      flagword * returned_flags;
  {
    const char * old_name = bfd_section_name (ibfd, isection);
    section_rename * rename;
--- 1728,1735 ----
     Also set RETURNED_FLAGS to the flags to be used for this section.  */
  
  static const char *
! find_section_rename (bfd * ibfd ATTRIBUTE_UNUSED, sec_ptr isection,
! 		     flagword * returned_flags)
  {
    const char * old_name = bfd_section_name (ibfd, isection);
    section_rename * rename;
*************** find_section_rename (ibfd, isection, ret
*** 1791,1800 ****
     name and attributes as ISECTION in IBFD.  */
  
  static void
! setup_section (ibfd, isection, obfdarg)
!      bfd *ibfd;
!      sec_ptr isection;
!      PTR obfdarg;
  {
    bfd *obfd = (bfd *) obfdarg;
    struct section_list *p;
--- 1753,1759 ----
     name and attributes as ISECTION in IBFD.  */
  
  static void
! setup_section (bfd *ibfd, sec_ptr isection, void *obfdarg)
  {
    bfd *obfd = (bfd *) obfdarg;
    struct section_list *p;
*************** setup_section (ibfd, isection, obfdarg)
*** 1818,1824 ****
    name = find_section_rename (ibfd, isection, & flags);
  
    /* Prefix sections.  */
!   if ((prefix_alloc_sections_string) && (bfd_get_section_flags (ibfd, isection) & SEC_ALLOC))
      prefix = prefix_alloc_sections_string;
    else if (prefix_sections_string)
      prefix = prefix_sections_string;
--- 1777,1784 ----
    name = find_section_rename (ibfd, isection, & flags);
  
    /* Prefix sections.  */
!   if ((prefix_alloc_sections_string)
!       && (bfd_get_section_flags (ibfd, isection) & SEC_ALLOC))
      prefix = prefix_alloc_sections_string;
    else if (prefix_sections_string)
      prefix = prefix_sections_string;
*************** loser:
*** 1935,1944 ****
     If stripping then don't copy any relocation info.  */
  
  static void
! copy_section (ibfd, isection, obfdarg)
!      bfd *ibfd;
!      sec_ptr isection;
!      PTR obfdarg;
  {
    bfd *obfd = (bfd *) obfdarg;
    struct section_list *p;
--- 1895,1901 ----
     If stripping then don't copy any relocation info.  */
  
  static void
! copy_section (bfd *ibfd, sec_ptr isection, void *obfdarg)
  {
    bfd *obfd = (bfd *) obfdarg;
    struct section_list *p;
*************** copy_section (ibfd, isection, obfdarg)
*** 2016,2022 ****
    if (bfd_get_section_flags (ibfd, isection) & SEC_HAS_CONTENTS
        && bfd_get_section_flags (obfd, osection) & SEC_HAS_CONTENTS)
      {
!       PTR memhunk = (PTR) xmalloc ((unsigned) size);
  
        if (!bfd_get_section_contents (ibfd, isection, memhunk, (file_ptr) 0,
  				     size))
--- 1973,1979 ----
    if (bfd_get_section_flags (ibfd, isection) & SEC_HAS_CONTENTS
        && bfd_get_section_flags (obfd, osection) & SEC_HAS_CONTENTS)
      {
!       void *memhunk = (void *) xmalloc ((unsigned) size);
  
        if (!bfd_get_section_contents (ibfd, isection, memhunk, (file_ptr) 0,
  				     size))
*************** copy_section (ibfd, isection, obfdarg)
*** 2033,2039 ****
      }
    else if (p != NULL && p->set_flags && (p->flags & SEC_HAS_CONTENTS) != 0)
      {
!       PTR memhunk = (PTR) xmalloc ((unsigned) size);
  
        /* We don't permit the user to turn off the SEC_HAS_CONTENTS
  	 flag--they can just remove the section entirely and add it
--- 1990,1996 ----
      }
    else if (p != NULL && p->set_flags && (p->flags & SEC_HAS_CONTENTS) != 0)
      {
!       void * memhunk = (void *) xmalloc ((unsigned) size);
  
        /* We don't permit the user to turn off the SEC_HAS_CONTENTS
  	 flag--they can just remove the section entirely and add it
*************** copy_section (ibfd, isection, obfdarg)
*** 2053,2062 ****
     used.  */
  
  static void
! get_sections (obfd, osection, secppparg)
!      bfd *obfd ATTRIBUTE_UNUSED;
!      asection *osection;
!      PTR secppparg;
  {
    asection ***secppp = (asection ***) secppparg;
  
--- 2010,2016 ----
     used.  */
  
  static void
! get_sections (bfd *obfd ATTRIBUTE_UNUSED, asection *osection, void *secppparg)
  {
    asection ***secppp = (asection ***) secppparg;
  
*************** get_sections (obfd, osection, secppparg)
*** 2069,2077 ****
     sections to the front, where they are easier to ignore.  */
  
  static int
! compare_section_lma (arg1, arg2)
!      const PTR arg1;
!      const PTR arg2;
  {
    const asection **sec1 = (const asection **) arg1;
    const asection **sec2 = (const asection **) arg2;
--- 2023,2029 ----
     sections to the front, where they are easier to ignore.  */
  
  static int
! compare_section_lma (const void *arg1, const void *arg2)
  {
    const asection **sec1 = (const asection **) arg1;
    const asection **sec2 = (const asection **) arg2;
*************** compare_section_lma (arg1, arg2)
*** 2115,2124 ****
     Ignore relocations which will not appear in the output file.  */
  
  static void
! mark_symbols_used_in_relocations (ibfd, isection, symbolsarg)
!      bfd *ibfd;
!      sec_ptr isection;
!      PTR symbolsarg;
  {
    asymbol **symbols = (asymbol **) symbolsarg;
    long relsize;
--- 2067,2073 ----
     Ignore relocations which will not appear in the output file.  */
  
  static void
! mark_symbols_used_in_relocations (bfd *ibfd, sec_ptr isection, void *symbolsarg)
  {
    asymbol **symbols = (asymbol **) symbolsarg;
    long relsize;
*************** mark_symbols_used_in_relocations (ibfd, 
*** 2158,2168 ****
  /* Write out debugging information.  */
  
  static bfd_boolean
! write_debugging_info (obfd, dhandle, symcountp, symppp)
!      bfd *obfd;
!      PTR dhandle;
!      long *symcountp ATTRIBUTE_UNUSED;
!      asymbol ***symppp ATTRIBUTE_UNUSED;
  {
    if (bfd_get_flavour (obfd) == bfd_target_ieee_flavour)
      return write_ieee_debugging_info (obfd, dhandle);
--- 2107,2115 ----
  /* Write out debugging information.  */
  
  static bfd_boolean
! write_debugging_info (bfd *obfd, void *dhandle,
! 		      long *symcountp ATTRIBUTE_UNUSED,
! 		      asymbol ***symppp ATTRIBUTE_UNUSED)
  {
    if (bfd_get_flavour (obfd) == bfd_target_ieee_flavour)
      return write_ieee_debugging_info (obfd, dhandle);
*************** write_debugging_info (obfd, dhandle, sym
*** 2226,2234 ****
  }
  
  static int
! strip_main (argc, argv)
!      int argc;
!      char *argv[];
  {
    char *input_target = NULL;
    char *output_target = NULL;
--- 2173,2179 ----
  }
  
  static int
! strip_main (int argc, char *argv[])
  {
    char *input_target = NULL;
    char *output_target = NULL;
*************** strip_main (argc, argv)
*** 2310,2320 ****
  	}
      }
  
!  if (formats_info)
!    {
!      display_info ();
!      return 0;
!    }
   
    if (show_version)
      print_version ("strip");
--- 2255,2265 ----
  	}
      }
  
!   if (formats_info)
!     {
!       display_info ();
!       return 0;
!     }
   
    if (show_version)
      print_version ("strip");
*************** strip_main (argc, argv)
*** 2373,2381 ****
  }
  
  static int
! copy_main (argc, argv)
!      int argc;
!      char *argv[];
  {
    char * binary_architecture = NULL;
    char *input_filename = NULL;
--- 2318,2324 ----
  }
  
  static int
! copy_main (int argc, char *argv[])
  {
    char * binary_architecture = NULL;
    char *input_filename = NULL;
*************** copy_main (argc, argv)
*** 2541,2547 ****
  	    f = fopen (pa->filename, FOPEN_RB);
  
  	    if (f == NULL)
! 	      fatal (_("cannot open: %s: %s"), pa->filename, strerror (errno));
  
  	    if (fread (pa->contents, 1, pa->size, f) == 0
  		|| ferror (f))
--- 2484,2491 ----
  	    f = fopen (pa->filename, FOPEN_RB);
  
  	    if (f == NULL)
! 	      fatal (_("cannot open: %s: %s"),
! 		     pa->filename, strerror (errno));
  
  	    if (fread (pa->contents, 1, pa->size, f) == 0
  		|| ferror (f))
*************** copy_main (argc, argv)
*** 2958,2969 ****
    return 0;
  }
  
- int main PARAMS ((int, char **));
- 
  int
! main (argc, argv)
!      int argc;
!      char *argv[];
  {
  #if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
    setlocale (LC_MESSAGES, "");
--- 2902,2909 ----
    return 0;
  }
  
  int
! main (int argc, char *argv[])
  {
  #if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
    setlocale (LC_MESSAGES, "");
        



More information about the Binutils mailing list