[ARC] Fixed issue with DTSOFF relocs.
[deliverable/binutils-gdb.git] / bfd / elf-properties.c
index 0ac055534d988b1811cffcb113a2b0ac4e979335..861db73170b8b0ef815025c9def67f503a9c93e1 100644 (file)
@@ -320,7 +320,12 @@ elf_get_gnu_property_section_size (elf_property_list *list,
   for (; list != NULL; list = list->next)
     {
       /* There are 4 byte type + 4 byte datasz for each property.  */
-      size += 4 + 4 + list->property.pr_datasz;
+      unsigned int datasz;
+      if (list->property.pr_type == GNU_PROPERTY_STACK_SIZE)
+       datasz = align_size;
+      else
+       datasz = list->property.pr_datasz;
+      size += 4 + 4 + datasz;
       /* Align each property.  */
       size = (size + (align_size - 1)) & ~(align_size - 1);
     }
@@ -336,6 +341,7 @@ elf_write_gnu_properties (bfd *abfd, bfd_byte *contents,
                          unsigned int align_size)
 {
   unsigned int descsz;
+  unsigned int datasz;
   Elf_External_Note *e_note;
 
   e_note = (Elf_External_Note *) contents;
@@ -350,17 +356,19 @@ elf_write_gnu_properties (bfd *abfd, bfd_byte *contents,
   for (; list != NULL; list = list->next)
     {
       /* There are 4 byte type + 4 byte datasz for each property.  */
-      bfd_h_put_32 (abfd, list->property.pr_type,
-                   contents + size);
-      bfd_h_put_32 (abfd, list->property.pr_datasz,
-                   contents + size + 4);
+      if (list->property.pr_type == GNU_PROPERTY_STACK_SIZE)
+       datasz = align_size;
+      else
+       datasz = list->property.pr_datasz;
+      bfd_h_put_32 (abfd, list->property.pr_type, contents + size);
+      bfd_h_put_32 (abfd, datasz, contents + size + 4);
       size += 4 + 4;
 
       /* Write out property value.  */
       switch (list->property.pr_kind)
        {
        case property_number:
-         switch (list->property.pr_datasz)
+         switch (datasz)
            {
            default:
              /* Never should happen.  */
@@ -385,7 +393,7 @@ elf_write_gnu_properties (bfd *abfd, bfd_byte *contents,
          /* Never should happen.  */
          abort ();
        }
-      size += list->property.pr_datasz;
+      size += datasz;
 
       /* Align each property.  */
       size = (size + (align_size - 1)) & ~ (align_size - 1);
@@ -480,7 +488,7 @@ _bfd_elf_link_setup_gnu_properties (struct bfd_link_info *info)
     {
       bfd_size_type size;
       bfd_byte *contents;
-      unsigned int align_size = bed->s->elfclass == ELFCLASS64 ? 8 : 4;
+      unsigned int align_size = elfclass == ELFCLASS64 ? 8 : 4;
 
       sec = bfd_get_section_by_name (first_pbfd,
                                     NOTE_GNU_PROPERTY_SECTION_NAME);
@@ -512,6 +520,18 @@ _bfd_elf_link_setup_gnu_properties (struct bfd_link_info *info)
          return NULL;
        }
 
+      /* Fix up GNU properties.  */
+      if (bed->fixup_gnu_properties)
+       bed->fixup_gnu_properties (info, &elf_properties (first_pbfd));
+
+      if (elf_properties (first_pbfd) == NULL)
+       {
+         /* Discard .note.gnu.property section if all properties have
+            been removed.  */
+         sec->output_section = bfd_abs_section_ptr;
+         return NULL;
+       }
+
       /* Compute the section size.  */
       list = elf_properties (first_pbfd);
       size = elf_get_gnu_property_section_size (list, align_size);
This page took 0.025322 seconds and 4 git commands to generate.