Add support for parallel instructions.
[deliverable/binutils-gdb.git] / bfd / elf.c
index 7b1d196de5183eb17b8fa2b294f7660ee70a06f1..ab9d7575faac3cccd831bda364fb19d35a9c0d1e 100644 (file)
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -2124,13 +2124,6 @@ map_sections_to_segments (abfd)
              skip a page in the segment, then we need a new segment.  */
          new_segment = true;
        }
-      else if ((abfd->flags & D_PAGED) == 0)
-       {
-         /* If the file is not demand paged, which means that we
-             don't require the sections to be correctly aligned in the
-             file, then there is no other reason for a new segment.  */
-         new_segment = false;
-       }
       else if ((last_hdr->flags & SEC_LOAD) == 0
               && (hdr->flags & SEC_LOAD) != 0)
        {
@@ -2138,6 +2131,13 @@ map_sections_to_segments (abfd)
              nonloadable section in the same segment.  */
          new_segment = true;
        }
+      else if ((abfd->flags & D_PAGED) == 0)
+       {
+         /* If the file is not demand paged, which means that we
+             don't require the sections to be correctly aligned in the
+             file, then there is no other reason for a new segment.  */
+         new_segment = false;
+       }
       else if (! writable
               && (hdr->flags & SEC_READONLY) == 0
               && (BFD_ALIGN (last_hdr->lma + last_hdr->_raw_size, maxpagesize)
@@ -2431,6 +2431,15 @@ assign_file_positions_for_segments (abfd)
          if (m->count > 0)
            {
              BFD_ASSERT (p->p_type == PT_LOAD);
+
+             if (p->p_vaddr < off)
+               {
+                 _bfd_error_handler ("%s: Not enough room for program headers, try linking with -N",
+                                     bfd_get_filename (abfd));
+                 bfd_set_error (bfd_error_bad_value);
+                 return false;
+               }
+             
              p->p_vaddr -= off;
              if (! m->p_paddr_valid)
                p->p_paddr -= off;
@@ -2503,29 +2512,40 @@ assign_file_positions_for_segments (abfd)
            {
              bfd_vma adjust;
 
-             /* The section VMA must equal the file position modulo
-                 the page size.  */
-             if ((flags & SEC_ALLOC) != 0)
+             if ((flags & SEC_LOAD) != 0)
+               adjust = sec->lma - (p->p_paddr + p->p_memsz);
+             else if ((flags & SEC_ALLOC) != 0)
                {
+                 /* The section VMA must equal the file position
+                    modulo the page size.  FIXME: I'm not sure if
+                    this adjustment is really necessary.  We used to
+                    not have the SEC_LOAD case just above, and then
+                    this was necessary, but now I'm not sure.  */
                  if ((abfd->flags & D_PAGED) != 0)
                    adjust = (sec->vma - voff) % bed->maxpagesize;
                  else
                    adjust = (sec->vma - voff) % align;
-                 if (adjust != 0)
-                   {
-                     if (i == 0)
-                       abort ();
-                     p->p_memsz += adjust;
-                     off += adjust;
-                     voff += adjust;
-                     if ((flags & SEC_LOAD) != 0)
-                       p->p_filesz += adjust;
-                   }
+               }
+
+             if (adjust != 0)
+               {
+                 if (i == 0)
+                   abort ();
+                 p->p_memsz += adjust;
+                 off += adjust;
+                 voff += adjust;
+                 if ((flags & SEC_LOAD) != 0)
+                   p->p_filesz += adjust;
                }
 
              sec->filepos = off;
 
-             if ((flags & SEC_LOAD) != 0)
+             /* We check SEC_HAS_CONTENTS here because if NOLOAD is
+                 used in a linker script we may have a section with
+                 SEC_LOAD clear but which is supposed to have
+                 contents.  */
+             if ((flags & SEC_LOAD) != 0
+                 || (flags & SEC_HAS_CONTENTS) != 0)
                off += sec->_raw_size;
              if ((flags & SEC_ALLOC) != 0)
                voff += sec->_raw_size;
@@ -2870,21 +2890,13 @@ prep_headers (abfd)
       i_ehdrp->e_machine = EM_CYGNUS_D30V;
       break;
 /* end-sanitize-d30v */
-/* start-sanitize-v850 */
     case bfd_arch_v850:
       switch (bfd_get_mach (abfd))
        {
        default:
        case 0:               i_ehdrp->e_machine = EM_CYGNUS_V850; break;
-/* start-sanitize-v850e */
-       case bfd_mach_v850e:  i_ehdrp->e_machine = EM_CYGNUS_V850E; break;
-/* end-sanitize-v850e */
-/* start-sanitize-v850eq */
-       case bfd_mach_v850eq: i_ehdrp->e_machine = EM_CYGNUS_V850EQ; break;
-/* end-sanitize-v850eq */
        }
       break;
-/* end-sanitize-v850 */
    case bfd_arch_arc:
       i_ehdrp->e_machine = EM_CYGNUS_ARC;
       break;
@@ -2897,6 +2909,11 @@ prep_headers (abfd)
     case bfd_arch_mn10300:
       i_ehdrp->e_machine = EM_CYGNUS_MN10300;
       break;
+/* start-sanitize-sky */
+    case bfd_arch_txvu:
+      i_ehdrp->e_machine = EM_CYGNUS_TXVU;
+      break;
+/* end-sanitize-sky */
       /* also note that EM_M32, AT&T WE32100 is unknown to bfd */
     default:
       i_ehdrp->e_machine = EM_NONE;
@@ -4002,6 +4019,11 @@ _bfd_elf_find_nearest_line (abfd,
   bfd_vma low_func;
   asymbol **p;
 
+  if (_bfd_dwarf2_find_nearest_line (abfd, section, symbols, offset,
+                                    filename_ptr, functionname_ptr, 
+                                    line_ptr))
+    return true;
+
   if (! _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset,
                                             &found, filename_ptr,
                                             functionname_ptr, line_ptr,
This page took 0.024983 seconds and 4 git commands to generate.