* ecoff.c (ecoff_find_nearest_line): Handle fdr.adr != pdr.adr
[binutils-gdb.git] / bfd / ecoff.c
index ce4d5f6c6f75a8655ed391281a12bedfb060eb23..83a3c22d89c602ed10bcf82c30b0e18d35344af1 100644 (file)
@@ -174,7 +174,7 @@ ecoff_new_section_hook (abfd, section)
   else if (strcmp (section->name, _LIB) == 0)
     {
       /* An Irix 4 shared libary.  */
-      section->flags |= SEC_SHARED_LIBRARY;
+      section->flags |= SEC_COFF_SHARED_LIBRARY;
     }
 
   /* Probably any other section name is SEC_NEVER_LOAD, but I'm
@@ -356,7 +356,7 @@ ecoff_styp_to_sec_flags (abfd, hdr)
       || (styp_flags & STYP_ECOFF_FINI))
     {
       if (sec_flags & SEC_NEVER_LOAD)
-       sec_flags |= SEC_CODE | SEC_SHARED_LIBRARY;
+       sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
       else
        sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
     }
@@ -367,7 +367,7 @@ ecoff_styp_to_sec_flags (abfd, hdr)
           || styp_flags == STYP_XDATA)
     {
       if (sec_flags & SEC_NEVER_LOAD)
-       sec_flags |= SEC_DATA | SEC_SHARED_LIBRARY;
+       sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
       else
        sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
       if ((styp_flags & STYP_RDATA)
@@ -391,7 +391,7 @@ ecoff_styp_to_sec_flags (abfd, hdr)
     }
   else if (styp_flags & STYP_ECOFF_LIB)
     {
-      sec_flags |= SEC_SHARED_LIBRARY;
+      sec_flags |= SEC_COFF_SHARED_LIBRARY;
     }
   else
     {
@@ -2007,6 +2007,7 @@ ecoff_find_nearest_line (abfd,
   char *pdr_ptr;
   char *pdr_end;
   PDR pdr;
+  bfd_vma first_off;
   unsigned char *line_ptr;
   unsigned char *line_end;
   int lineno;
@@ -2052,10 +2053,12 @@ ecoff_find_nearest_line (abfd,
             + fdr_ptr->ipdFirst * external_pdr_size);
   pdr_end = pdr_ptr + fdr_ptr->cpd * external_pdr_size;
   (*debug_swap->swap_pdr_in) (abfd, (PTR) pdr_ptr, &pdr);
+  if (offset < pdr.adr)
+    return false;
 
   /* The address of the first PDR is an offset which applies to the
      addresses of all the PDR's.  */
-  offset += pdr.adr;
+  first_off = pdr.adr;
 
   for (pdr_ptr += external_pdr_size;
        pdr_ptr < pdr_end;
@@ -2080,7 +2083,7 @@ ecoff_find_nearest_line (abfd,
   pdr_ptr -= external_pdr_size;
   (*debug_swap->swap_pdr_in) (abfd, (PTR) pdr_ptr, &pdr);
 
-  offset -= pdr.adr;
+  offset -= pdr.adr - first_off;
   lineno = pdr.lnLow;
   line_ptr = (ecoff_data (abfd)->debug_info.line
              + fdr_ptr->cbLineOffset