X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=binutils%2Fnlmconv.c;h=8cb4c814c74d9ddd557951f1202c436b45760406;hb=c2274b2767dba3175e585bd17f9f4a93b56cdc63;hp=8544ba0e4f99a415dae7072580f74f3a371d4f50;hpb=9d04d6183d792349aaab84ecb1338b9445c0981b;p=deliverable%2Fbinutils-gdb.git diff --git a/binutils/nlmconv.c b/binutils/nlmconv.c index 8544ba0e4f..8cb4c814c7 100644 --- a/binutils/nlmconv.c +++ b/binutils/nlmconv.c @@ -1,5 +1,6 @@ /* nlmconv.c -- NLM conversion program - Copyright (C) 1993, 94, 95, 96, 97, 1998 Free Software Foundation, Inc. + Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 + Free Software Foundation, Inc. This file is part of GNU Binutils. @@ -34,10 +35,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "bfd.h" #include "libiberty.h" #include "bucomm.h" +#include "safe-ctype.h" #include #include -#include #include #include #include @@ -55,7 +56,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* If strerror is just a macro, we want to use the one from libiberty since it will handle undefined values. */ #undef strerror -extern char *strerror (); +extern char *strerror PARAMS ((int)); #ifndef localtime extern struct tm *localtime (); @@ -210,6 +211,15 @@ main (argc, argv) char *modname; char **matching; +#if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES) + setlocale (LC_MESSAGES, ""); +#endif +#if defined (HAVE_SETLOCALE) + setlocale (LC_CTYPE, ""); +#endif + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + program_name = argv[0]; xmalloc_set_program_name (program_name); @@ -265,10 +275,7 @@ main (argc, argv) show_usage (stderr, 1); if (strcmp (input_file, output_file) == 0) { - fprintf (stderr, - _("%s: input and output files must be different\n"), - program_name); - exit (1); + fatal (_("input and output files must be different")); } } } @@ -315,10 +322,7 @@ main (argc, argv) { if (input_file != NULL) { - fprintf (stderr, - _("%s: input file named both on command line and with INPUT\n"), - program_name); - exit (1); + fatal (_("input file named both on command line and with INPUT")); } if (input_files->next == NULL) input_file = input_files->string; @@ -327,7 +331,7 @@ main (argc, argv) } else if (input_file == NULL) { - fprintf (stderr, _("%s: no input file\n"), program_name); + non_fatal (_("no input file")); show_usage (stderr, 1); } @@ -357,8 +361,7 @@ main (argc, argv) Otherwise use the file named in the OUTPUT statement. */ if (output_file == NULL) { - fprintf (stderr, _("%s: no name for output file\n"), - program_name); + non_fatal (_("no name for output file")); show_usage (stderr, 1); } @@ -371,9 +374,7 @@ main (argc, argv) assert (bfd_get_flavour (outbfd) == bfd_target_nlm_flavour); if (bfd_arch_get_compatible (inbfd, outbfd) == NULL) - fprintf (stderr, - _("%s: warning:input and output formats are not compatible\n"), - program_name); + non_fatal (_("warning: input and output formats are not compatible")); /* Move the values read from the command file into outbfd. */ *nlm_fixed_header (outbfd) = fixed_hdr_struct; @@ -628,9 +629,8 @@ main (argc, argv) } } if (l == NULL) - fprintf (stderr, - _("%s: warning: symbol %s imported but not in import list\n"), - program_name, bfd_asymbol_name (sym)); + non_fatal (_("warning: symbol %s imported but not in import list"), + bfd_asymbol_name (sym)); } /* See if it's one of the special named symbols. */ @@ -698,15 +698,11 @@ main (argc, argv) bfd_set_symtab (outbfd, outsyms, symcount + newsymcount); if (! gotstart) - fprintf (stderr, _("%s: warning: START procedure %s not defined\n"), - program_name, start_procedure); + non_fatal (_("warning: START procedure %s not defined"), start_procedure); if (! gotexit) - fprintf (stderr, _("%s: warning: EXIT procedure %s not defined\n"), - program_name, exit_procedure); - if (check_procedure != NULL - && ! gotcheck) - fprintf (stderr, _("%s: warning: CHECK procedure %s not defined\n"), - program_name, check_procedure); + non_fatal (_("warning: EXIT procedure %s not defined"), exit_procedure); + if (check_procedure != NULL && ! gotcheck) + non_fatal (_("warning: CHECK procedure %s not defined"), check_procedure); /* Add additional sections required for the header information. */ if (custom_file != NULL) @@ -842,9 +838,8 @@ main (argc, argv) if (sharedhdr.uninitializedDataSize > 0) { /* There is no place to record this information. */ - fprintf (stderr, - _("%s:%s: warning: shared libraries can not have uninitialized data\n"), - program_name, sharelib_file); + non_fatal (_("%s: warning: shared libraries can not have uninitialized data"), + sharelib_file); } shared_offset = st.st_size; if (shared_offset > (size_t) sharedhdr.codeImageOffset) @@ -872,8 +867,7 @@ main (argc, argv) /* Check whether a version was given. */ if (strncmp (version_hdr->stamp, "VeRsIoN#", 8) != 0) - fprintf (stderr, _("%s: warning: No version number given\n"), - program_name); + non_fatal (_("warning: No version number given")); /* At least for now, always create an extended header, because that is what NLMLINK does. */ @@ -913,8 +907,7 @@ main (argc, argv) data = xmalloc (custom_size); if (fread (data, 1, custom_size, custom_data) != custom_size) - fprintf (stderr, _("%s:%s: read: %s\n"), program_name, custom_file, - strerror (errno)); + non_fatal (_("%s: read: %s"), custom_file, strerror (errno)); else { if (! bfd_set_section_contents (outbfd, custom_section, data, @@ -936,17 +929,14 @@ main (argc, argv) nlm_fixed_header (outbfd)->debugInfoOffset = (file_ptr) -1; } if (map_file != NULL) - fprintf (stderr, - _("%s: warning: MAP and FULLMAP are not supported; try ld -M\n"), - program_name); + non_fatal (_("warning: MAP and FULLMAP are not supported; try ld -M")); if (help_file != NULL) { PTR data; data = xmalloc (help_size); if (fread (data, 1, help_size, help_data) != help_size) - fprintf (stderr, _("%s:%s: read: %s\n"), program_name, help_file, - strerror (errno)); + non_fatal (_("%s: read: %s"), help_file, strerror (errno)); else { if (! bfd_set_section_contents (outbfd, help_section, data, @@ -964,8 +954,7 @@ main (argc, argv) data = xmalloc (message_size); if (fread (data, 1, message_size, message_data) != message_size) - fprintf (stderr, _("%s:%s: read: %s\n"), program_name, message_file, - strerror (errno)); + non_fatal (_("%s: read: %s"), message_file, strerror (errno)); else { if (! bfd_set_section_contents (outbfd, message_section, data, @@ -1014,8 +1003,7 @@ main (argc, argv) data = xmalloc (rpc_size); if (fread (data, 1, rpc_size, rpc_data) != rpc_size) - fprintf (stderr, _("%s:%s: read: %s\n"), program_name, rpc_file, - strerror (errno)); + non_fatal (_("%s: read: %s"), rpc_file, strerror (errno)); else { if (! bfd_set_section_contents (outbfd, rpc_section, data, @@ -1034,8 +1022,7 @@ main (argc, argv) data = xmalloc (shared_size); if (fseek (shared_data, shared_offset, SEEK_SET) != 0 || fread (data, 1, shared_size, shared_data) != shared_size) - fprintf (stderr, _("%s:%s: read: %s\n"), program_name, sharelib_file, - strerror (errno)); + non_fatal (_("%s: read: %s"), sharelib_file, strerror (errno)); else { if (! bfd_set_section_contents (outbfd, shared_section, data, @@ -1087,8 +1074,7 @@ main (argc, argv) for (modname = nlm_fixed_header (outbfd)->moduleName; *modname != '\0'; modname++) - if (islower ((unsigned char) *modname)) - *modname = toupper (*modname); + *modname = TOUPPER (*modname); strncpy (nlm_variable_header (outbfd)->oldThreadName, " LONG", NLM_OLD_THREAD_NAME_LENGTH); @@ -1132,7 +1118,7 @@ Usage: %s [-dhV] [-I bfdname] [-O bfdname] [-T header-file] [-l linker]\n\ [in-file [out-file]]\n"), program_name); if (status == 0) - fprintf (file, _("Report bugs to bug-gnu-utils@gnu.org\n")); + fprintf (file, _("Report bugs to %s\n"), REPORT_BUGS_TO); exit (status); } @@ -1143,7 +1129,7 @@ static const char * select_output_format (arch, mach, bigendian) enum bfd_architecture arch; unsigned long mach; - boolean bigendian; + boolean bigendian ATTRIBUTE_UNUSED; { switch (arch) { @@ -1164,11 +1150,8 @@ select_output_format (arch, mach, bigendian) return "nlm32-powerpc"; #endif default: - fprintf (stderr, _("%s: support not compiled in for %s\n"), - program_name, bfd_printable_arch_mach (arch, mach)); - exit (1); - /* Avoid warning. */ - return NULL; + fatal (_("support not compiled in for %s"), + bfd_printable_arch_mach (arch, mach)); } /*NOTREACHED*/ } @@ -1179,7 +1162,7 @@ select_output_format (arch, mach, bigendian) static void setup_sections (inbfd, insec, data_ptr) - bfd *inbfd; + bfd *inbfd ATTRIBUTE_UNUSED; asection *insec; PTR data_ptr; { @@ -1403,12 +1386,12 @@ mangle_relocs (outbfd, insec, relocs_ptr, reloc_count_ptr, contents, static void default_mangle_relocs (outbfd, insec, relocs_ptr, reloc_count_ptr, contents, contents_size) - bfd *outbfd; + bfd *outbfd ATTRIBUTE_UNUSED; asection *insec; arelent ***relocs_ptr; long *reloc_count_ptr; - char *contents; - bfd_size_type contents_size; + char *contents ATTRIBUTE_UNUSED; + bfd_size_type contents_size ATTRIBUTE_UNUSED; { if (insec->output_offset != 0) { @@ -1612,8 +1595,8 @@ alpha_mangle_relocs (outbfd, insec, relocs_ptr, reloc_count_ptr, contents, asection *insec; register arelent ***relocs_ptr; long *reloc_count_ptr; - char *contents; - bfd_size_type contents_size; + char *contents ATTRIBUTE_UNUSED; + bfd_size_type contents_size ATTRIBUTE_UNUSED; { long old_reloc_count; arelent **old_relocs; @@ -1745,7 +1728,7 @@ static bfd_size_type powerpc_initial_got_size; static void powerpc_build_stubs (inbfd, outbfd, symbols_ptr, symcount_ptr) bfd *inbfd; - bfd *outbfd; + bfd *outbfd ATTRIBUTE_UNUSED; asymbol ***symbols_ptr; long *symcount_ptr; { @@ -1934,7 +1917,7 @@ powerpc_mangle_relocs (outbfd, insec, relocs_ptr, reloc_count_ptr, contents, register arelent ***relocs_ptr; long *reloc_count_ptr; char *contents; - bfd_size_type contents_size; + bfd_size_type contents_size ATTRIBUTE_UNUSED; { reloc_howto_type *toc_howto; long reloc_count; @@ -1994,8 +1977,8 @@ powerpc_mangle_relocs (outbfd, insec, relocs_ptr, reloc_count_ptr, contents, between two sections both of which were placed in the same output section. This should not happen. */ if (bfd_get_section (sym) != insec->output_section) - fprintf (stderr, _("%s: unresolved PC relative reloc against %s\n"), - program_name, bfd_asymbol_name (sym)); + non_fatal (_("unresolved PC relative reloc against %s"), + bfd_asymbol_name (sym)); else { bfd_vma val; @@ -2058,9 +2041,8 @@ powerpc_mangle_relocs (outbfd, insec, relocs_ptr, reloc_count_ptr, contents, & rel->howto->dst_mask)); if ((bfd_signed_vma) val < - 0x8000 || (bfd_signed_vma) val >= 0x8000) - fprintf (stderr, - _("%s: overflow when adjusting relocation against %s\n"), - program_name, bfd_asymbol_name (sym)); + non_fatal (_("overflow when adjusting relocation against %s"), + bfd_asymbol_name (sym)); bfd_put_16 (outbfd, val, (bfd_byte *) contents + rel->address); break; @@ -2106,9 +2088,6 @@ powerpc_mangle_relocs (outbfd, insec, relocs_ptr, reloc_count_ptr, contents, #define LD_NAME "ld" #endif -/* Temporary file name base. */ -static char *temp_filename; - /* The user has specified several input files. Invoke the linker to link them all together, and convert and delete the resulting output file. */ @@ -2157,10 +2136,7 @@ link_inputs (inputs, ld) if (ld == NULL) ld = (char *) LD_NAME; - temp_filename = choose_temp_base (); - - unlink_on_exit = xmalloc (strlen (temp_filename) + 3); - sprintf (unlink_on_exit, "%s.O", temp_filename); + unlink_on_exit = make_temp_file (".O"); argv[0] = ld; argv[1] = (char *) "-Ur"; @@ -2197,7 +2173,7 @@ link_inputs (inputs, ld) if (status != 0) { - fprintf (stderr, _("%s: Execution of %s failed\n"), program_name, ld); + non_fatal (_("Execution of %s failed"), ld); unlink (unlink_on_exit); exit (1); }