Correct last entry: s/SYMBOL/TABLE_/
[deliverable/binutils-gdb.git] / bfd / elf.c
index 2b73cde4ebc04e7f867a8d31326da8fb5799c231..b7674e316e68e2d6bb604e4dc943e984e73b133b 100644 (file)
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -1739,6 +1739,7 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
     case SHT_INIT_ARRAY:       /* .init_array section.  */
     case SHT_FINI_ARRAY:       /* .fini_array section.  */
     case SHT_PREINIT_ARRAY:    /* .preinit_array section.  */
+    case SHT_GNU_LIBLIST:      /* .gnu.liblist section.  */
       return _bfd_elf_make_section_from_shdr (abfd, hdr, name);
 
     case SHT_DYNAMIC:  /* Dynamic linking information.  */
@@ -2132,6 +2133,8 @@ static struct bfd_elf_special_section const special_sections[] =
   { ".rela",           5, -1, SHT_RELA,     0 },
   { ".rel",            4, -1, SHT_REL,      0 },
   { ".stabstr",        5,  3, SHT_STRTAB,   0 },
+  { ".gnu.liblist",   12,  0, SHT_GNU_LIBLIST, SHF_ALLOC },
+  { ".gnu.conflict",  13,  0, SHT_RELA,     SHF_ALLOC },
   { NULL,              0,  0, 0,            0 }
 };
 
@@ -2969,6 +2972,17 @@ assign_section_numbers (bfd *abfd)
            d->this_hdr.sh_link = elf_section_data (s)->this_idx;
          break;
 
+       case SHT_GNU_LIBLIST:
+         /* sh_link is the section header index of the prelink library
+            list 
+            used for the dynamic entries, or the symbol table, or the
+            version strings.  */
+         s = bfd_get_section_by_name (abfd, (sec->flags & SEC_ALLOC)
+                                            ? ".dynstr" : ".gnu.libstr");
+         if (s != NULL)
+           d->this_hdr.sh_link = elf_section_data (s)->this_idx;
+         break;
+
        case SHT_HASH:
        case SHT_GNU_versym:
          /* sh_link is the section header index of the symbol table
@@ -3787,12 +3801,6 @@ vma_page_aligned_bias (bfd_vma vma, ufile_ptr off, bfd_vma maxpagesize)
   return ((vma - off) % maxpagesize);
 }
 
-/* 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.  */
-#define IS_LOADED(FLAGS) \
-  (((FLAGS) & SEC_LOAD) != 0 || ((FLAGS) & SEC_HAS_CONTENTS) != 0)
-
 /* Assign file positions to the sections based on the mapping from
    sections to segments.  This function also sets up some fields in
    the file header, and writes out the program headers.  */
@@ -3959,7 +3967,7 @@ assign_file_positions_for_segments (bfd *abfd, struct bfd_link_info *link_info)
                 .tbss, we need to look at the next section to decide
                 whether the segment has any loadable sections.  */
              i = 0;
-             while (!IS_LOADED (m->sections[i]->flags))
+             while ((m->sections[i]->flags & SEC_LOAD) == 0)
                {
                  if ((m->sections[i]->flags & SEC_THREAD_LOCAL) == 0
                      || ++i >= m->count)
@@ -4107,7 +4115,7 @@ assign_file_positions_for_segments (bfd *abfd, struct bfd_link_info *link_info)
            {
              bfd_signed_vma adjust;
 
-             if (IS_LOADED (flags))
+             if ((flags & SEC_LOAD) != 0)
                {
                  adjust = sec->lma - (p->p_paddr + p->p_filesz);
                  if (adjust < 0)
@@ -4164,11 +4172,26 @@ assign_file_positions_for_segments (bfd *abfd, struct bfd_link_info *link_info)
              if (p->p_type == PT_LOAD)
                {
                  sec->filepos = off;
-                 if (IS_LOADED (flags))
+                 /* FIXME: The SEC_HAS_CONTENTS test here dates back to
+                    1997, and the exact reason for it isn't clear.  One
+                    plausible explanation is that it is to work around
+                    a problem we have with linker scripts using data
+                    statements in NOLOAD sections.  I don't think it
+                    makes a great deal of sense to have such a section
+                    assigned to a PT_LOAD segment, but apparently
+                    people do this.  The data statement results in a
+                    bfd_data_link_order being built, and these need
+                    section contents to write into.  Eventually, we get
+                    to _bfd_elf_write_object_contents which writes any
+                    section with contents to the output.  Make room
+                    here for the write, so that following segments are
+                    not trashed.  */
+                 if ((flags & SEC_LOAD) != 0
+                     || (flags & SEC_HAS_CONTENTS) != 0)
                    off += sec->size;
                }
 
-             if (IS_LOADED (flags))
+             if ((flags & SEC_LOAD) != 0)
                {
                  p->p_filesz += sec->size;
                  p->p_memsz += sec->size;
@@ -6295,9 +6318,6 @@ elf_find_function (bfd *abfd ATTRIBUTE_UNUSED,
 
       q = (elf_symbol_type *) *p;
 
-      if (bfd_get_section (&q->symbol) != section)
-       continue;
-
       switch (ELF_ST_TYPE (q->internal_elf_sym.st_info))
        {
        default:
@@ -6307,7 +6327,7 @@ elf_find_function (bfd *abfd ATTRIBUTE_UNUSED,
          break;
        case STT_NOTYPE:
        case STT_FUNC:
-         if (q->symbol.section == section
+         if (bfd_get_section (&q->symbol) == section
              && q->symbol.value >= low_func
              && q->symbol.value <= offset)
            {
@@ -7726,7 +7746,7 @@ _bfd_elf_rel_local_sym (bfd *abfd,
 
 bfd_vma
 _bfd_elf_section_offset (bfd *abfd,
-                        struct bfd_link_info *info ATTRIBUTE_UNUSED,
+                        struct bfd_link_info *info,
                         asection *sec,
                         bfd_vma offset)
 {
@@ -7736,7 +7756,7 @@ _bfd_elf_section_offset (bfd *abfd,
       return _bfd_stab_section_offset (sec, elf_section_data (sec)->sec_info,
                                       offset);
     case ELF_INFO_TYPE_EH_FRAME:
-      return _bfd_elf_eh_frame_section_offset (abfd, sec, offset);
+      return _bfd_elf_eh_frame_section_offset (abfd, info, sec, offset);
     default:
       return offset;
     }
This page took 0.025111 seconds and 4 git commands to generate.