[binutils-gdb] gas: conditionalize body of create_obj_attrs_section()

Jan Beulich via Binutils-cvs <[email protected]>
Newsgroups gmane.comp.gnu.binutils.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=44b41849915f0b53ccf8f5e413cdcb7ba1170e38

commit 44b41849915f0b53ccf8f5e413cdcb7ba1170e38
Author: Jan Beulich <[email protected]>
Date:   Fri Mar 13 07:50:45 2026 +0100

    gas: conditionalize body of create_obj_attrs_section()
    
    This way bfd_elf_obj_attr_size() and bfd_elf_set_obj_attr_contents() will
    remain unused for targets not supporting object attributes, which allows
    libbfd to not provide them.
    
    Also correct the surrounding #if-s: OBJ_MAYBE_ELF really needs taking into
    consideration as well.

Diff:
---
 gas/write.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/gas/write.c b/gas/write.c
index 3494871270a..9d0777051dd 100644
--- a/gas/write.c
+++ b/gas/write.c
@@ -1895,11 +1895,12 @@ subsegs_finish (void)
     subsegs_finish_section (s);
 }
 
-#ifdef OBJ_ELF
+#if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)
 
 static void
 create_obj_attrs_section (void)
 {
+#ifdef TC_OBJ_ATTR
   offsetT size = bfd_elf_obj_attr_size (stdoutput);
   if (size == 0)
     return;
@@ -1922,6 +1923,7 @@ create_obj_attrs_section (void)
   subsegs_finish_section (s);
   relax_segment (seg_info (s)->frchainP->frch_root, s, 0);
   size_seg (stdoutput, s, NULL);
+#endif /* TC_OBJ_ATTR */
 }
 
 /* Create a relocation against an entry in a GNU Build attribute section.  */
@@ -2203,7 +2205,7 @@ write_object_file (void)
   md_post_relax_hook;
 #endif
 
-#ifdef OBJ_ELF
+#if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)
   if (IS_ELF)
     create_obj_attrs_section ();
 #endif
@@ -2321,7 +2323,7 @@ write_object_file (void)
 
   evaluate_deferred_diags ();
 
-#ifdef OBJ_ELF
+#if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)
   if (IS_ELF)
     maybe_generate_build_notes ();
 #endif
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.