1 /* ELF program property support.
2 Copyright (C) 2017-2022 Free Software Foundation, Inc.
4 This file is part of BFD, the Binary File Descriptor library.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19 MA 02110-1301, USA. */
21 /* GNU program property draft is at:
23 https://github.com/hjl-tools/linux-abi/wiki/property-draft.pdf
31 /* Get a property, allocate a new one if needed. */
34 _bfd_elf_get_property (bfd
*abfd
, unsigned int type
, unsigned int datasz
)
36 elf_property_list
*p
, **lastp
;
38 if (bfd_get_flavour (abfd
) != bfd_target_elf_flavour
)
40 /* Never should happen. */
44 /* Keep the property list in order of type. */
45 lastp
= &elf_properties (abfd
);
46 for (p
= *lastp
; p
; p
= p
->next
)
48 /* Reuse the existing entry. */
49 if (type
== p
->property
.pr_type
)
51 if (datasz
> p
->property
.pr_datasz
)
53 /* This can happen when mixing 32-bit and 64-bit objects. */
54 p
->property
.pr_datasz
= datasz
;
58 else if (type
< p
->property
.pr_type
)
62 p
= (elf_property_list
*) bfd_alloc (abfd
, sizeof (*p
));
65 _bfd_error_handler (_("%pB: out of memory in _bfd_elf_get_property"),
69 memset (p
, 0, sizeof (*p
));
70 p
->property
.pr_type
= type
;
71 p
->property
.pr_datasz
= datasz
;
77 /* Parse GNU properties. */
80 _bfd_elf_parse_gnu_properties (bfd
*abfd
, Elf_Internal_Note
*note
)
82 const struct elf_backend_data
*bed
= get_elf_backend_data (abfd
);
83 unsigned int align_size
= bed
->s
->elfclass
== ELFCLASS64
? 8 : 4;
84 bfd_byte
*ptr
= (bfd_byte
*) note
->descdata
;
85 bfd_byte
*ptr_end
= ptr
+ note
->descsz
;
87 if (note
->descsz
< 8 || (note
->descsz
% align_size
) != 0)
91 (_("warning: %pB: corrupt GNU_PROPERTY_TYPE (%ld) size: %#lx"),
92 abfd
, note
->type
, note
->descsz
);
96 while (ptr
!= ptr_end
)
102 if ((size_t) (ptr_end
- ptr
) < 8)
105 type
= bfd_h_get_32 (abfd
, ptr
);
106 datasz
= bfd_h_get_32 (abfd
, ptr
+ 4);
109 if (datasz
> (size_t) (ptr_end
- ptr
))
112 (_("warning: %pB: corrupt GNU_PROPERTY_TYPE (%ld) type (0x%x) datasz: 0x%x"),
113 abfd
, note
->type
, type
, datasz
);
114 /* Clear all properties. */
115 elf_properties (abfd
) = NULL
;
119 if (type
>= GNU_PROPERTY_LOPROC
)
121 if (bed
->elf_machine_code
== EM_NONE
)
123 /* Ignore processor-specific properties with generic ELF
124 target vector. They should be handled by the matching
125 ELF target vector. */
128 else if (type
< GNU_PROPERTY_LOUSER
129 && bed
->parse_gnu_properties
)
131 enum elf_property_kind kind
132 = bed
->parse_gnu_properties (abfd
, type
, ptr
, datasz
);
133 if (kind
== property_corrupt
)
135 /* Clear all properties. */
136 elf_properties (abfd
) = NULL
;
139 else if (kind
!= property_ignored
)
147 case GNU_PROPERTY_STACK_SIZE
:
148 if (datasz
!= align_size
)
151 (_("warning: %pB: corrupt stack size: 0x%x"),
153 /* Clear all properties. */
154 elf_properties (abfd
) = NULL
;
157 prop
= _bfd_elf_get_property (abfd
, type
, datasz
);
159 prop
->u
.number
= bfd_h_get_64 (abfd
, ptr
);
161 prop
->u
.number
= bfd_h_get_32 (abfd
, ptr
);
162 prop
->pr_kind
= property_number
;
165 case GNU_PROPERTY_NO_COPY_ON_PROTECTED
:
169 (_("warning: %pB: corrupt no copy on protected size: 0x%x"),
171 /* Clear all properties. */
172 elf_properties (abfd
) = NULL
;
175 prop
= _bfd_elf_get_property (abfd
, type
, datasz
);
176 elf_has_no_copy_on_protected (abfd
) = true;
177 prop
->pr_kind
= property_number
;
181 if ((type
>= GNU_PROPERTY_UINT32_AND_LO
182 && type
<= GNU_PROPERTY_UINT32_AND_HI
)
183 || (type
>= GNU_PROPERTY_UINT32_OR_LO
184 && type
<= GNU_PROPERTY_UINT32_OR_HI
))
189 (_("error: %pB: <corrupt property (0x%x) size: 0x%x>"),
191 /* Clear all properties. */
192 elf_properties (abfd
) = NULL
;
195 prop
= _bfd_elf_get_property (abfd
, type
, datasz
);
196 prop
->u
.number
|= bfd_h_get_32 (abfd
, ptr
);
197 prop
->pr_kind
= property_number
;
198 if ((abfd
->flags
& DYNAMIC
) == 0
199 && type
== GNU_PROPERTY_1_NEEDED
201 & GNU_PROPERTY_1_NEEDED_INDIRECT_EXTERN_ACCESS
)
204 /* NB: Skip the shared library since it may not be
205 the same at run-time. */
206 elf_has_indirect_extern_access (abfd
) = true;
207 /* GNU_PROPERTY_NO_COPY_ON_PROTECTED is implied. */
208 elf_has_no_copy_on_protected (abfd
) = true;
217 (_("warning: %pB: unsupported GNU_PROPERTY_TYPE (%ld) type: 0x%x"),
218 abfd
, note
->type
, type
);
221 ptr
+= (datasz
+ (align_size
- 1)) & ~ (align_size
- 1);
227 /* Merge GNU property BPROP with APROP. If APROP isn't NULL, return TRUE
228 if APROP is updated. Otherwise, return TRUE if BPROP should be merged
232 elf_merge_gnu_properties (struct bfd_link_info
*info
, bfd
*abfd
, bfd
*bbfd
,
233 elf_property
*aprop
, elf_property
*bprop
)
235 const struct elf_backend_data
*bed
= get_elf_backend_data (abfd
);
236 unsigned int pr_type
= aprop
!= NULL
? aprop
->pr_type
: bprop
->pr_type
;
240 if (bed
->merge_gnu_properties
!= NULL
241 && pr_type
>= GNU_PROPERTY_LOPROC
242 && pr_type
< GNU_PROPERTY_LOUSER
)
243 return bed
->merge_gnu_properties (info
, abfd
, bbfd
, aprop
, bprop
);
247 case GNU_PROPERTY_STACK_SIZE
:
248 if (aprop
!= NULL
&& bprop
!= NULL
)
250 if (bprop
->u
.number
> aprop
->u
.number
)
252 aprop
->u
.number
= bprop
->u
.number
;
259 case GNU_PROPERTY_NO_COPY_ON_PROTECTED
:
260 /* Return TRUE if APROP is NULL to indicate that BPROP should
262 return aprop
== NULL
;
266 if (pr_type
>= GNU_PROPERTY_UINT32_OR_LO
267 && pr_type
<= GNU_PROPERTY_UINT32_OR_HI
)
269 if (aprop
!= NULL
&& bprop
!= NULL
)
271 number
= aprop
->u
.number
;
272 aprop
->u
.number
= number
| bprop
->u
.number
;
273 /* Remove the property if all bits are empty. */
274 if (aprop
->u
.number
== 0)
276 aprop
->pr_kind
= property_remove
;
280 updated
= number
!= (unsigned int) aprop
->u
.number
;
284 /* Only one of APROP and BPROP can be NULL. */
287 if (aprop
->u
.number
== 0)
289 /* Remove APROP if all bits are empty. */
290 aprop
->pr_kind
= property_remove
;
296 /* Return TRUE if APROP is NULL and all bits of BPROP
297 aren't empty to indicate that BPROP should be added
299 updated
= bprop
->u
.number
!= 0;
304 else if (pr_type
>= GNU_PROPERTY_UINT32_AND_LO
305 && pr_type
<= GNU_PROPERTY_UINT32_AND_HI
)
307 /* Only one of APROP and BPROP can be NULL:
308 1. APROP & BPROP when both APROP and BPROP aren't NULL.
309 2. If APROP is NULL, remove x86 feature.
310 3. Otherwise, do nothing.
312 if (aprop
!= NULL
&& bprop
!= NULL
)
314 number
= aprop
->u
.number
;
315 aprop
->u
.number
= number
& bprop
->u
.number
;
316 updated
= number
!= (unsigned int) aprop
->u
.number
;
317 /* Remove the property if all feature bits are cleared. */
318 if (aprop
->u
.number
== 0)
319 aprop
->pr_kind
= property_remove
;
323 /* There should be no AND properties since some input
324 doesn't have them. */
327 aprop
->pr_kind
= property_remove
;
334 /* Never should happen. */
341 /* Return the property of TYPE on *LISTP and remove it from *LISTP if RM is
342 true. Return NULL if not found. */
344 static elf_property
*
345 elf_find_and_remove_property (elf_property_list
**listp
,
346 unsigned int type
, bool rm
)
348 elf_property_list
*list
;
350 for (list
= *listp
; list
; list
= list
->next
)
352 if (type
== list
->property
.pr_type
)
354 /* Remove this property. */
357 return &list
->property
;
359 else if (type
< list
->property
.pr_type
)
367 /* Merge GNU property list *LISTP in ABFD with FIRST_PBFD. */
370 elf_merge_gnu_property_list (struct bfd_link_info
*info
, bfd
*first_pbfd
,
371 bfd
*abfd
, elf_property_list
**listp
)
373 elf_property_list
*p
, **lastp
;
378 /* Merge each GNU property in FIRST_PBFD with the one on *LISTP. */
379 lastp
= &elf_properties (first_pbfd
);
380 for (p
= *lastp
; p
; p
= p
->next
)
381 if (p
->property
.pr_kind
!= property_remove
)
383 if (p
->property
.pr_kind
== property_number
)
386 number
= p
->property
.u
.number
;
390 pr
= elf_find_and_remove_property (listp
, p
->property
.pr_type
,
392 /* Pass NULL to elf_merge_gnu_properties for the property which
394 elf_merge_gnu_properties (info
, first_pbfd
, abfd
, &p
->property
, pr
);
395 if (p
->property
.pr_kind
== property_remove
)
397 if (info
->has_map_file
)
402 info
->callbacks
->minfo
403 (_("Removed property %W to merge %pB (0x%v) "
405 (bfd_vma
) p
->property
.pr_type
, first_pbfd
,
406 number
, abfd
, pr
->u
.number
);
408 info
->callbacks
->minfo
409 (_("Removed property %W to merge %pB (0x%v) "
410 "and %pB (not found)\n"),
411 (bfd_vma
) p
->property
.pr_type
, first_pbfd
,
417 info
->callbacks
->minfo
418 (_("Removed property %W to merge %pB and %pB\n"),
419 (bfd_vma
) p
->property
.pr_type
, first_pbfd
, abfd
);
421 info
->callbacks
->minfo
422 (_("Removed property %W to merge %pB and %pB "
424 (bfd_vma
) p
->property
.pr_type
, first_pbfd
, abfd
);
428 /* Remove this property. */
436 if (p
->property
.u
.number
!= number
437 || p
->property
.u
.number
!= pr
->u
.number
)
438 info
->callbacks
->minfo
439 (_("Updated property %W (0x%v) to merge %pB (0x%v) "
441 (bfd_vma
) p
->property
.pr_type
, p
->property
.u
.number
,
442 first_pbfd
, number
, abfd
, pr
->u
.number
);
446 if (p
->property
.u
.number
!= number
)
447 info
->callbacks
->minfo
448 (_("Updated property %W (%v) to merge %pB (0x%v) "
449 "and %pB (not found)\n"),
450 (bfd_vma
) p
->property
.pr_type
, p
->property
.u
.number
,
451 first_pbfd
, number
, abfd
);
457 /* Merge the remaining properties on *LISTP with FIRST_PBFD. */
458 for (p
= *listp
; p
!= NULL
; p
= p
->next
)
460 if (p
->property
.pr_kind
== property_number
)
463 number
= p
->property
.u
.number
;
468 if (elf_merge_gnu_properties (info
, first_pbfd
, abfd
, NULL
, &p
->property
))
470 if (p
->property
.pr_type
== GNU_PROPERTY_NO_COPY_ON_PROTECTED
)
471 elf_has_no_copy_on_protected (first_pbfd
) = true;
473 pr
= _bfd_elf_get_property (first_pbfd
, p
->property
.pr_type
,
474 p
->property
.pr_datasz
);
475 /* It must be a new property. */
476 if (pr
->pr_kind
!= property_unknown
)
478 /* Add a new property. */
483 pr
= elf_find_and_remove_property (&elf_properties (first_pbfd
),
489 info
->callbacks
->minfo
490 (_("Removed property %W to merge %pB (not found) and "
492 (bfd_vma
) p
->property
.pr_type
, first_pbfd
, abfd
,
495 info
->callbacks
->minfo
496 (_("Removed property %W to merge %pB and %pB\n"),
497 (bfd_vma
) p
->property
.pr_type
, first_pbfd
, abfd
);
499 else if (pr
->pr_kind
!= property_remove
)
505 /* Get GNU property section size. */
508 elf_get_gnu_property_section_size (elf_property_list
*list
,
509 unsigned int align_size
)
514 /* Compute the output section size. */
515 descsz
= offsetof (Elf_External_Note
, name
[sizeof "GNU"]);
516 descsz
= (descsz
+ 3) & -(unsigned int) 4;
518 for (; list
!= NULL
; list
= list
->next
)
521 /* Check if this property should be skipped. */
522 if (list
->property
.pr_kind
== property_remove
)
524 /* There are 4 byte type + 4 byte datasz for each property. */
525 if (list
->property
.pr_type
== GNU_PROPERTY_STACK_SIZE
)
528 datasz
= list
->property
.pr_datasz
;
529 size
+= 4 + 4 + datasz
;
530 /* Align each property. */
531 size
= (size
+ (align_size
- 1)) & ~(align_size
- 1);
537 /* Write GNU properties. */
540 elf_write_gnu_properties (struct bfd_link_info
*info
,
541 bfd
*abfd
, bfd_byte
*contents
,
542 elf_property_list
*list
, unsigned int size
,
543 unsigned int align_size
)
547 Elf_External_Note
*e_note
;
549 e_note
= (Elf_External_Note
*) contents
;
550 descsz
= offsetof (Elf_External_Note
, name
[sizeof "GNU"]);
551 descsz
= (descsz
+ 3) & -(unsigned int) 4;
552 bfd_h_put_32 (abfd
, sizeof "GNU", &e_note
->namesz
);
553 bfd_h_put_32 (abfd
, size
- descsz
, &e_note
->descsz
);
554 bfd_h_put_32 (abfd
, NT_GNU_PROPERTY_TYPE_0
, &e_note
->type
);
555 memcpy (e_note
->name
, "GNU", sizeof "GNU");
558 for (; list
!= NULL
; list
= list
->next
)
560 /* Check if this property should be skipped. */
561 if (list
->property
.pr_kind
== property_remove
)
563 /* There are 4 byte type + 4 byte datasz for each property. */
564 if (list
->property
.pr_type
== GNU_PROPERTY_STACK_SIZE
)
567 datasz
= list
->property
.pr_datasz
;
568 bfd_h_put_32 (abfd
, list
->property
.pr_type
, contents
+ size
);
569 bfd_h_put_32 (abfd
, datasz
, contents
+ size
+ 4);
572 /* Write out property value. */
573 switch (list
->property
.pr_kind
)
575 case property_number
:
579 /* Never should happen. */
586 /* Save the pointer to GNU_PROPERTY_1_NEEDED so that it
587 can be updated later if needed. */
589 && list
->property
.pr_type
== GNU_PROPERTY_1_NEEDED
)
590 info
->needed_1_p
= contents
+ size
;
591 bfd_h_put_32 (abfd
, list
->property
.u
.number
,
596 bfd_h_put_64 (abfd
, list
->property
.u
.number
,
603 /* Never should happen. */
608 /* Align each property. */
609 size
= (size
+ (align_size
- 1)) & ~ (align_size
- 1);
613 /* Set up GNU properties. Return the first relocatable ELF input with
614 GNU properties if found. Otherwise, return NULL. */
617 _bfd_elf_link_setup_gnu_properties (struct bfd_link_info
*info
)
619 bfd
*abfd
, *first_pbfd
= NULL
, *elf_bfd
= NULL
;
620 elf_property_list
*list
;
622 bool has_properties
= false;
623 const struct elf_backend_data
*bed
624 = get_elf_backend_data (info
->output_bfd
);
625 unsigned int elfclass
= bed
->s
->elfclass
;
626 int elf_machine_code
= bed
->elf_machine_code
;
629 /* Find the first relocatable ELF input with GNU properties. */
630 for (abfd
= info
->input_bfds
; abfd
!= NULL
; abfd
= abfd
->link
.next
)
631 if (bfd_get_flavour (abfd
) == bfd_target_elf_flavour
632 && (abfd
->flags
& DYNAMIC
) == 0
634 == get_elf_backend_data (abfd
)->elf_machine_code
)
635 && (elfclass
== get_elf_backend_data (abfd
)->s
->elfclass
))
637 /* Ignore GNU properties from ELF objects with different machine
638 code or class. Also skip objects without a GNU_PROPERTY note
642 if (elf_properties (abfd
) != NULL
)
644 has_properties
= true;
646 if (bfd_get_section_by_name (abfd
,
647 NOTE_GNU_PROPERTY_SECTION_NAME
)
650 /* Keep .note.gnu.property section in FIRST_PBFD. */
657 if (info
->indirect_extern_access
> 0 && elf_bfd
!= NULL
)
659 /* Support -z indirect-extern-access. */
660 if (first_pbfd
== NULL
)
662 sec
= bfd_make_section_with_flags (elf_bfd
,
663 NOTE_GNU_PROPERTY_SECTION_NAME
,
671 info
->callbacks
->einfo (_("%F%P: failed to create GNU property section\n"));
673 if (!bfd_set_section_alignment (sec
,
674 elfclass
== ELFCLASS64
? 3 : 2))
675 info
->callbacks
->einfo (_("%F%pA: failed to align section\n"),
678 elf_section_type (sec
) = SHT_NOTE
;
679 first_pbfd
= elf_bfd
;
680 has_properties
= true;
683 p
= _bfd_elf_get_property (first_pbfd
, GNU_PROPERTY_1_NEEDED
, 4);
684 if (p
->pr_kind
== property_unknown
)
686 /* Create GNU_PROPERTY_1_NEEDED. */
688 = GNU_PROPERTY_1_NEEDED_INDIRECT_EXTERN_ACCESS
;
689 p
->pr_kind
= property_number
;
693 |= GNU_PROPERTY_1_NEEDED_INDIRECT_EXTERN_ACCESS
;
696 /* Do nothing if there is no .note.gnu.property section. */
700 /* Merge .note.gnu.property sections. */
701 info
->callbacks
->minfo (_("\n"));
702 info
->callbacks
->minfo (_("Merging program properties\n"));
703 info
->callbacks
->minfo (_("\n"));
705 for (abfd
= info
->input_bfds
; abfd
!= NULL
; abfd
= abfd
->link
.next
)
706 if (abfd
!= first_pbfd
707 && (abfd
->flags
& (DYNAMIC
| BFD_PLUGIN
| BFD_LINKER_CREATED
)) == 0)
709 elf_property_list
*null_ptr
= NULL
;
710 elf_property_list
**listp
= &null_ptr
;
712 /* Merge .note.gnu.property section in relocatable ELF input. */
713 if (bfd_get_flavour (abfd
) == bfd_target_elf_flavour
)
715 list
= elf_properties (abfd
);
717 /* Ignore GNU properties from ELF objects with different
721 == get_elf_backend_data (abfd
)->elf_machine_code
))
722 listp
= &elf_properties (abfd
);
727 /* Merge properties with FIRST_PBFD. FIRST_PBFD can be NULL
728 when all properties are from ELF objects with different
729 machine code or class. */
730 if (first_pbfd
!= NULL
)
731 elf_merge_gnu_property_list (info
, first_pbfd
, abfd
, listp
);
735 /* Discard the .note.gnu.property section in this bfd. */
736 sec
= bfd_get_section_by_name (abfd
,
737 NOTE_GNU_PROPERTY_SECTION_NAME
);
739 sec
->output_section
= bfd_abs_section_ptr
;
743 /* Rewrite .note.gnu.property section so that GNU properties are
744 always sorted by type even if input GNU properties aren't sorted. */
745 if (first_pbfd
!= NULL
)
749 unsigned int align_size
= elfclass
== ELFCLASS64
? 8 : 4;
751 sec
= bfd_get_section_by_name (first_pbfd
,
752 NOTE_GNU_PROPERTY_SECTION_NAME
);
753 BFD_ASSERT (sec
!= NULL
);
755 /* Update stack size in .note.gnu.property with -z stack-size=N
757 if (info
->stacksize
> 0)
759 bfd_vma stacksize
= info
->stacksize
;
761 p
= _bfd_elf_get_property (first_pbfd
, GNU_PROPERTY_STACK_SIZE
,
763 if (p
->pr_kind
== property_unknown
)
765 /* Create GNU_PROPERTY_STACK_SIZE. */
766 p
->u
.number
= stacksize
;
767 p
->pr_kind
= property_number
;
769 else if (stacksize
> p
->u
.number
)
770 p
->u
.number
= stacksize
;
772 else if (elf_properties (first_pbfd
) == NULL
)
774 /* Discard .note.gnu.property section if all properties have
776 sec
->output_section
= bfd_abs_section_ptr
;
780 /* Fix up GNU properties. */
781 if (bed
->fixup_gnu_properties
)
782 bed
->fixup_gnu_properties (info
, &elf_properties (first_pbfd
));
784 if (elf_properties (first_pbfd
) == NULL
)
786 /* Discard .note.gnu.property section if all properties have
788 sec
->output_section
= bfd_abs_section_ptr
;
792 /* Compute the section size. */
793 list
= elf_properties (first_pbfd
);
794 size
= elf_get_gnu_property_section_size (list
, align_size
);
796 /* Update .note.gnu.property section now. */
798 contents
= (bfd_byte
*) bfd_zalloc (first_pbfd
, size
);
800 if (info
->indirect_extern_access
<= 0)
802 /* Get GNU_PROPERTY_1_NEEDED properties. */
803 p
= elf_find_and_remove_property (&elf_properties (first_pbfd
),
804 GNU_PROPERTY_1_NEEDED
, false);
807 if (info
->indirect_extern_access
< 0)
809 /* Set indirect_extern_access to 1 to indicate that
810 it is turned on by input properties. */
812 & GNU_PROPERTY_1_NEEDED_INDIRECT_EXTERN_ACCESS
)
814 info
->indirect_extern_access
= 1;
817 /* Turn off indirect external access. */
819 &= ~GNU_PROPERTY_1_NEEDED_INDIRECT_EXTERN_ACCESS
;
823 elf_write_gnu_properties (info
, first_pbfd
, contents
, list
, size
,
826 /* Cache the section contents for elf_link_input_bfd. */
827 elf_section_data (sec
)->this_hdr
.contents
= contents
;
829 /* If GNU_PROPERTY_NO_COPY_ON_PROTECTED is set, protected data
830 symbol is defined in the shared object. */
831 if (elf_has_no_copy_on_protected (first_pbfd
))
832 info
->extern_protected_data
= false;
834 if (info
->indirect_extern_access
> 0)
836 /* For indirect external access, don't generate copy
837 relocations. NB: Set to nocopyreloc to 2 to indicate
838 that it is implied by indirect_extern_access. */
839 info
->nocopyreloc
= 2;
840 info
->extern_protected_data
= false;
847 /* Convert GNU property size. */
850 _bfd_elf_convert_gnu_property_size (bfd
*ibfd
, bfd
*obfd
)
852 unsigned int align_size
;
853 const struct elf_backend_data
*bed
;
854 elf_property_list
*list
= elf_properties (ibfd
);
856 bed
= get_elf_backend_data (obfd
);
857 align_size
= bed
->s
->elfclass
== ELFCLASS64
? 8 : 4;
859 /* Get the output .note.gnu.property section size. */
860 return elf_get_gnu_property_section_size (list
, align_size
);
863 /* Convert GNU properties. */
866 _bfd_elf_convert_gnu_properties (bfd
*ibfd
, asection
*isec
,
867 bfd
*obfd
, bfd_byte
**ptr
,
868 bfd_size_type
*ptr_size
)
872 unsigned int align_shift
;
873 const struct elf_backend_data
*bed
;
874 elf_property_list
*list
= elf_properties (ibfd
);
876 bed
= get_elf_backend_data (obfd
);
877 align_shift
= bed
->s
->elfclass
== ELFCLASS64
? 3 : 2;
879 /* Get the output .note.gnu.property section size. */
880 size
= bfd_section_size (isec
->output_section
);
882 /* Update the output .note.gnu.property section alignment. */
883 bfd_set_section_alignment (isec
->output_section
, align_shift
);
885 if (size
> bfd_section_size (isec
))
887 contents
= (bfd_byte
*) bfd_malloc (size
);
888 if (contents
== NULL
)
898 /* Generate the output .note.gnu.property section. */
899 elf_write_gnu_properties (NULL
, ibfd
, contents
, list
, size
,