1 /* ELF program property support.
2 Copyright (C) 2017-2024 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 (type
== GNU_PROPERTY_1_NEEDED
200 & GNU_PROPERTY_1_NEEDED_INDIRECT_EXTERN_ACCESS
)
203 elf_has_indirect_extern_access (abfd
) = true;
204 /* GNU_PROPERTY_NO_COPY_ON_PROTECTED is implied. */
205 elf_has_no_copy_on_protected (abfd
) = true;
214 (_("warning: %pB: unsupported GNU_PROPERTY_TYPE (%ld) type: 0x%x"),
215 abfd
, note
->type
, type
);
218 ptr
+= (datasz
+ (align_size
- 1)) & ~ (align_size
- 1);
224 /* Merge GNU property BPROP with APROP. If APROP isn't NULL, return TRUE
225 if APROP is updated. Otherwise, return TRUE if BPROP should be merged
229 elf_merge_gnu_properties (struct bfd_link_info
*info
, bfd
*abfd
, bfd
*bbfd
,
230 elf_property
*aprop
, elf_property
*bprop
)
232 const struct elf_backend_data
*bed
= get_elf_backend_data (abfd
);
233 unsigned int pr_type
= aprop
!= NULL
? aprop
->pr_type
: bprop
->pr_type
;
237 if (bed
->merge_gnu_properties
!= NULL
238 && pr_type
>= GNU_PROPERTY_LOPROC
239 && pr_type
< GNU_PROPERTY_LOUSER
)
240 return bed
->merge_gnu_properties (info
, abfd
, bbfd
, aprop
, bprop
);
244 case GNU_PROPERTY_STACK_SIZE
:
245 if (aprop
!= NULL
&& bprop
!= NULL
)
247 if (bprop
->u
.number
> aprop
->u
.number
)
249 aprop
->u
.number
= bprop
->u
.number
;
256 case GNU_PROPERTY_NO_COPY_ON_PROTECTED
:
257 /* Return TRUE if APROP is NULL to indicate that BPROP should
259 return aprop
== NULL
;
263 if (pr_type
>= GNU_PROPERTY_UINT32_OR_LO
264 && pr_type
<= GNU_PROPERTY_UINT32_OR_HI
)
266 if (aprop
!= NULL
&& bprop
!= NULL
)
268 number
= aprop
->u
.number
;
269 aprop
->u
.number
= number
| bprop
->u
.number
;
270 /* Remove the property if all bits are empty. */
271 if (aprop
->u
.number
== 0)
273 aprop
->pr_kind
= property_remove
;
277 updated
= number
!= (unsigned int) aprop
->u
.number
;
281 /* Only one of APROP and BPROP can be NULL. */
284 if (aprop
->u
.number
== 0)
286 /* Remove APROP if all bits are empty. */
287 aprop
->pr_kind
= property_remove
;
293 /* Return TRUE if APROP is NULL and all bits of BPROP
294 aren't empty to indicate that BPROP should be added
296 updated
= bprop
->u
.number
!= 0;
301 else if (pr_type
>= GNU_PROPERTY_UINT32_AND_LO
302 && pr_type
<= GNU_PROPERTY_UINT32_AND_HI
)
304 /* Only one of APROP and BPROP can be NULL:
305 1. APROP & BPROP when both APROP and BPROP aren't NULL.
306 2. If APROP is NULL, remove x86 feature.
307 3. Otherwise, do nothing.
309 if (aprop
!= NULL
&& bprop
!= NULL
)
311 number
= aprop
->u
.number
;
312 aprop
->u
.number
= number
& bprop
->u
.number
;
313 updated
= number
!= (unsigned int) aprop
->u
.number
;
314 /* Remove the property if all feature bits are cleared. */
315 if (aprop
->u
.number
== 0)
316 aprop
->pr_kind
= property_remove
;
320 /* There should be no AND properties since some input
321 doesn't have them. */
324 aprop
->pr_kind
= property_remove
;
331 /* Never should happen. */
338 /* Return the property of TYPE on *LISTP and remove it from *LISTP if RM is
339 true. Return NULL if not found. */
341 static elf_property
*
342 elf_find_and_remove_property (elf_property_list
**listp
,
343 unsigned int type
, bool rm
)
345 elf_property_list
*list
;
347 for (list
= *listp
; list
; list
= list
->next
)
349 if (type
== list
->property
.pr_type
)
351 /* Remove this property. */
354 return &list
->property
;
356 else if (type
< list
->property
.pr_type
)
364 /* Merge GNU property list *LISTP in ABFD with FIRST_PBFD. */
367 elf_merge_gnu_property_list (struct bfd_link_info
*info
, bfd
*first_pbfd
,
368 bfd
*abfd
, elf_property_list
**listp
)
370 elf_property_list
*p
, **lastp
;
375 /* Merge each GNU property in FIRST_PBFD with the one on *LISTP. */
376 lastp
= &elf_properties (first_pbfd
);
377 for (p
= *lastp
; p
; p
= p
->next
)
378 if (p
->property
.pr_kind
!= property_remove
)
380 if (p
->property
.pr_kind
== property_number
)
383 number
= p
->property
.u
.number
;
387 pr
= elf_find_and_remove_property (listp
, p
->property
.pr_type
,
389 /* Pass NULL to elf_merge_gnu_properties for the property which
391 elf_merge_gnu_properties (info
, first_pbfd
, abfd
, &p
->property
, pr
);
392 if (p
->property
.pr_kind
== property_remove
)
394 if (info
->has_map_file
)
399 info
->callbacks
->minfo
400 (_("Removed property %W to merge %pB (0x%v) "
402 (bfd_vma
) p
->property
.pr_type
, first_pbfd
,
403 number
, abfd
, pr
->u
.number
);
405 info
->callbacks
->minfo
406 (_("Removed property %W to merge %pB (0x%v) "
407 "and %pB (not found)\n"),
408 (bfd_vma
) p
->property
.pr_type
, first_pbfd
,
414 info
->callbacks
->minfo
415 (_("Removed property %W to merge %pB and %pB\n"),
416 (bfd_vma
) p
->property
.pr_type
, first_pbfd
, abfd
);
418 info
->callbacks
->minfo
419 (_("Removed property %W to merge %pB and %pB "
421 (bfd_vma
) p
->property
.pr_type
, first_pbfd
, abfd
);
425 /* Remove this property. */
433 if (p
->property
.u
.number
!= number
434 || p
->property
.u
.number
!= pr
->u
.number
)
435 info
->callbacks
->minfo
436 (_("Updated property %W (0x%v) to merge %pB (0x%v) "
438 (bfd_vma
) p
->property
.pr_type
, p
->property
.u
.number
,
439 first_pbfd
, number
, abfd
, pr
->u
.number
);
443 if (p
->property
.u
.number
!= number
)
444 info
->callbacks
->minfo
445 (_("Updated property %W (%v) to merge %pB (0x%v) "
446 "and %pB (not found)\n"),
447 (bfd_vma
) p
->property
.pr_type
, p
->property
.u
.number
,
448 first_pbfd
, number
, abfd
);
454 /* Merge the remaining properties on *LISTP with FIRST_PBFD. */
455 for (p
= *listp
; p
!= NULL
; p
= p
->next
)
457 if (p
->property
.pr_kind
== property_number
)
460 number
= p
->property
.u
.number
;
465 if (elf_merge_gnu_properties (info
, first_pbfd
, abfd
, NULL
, &p
->property
))
467 if (p
->property
.pr_type
== GNU_PROPERTY_NO_COPY_ON_PROTECTED
)
468 elf_has_no_copy_on_protected (first_pbfd
) = true;
470 pr
= _bfd_elf_get_property (first_pbfd
, p
->property
.pr_type
,
471 p
->property
.pr_datasz
);
472 /* It must be a new property. */
473 if (pr
->pr_kind
!= property_unknown
)
475 /* Add a new property. */
480 pr
= elf_find_and_remove_property (&elf_properties (first_pbfd
),
486 info
->callbacks
->minfo
487 (_("Removed property %W to merge %pB (not found) and "
489 (bfd_vma
) p
->property
.pr_type
, first_pbfd
, abfd
,
492 info
->callbacks
->minfo
493 (_("Removed property %W to merge %pB and %pB\n"),
494 (bfd_vma
) p
->property
.pr_type
, first_pbfd
, abfd
);
496 else if (pr
->pr_kind
!= property_remove
)
502 /* Get GNU property section size. */
505 elf_get_gnu_property_section_size (elf_property_list
*list
,
506 unsigned int align_size
)
511 /* Compute the output section size. */
512 descsz
= offsetof (Elf_External_Note
, name
[sizeof "GNU"]);
513 descsz
= (descsz
+ 3) & -(unsigned int) 4;
515 for (; list
!= NULL
; list
= list
->next
)
518 /* Check if this property should be skipped. */
519 if (list
->property
.pr_kind
== property_remove
)
521 /* There are 4 byte type + 4 byte datasz for each property. */
522 if (list
->property
.pr_type
== GNU_PROPERTY_STACK_SIZE
)
525 datasz
= list
->property
.pr_datasz
;
526 size
+= 4 + 4 + datasz
;
527 /* Align each property. */
528 size
= (size
+ (align_size
- 1)) & ~(align_size
- 1);
534 /* Write GNU properties. */
537 elf_write_gnu_properties (struct bfd_link_info
*info
,
538 bfd
*abfd
, bfd_byte
*contents
,
539 elf_property_list
*list
, unsigned int size
,
540 unsigned int align_size
)
544 Elf_External_Note
*e_note
;
546 e_note
= (Elf_External_Note
*) contents
;
547 descsz
= offsetof (Elf_External_Note
, name
[sizeof "GNU"]);
548 descsz
= (descsz
+ 3) & -(unsigned int) 4;
549 bfd_h_put_32 (abfd
, sizeof "GNU", &e_note
->namesz
);
550 bfd_h_put_32 (abfd
, size
- descsz
, &e_note
->descsz
);
551 bfd_h_put_32 (abfd
, NT_GNU_PROPERTY_TYPE_0
, &e_note
->type
);
552 memcpy (e_note
->name
, "GNU", sizeof "GNU");
555 for (; list
!= NULL
; list
= list
->next
)
557 /* Check if this property should be skipped. */
558 if (list
->property
.pr_kind
== property_remove
)
560 /* There are 4 byte type + 4 byte datasz for each property. */
561 if (list
->property
.pr_type
== GNU_PROPERTY_STACK_SIZE
)
564 datasz
= list
->property
.pr_datasz
;
565 bfd_h_put_32 (abfd
, list
->property
.pr_type
, contents
+ size
);
566 bfd_h_put_32 (abfd
, datasz
, contents
+ size
+ 4);
569 /* Write out property value. */
570 switch (list
->property
.pr_kind
)
572 case property_number
:
576 /* Never should happen. */
583 /* Save the pointer to GNU_PROPERTY_1_NEEDED so that it
584 can be updated later if needed. */
586 && list
->property
.pr_type
== GNU_PROPERTY_1_NEEDED
)
587 info
->needed_1_p
= contents
+ size
;
588 bfd_h_put_32 (abfd
, list
->property
.u
.number
,
593 bfd_h_put_64 (abfd
, list
->property
.u
.number
,
600 /* Never should happen. */
605 /* Align each property. */
606 size
= (size
+ (align_size
- 1)) & ~ (align_size
- 1);
610 /* Set up GNU properties. Return the first relocatable ELF input with
611 GNU properties if found. Otherwise, return NULL. */
614 _bfd_elf_link_setup_gnu_properties (struct bfd_link_info
*info
)
616 bfd
*abfd
, *first_pbfd
= NULL
, *elf_bfd
= NULL
;
617 elf_property_list
*list
;
619 bool has_properties
= false;
620 const struct elf_backend_data
*bed
621 = get_elf_backend_data (info
->output_bfd
);
622 unsigned int elfclass
= bed
->s
->elfclass
;
623 int elf_machine_code
= bed
->elf_machine_code
;
626 /* Find the first relocatable ELF input with GNU properties. */
627 for (abfd
= info
->input_bfds
; abfd
!= NULL
; abfd
= abfd
->link
.next
)
628 if (bfd_get_flavour (abfd
) == bfd_target_elf_flavour
629 && (abfd
->flags
& DYNAMIC
) == 0
631 == get_elf_backend_data (abfd
)->elf_machine_code
)
632 && (elfclass
== get_elf_backend_data (abfd
)->s
->elfclass
))
634 /* Ignore GNU properties from ELF objects with different machine
635 code or class. Also skip objects without a GNU_PROPERTY note
639 if (elf_properties (abfd
) != NULL
)
641 has_properties
= true;
643 if (bfd_get_section_by_name (abfd
,
644 NOTE_GNU_PROPERTY_SECTION_NAME
)
647 /* Keep .note.gnu.property section in FIRST_PBFD. */
654 if (info
->indirect_extern_access
> 0 && elf_bfd
!= NULL
)
656 /* Support -z indirect-extern-access. */
657 if (first_pbfd
== NULL
)
659 sec
= bfd_make_section_with_flags (elf_bfd
,
660 NOTE_GNU_PROPERTY_SECTION_NAME
,
668 info
->callbacks
->einfo (_("%F%P: failed to create GNU property section\n"));
670 if (!bfd_set_section_alignment (sec
,
671 elfclass
== ELFCLASS64
? 3 : 2))
672 info
->callbacks
->einfo (_("%F%pA: failed to align section\n"),
675 elf_section_type (sec
) = SHT_NOTE
;
676 first_pbfd
= elf_bfd
;
677 has_properties
= true;
680 p
= _bfd_elf_get_property (first_pbfd
, GNU_PROPERTY_1_NEEDED
, 4);
681 if (p
->pr_kind
== property_unknown
)
683 /* Create GNU_PROPERTY_1_NEEDED. */
685 = GNU_PROPERTY_1_NEEDED_INDIRECT_EXTERN_ACCESS
;
686 p
->pr_kind
= property_number
;
690 |= GNU_PROPERTY_1_NEEDED_INDIRECT_EXTERN_ACCESS
;
693 /* Do nothing if there is no .note.gnu.property section. */
697 /* Merge .note.gnu.property sections. */
698 info
->callbacks
->minfo (_("\n"));
699 info
->callbacks
->minfo (_("Merging program properties\n"));
700 info
->callbacks
->minfo (_("\n"));
702 for (abfd
= info
->input_bfds
; abfd
!= NULL
; abfd
= abfd
->link
.next
)
703 if (abfd
!= first_pbfd
704 && (abfd
->flags
& (DYNAMIC
| BFD_PLUGIN
| BFD_LINKER_CREATED
)) == 0)
706 elf_property_list
*null_ptr
= NULL
;
707 elf_property_list
**listp
= &null_ptr
;
709 /* Merge .note.gnu.property section in relocatable ELF input. */
710 if (bfd_get_flavour (abfd
) == bfd_target_elf_flavour
)
712 list
= elf_properties (abfd
);
714 /* Ignore GNU properties from ELF objects with different
718 == get_elf_backend_data (abfd
)->elf_machine_code
))
719 listp
= &elf_properties (abfd
);
724 /* Merge properties with FIRST_PBFD. FIRST_PBFD can be NULL
725 when all properties are from ELF objects with different
726 machine code or class. */
727 if (first_pbfd
!= NULL
)
728 elf_merge_gnu_property_list (info
, first_pbfd
, abfd
, listp
);
732 /* Discard the .note.gnu.property section in this bfd. */
733 sec
= bfd_get_section_by_name (abfd
,
734 NOTE_GNU_PROPERTY_SECTION_NAME
);
736 sec
->output_section
= bfd_abs_section_ptr
;
740 /* Rewrite .note.gnu.property section so that GNU properties are
741 always sorted by type even if input GNU properties aren't sorted. */
742 if (first_pbfd
!= NULL
)
746 unsigned int align_size
= elfclass
== ELFCLASS64
? 8 : 4;
748 sec
= bfd_get_section_by_name (first_pbfd
,
749 NOTE_GNU_PROPERTY_SECTION_NAME
);
750 BFD_ASSERT (sec
!= NULL
);
752 /* Update stack size in .note.gnu.property with -z stack-size=N
754 if (info
->stacksize
> 0)
756 bfd_vma stacksize
= info
->stacksize
;
758 p
= _bfd_elf_get_property (first_pbfd
, GNU_PROPERTY_STACK_SIZE
,
760 if (p
->pr_kind
== property_unknown
)
762 /* Create GNU_PROPERTY_STACK_SIZE. */
763 p
->u
.number
= stacksize
;
764 p
->pr_kind
= property_number
;
766 else if (stacksize
> p
->u
.number
)
767 p
->u
.number
= stacksize
;
769 else if (elf_properties (first_pbfd
) == NULL
)
771 /* Discard .note.gnu.property section if all properties have
773 sec
->output_section
= bfd_abs_section_ptr
;
777 /* Fix up GNU properties. */
778 if (bed
->fixup_gnu_properties
)
779 bed
->fixup_gnu_properties (info
, &elf_properties (first_pbfd
));
781 if (elf_properties (first_pbfd
) == NULL
)
783 /* Discard .note.gnu.property section if all properties have
785 sec
->output_section
= bfd_abs_section_ptr
;
789 /* Compute the section size. */
790 list
= elf_properties (first_pbfd
);
791 size
= elf_get_gnu_property_section_size (list
, align_size
);
793 /* Update .note.gnu.property section now. */
795 contents
= (bfd_byte
*) bfd_zalloc (first_pbfd
, size
);
797 if (info
->indirect_extern_access
<= 0)
799 /* Get GNU_PROPERTY_1_NEEDED properties. */
800 p
= elf_find_and_remove_property (&elf_properties (first_pbfd
),
801 GNU_PROPERTY_1_NEEDED
, false);
804 if (info
->indirect_extern_access
< 0)
806 /* Set indirect_extern_access to 1 to indicate that
807 it is turned on by input properties. */
809 & GNU_PROPERTY_1_NEEDED_INDIRECT_EXTERN_ACCESS
)
811 info
->indirect_extern_access
= 1;
814 /* Turn off indirect external access. */
816 &= ~GNU_PROPERTY_1_NEEDED_INDIRECT_EXTERN_ACCESS
;
820 elf_write_gnu_properties (info
, first_pbfd
, contents
, list
, size
,
823 /* Cache the section contents for elf_link_input_bfd. */
824 elf_section_data (sec
)->this_hdr
.contents
= contents
;
826 /* If GNU_PROPERTY_NO_COPY_ON_PROTECTED is set, protected data
827 symbol is defined in the shared object. */
828 if (elf_has_no_copy_on_protected (first_pbfd
))
829 info
->extern_protected_data
= false;
831 if (info
->indirect_extern_access
> 0)
833 /* For indirect external access, don't generate copy
834 relocations. NB: Set to nocopyreloc to 2 to indicate
835 that it is implied by indirect_extern_access. */
836 info
->nocopyreloc
= 2;
837 info
->extern_protected_data
= false;
844 /* Convert GNU property size. */
847 _bfd_elf_convert_gnu_property_size (bfd
*ibfd
, bfd
*obfd
)
849 unsigned int align_size
;
850 const struct elf_backend_data
*bed
;
851 elf_property_list
*list
= elf_properties (ibfd
);
853 bed
= get_elf_backend_data (obfd
);
854 align_size
= bed
->s
->elfclass
== ELFCLASS64
? 8 : 4;
856 /* Get the output .note.gnu.property section size. */
857 return elf_get_gnu_property_section_size (list
, align_size
);
860 /* Convert GNU properties. */
863 _bfd_elf_convert_gnu_properties (bfd
*ibfd
, asection
*isec
,
864 bfd
*obfd
, bfd_byte
**ptr
,
865 bfd_size_type
*ptr_size
)
869 unsigned int align_shift
;
870 const struct elf_backend_data
*bed
;
871 elf_property_list
*list
= elf_properties (ibfd
);
873 bed
= get_elf_backend_data (obfd
);
874 align_shift
= bed
->s
->elfclass
== ELFCLASS64
? 3 : 2;
876 /* Get the output .note.gnu.property section size. */
877 size
= bfd_section_size (isec
->output_section
);
879 /* Update the output .note.gnu.property section alignment. */
880 bfd_set_section_alignment (isec
->output_section
, align_shift
);
882 if (size
> bfd_section_size (isec
))
884 contents
= (bfd_byte
*) bfd_malloc (size
);
885 if (contents
== NULL
)
895 /* Generate the output .note.gnu.property section. */
896 elf_write_gnu_properties (NULL
, ibfd
, contents
, list
, size
,