Inconsistent .eh_frame_hdr on powerpc64
[deliverable/binutils-gdb.git] / bfd / elf-properties.c
index 13d620d9c47478e7906eecda22422b4d8568571d..bfb106edc92d1f80035f40ac32e419a9f495ee98 100644 (file)
@@ -93,15 +93,20 @@ bad_size:
       return FALSE;
     }
 
-  while (1)
+  while (ptr != ptr_end)
     {
-      unsigned int type = bfd_h_get_32 (abfd, ptr);
-      unsigned int datasz = bfd_h_get_32 (abfd, ptr + 4);
+      unsigned int type;
+      unsigned int datasz;
       elf_property *prop;
 
+      if ((size_t) (ptr_end - ptr) < 8)
+       goto bad_size;
+
+      type = bfd_h_get_32 (abfd, ptr);
+      datasz = bfd_h_get_32 (abfd, ptr + 4);
       ptr += 8;
 
-      if ((ptr + datasz) > ptr_end)
+      if (datasz > (size_t) (ptr_end - ptr))
        {
          _bfd_error_handler
            (_("warning: %B: corrupt GNU_PROPERTY_TYPE (%ld) type (0x%x) datasz: 0x%x"),
@@ -168,6 +173,7 @@ bad_size:
                  return FALSE;
                }
              prop = _bfd_elf_get_property (abfd, type, datasz);
+             elf_has_no_copy_on_protected (abfd) = TRUE;
              prop->pr_kind = property_number;
              goto next;
 
@@ -182,11 +188,6 @@ bad_size:
 
 next:
       ptr += (datasz + (align_size - 1)) & ~ (align_size - 1);
-      if (ptr == ptr_end)
-       break;
-
-      if (ptr > (ptr_end - 8))
-       goto bad_size;
     }
 
   return TRUE;
@@ -290,6 +291,9 @@ elf_merge_gnu_property_list (struct bfd_link_info *info, bfd *abfd,
   for (p = *listp; p != NULL; p = p->next)
     if (elf_merge_gnu_properties (info, abfd, NULL, &p->property))
       {
+       if (p->property.pr_type == GNU_PROPERTY_NO_COPY_ON_PROTECTED)
+         elf_has_no_copy_on_protected (abfd) = TRUE;
+
        pr = _bfd_elf_get_property (abfd, p->property.pr_type,
                                    p->property.pr_datasz);
        /* It must be a new property.  */
@@ -489,6 +493,11 @@ _bfd_elf_link_setup_gnu_properties (struct bfd_link_info *info)
 
       /* Cache the section contents for elf_link_input_bfd.  */
       elf_section_data (sec)->this_hdr.contents = contents;
+
+      /* If GNU_PROPERTY_NO_COPY_ON_PROTECTED is set, protected data
+        symbol is defined in the shared object.  */
+      if (elf_has_no_copy_on_protected (first_pbfd))
+       info->extern_protected_data = FALSE;
     }
 
   return first_pbfd;
This page took 0.02563 seconds and 4 git commands to generate.