Accept 16-bit addresses.
[deliverable/binutils-gdb.git] / binutils / addr2line.c
index 7a55df3e97771ce38a1196d306490c9d9df38315..72707c20bbb6cc871e293e8ab63311112f81687e 100644 (file)
@@ -1,5 +1,5 @@
 /* addr2line.c -- convert addresses to line number and function name
-   Copyright 1997, 1998 Free Software Foundation, Inc.
+   Copyright 1997, 1998, 1999 Free Software Foundation, Inc.
    Contributed by Ulrich Lauther <Ulrich.Lauther@zfe.siemens.de>
 
    This file is part of GNU Binutils.
@@ -123,9 +123,10 @@ static void
 find_address_in_section (abfd, section, data)
      bfd *abfd;
      asection *section;
-     PTR data;
+     PTR data ATTRIBUTE_UNUSED;
 {
   bfd_vma vma;
+  bfd_size_type size;
 
   if (found)
     return;
@@ -137,6 +138,10 @@ find_address_in_section (abfd, section, data)
   if (pc < vma)
     return;
 
+  size = bfd_get_section_size_before_reloc (section);
+  if (pc >= vma + size)
+    return;
+
   found = bfd_find_nearest_line (abfd, section, syms, pc - vma,
                                 &filename, &functionname, &line);
 }
@@ -181,7 +186,7 @@ translate_addresses (abfd)
        {
          if (with_functions)
            {
-             if (*functionname == '\0')
+             if (functionname == NULL || *functionname == '\0')
                printf ("??\n");
              else if (! do_demangle)
                printf ("%s\n", functionname);
@@ -200,7 +205,7 @@ translate_addresses (abfd)
                }
            }
 
-         if (base_names)
+         if (base_names && filename != NULL)
            {
              char *h;
 
@@ -209,7 +214,7 @@ translate_addresses (abfd)
                filename = h + 1;
            }
 
-         printf ("%s:%u\n", filename, line);
+         printf ("%s:%u\n", filename ? filename : "??", line);
        }
 
       /* fflush() is essential for using this command as a server
@@ -270,7 +275,9 @@ main (argc, argv)
   char *target;
   int c;
 
+#if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
   setlocale (LC_MESSAGES, "");
+#endif
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
This page took 0.025049 seconds and 4 git commands to generate.