[binutils-gdb] clean-up create_obj_attrs_section: comment about .gnu.attributes VS .gnu.build.attributes

Matthieu Longo mlongo@sourceware.org
Tue Mar 4 11:10:11 GMT 2025


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=29b221fc12a15352d1324d69691a514818f6d4b6

commit 29b221fc12a15352d1324d69691a514818f6d4b6
Author: Matthieu Longo <matthieu.longo@arm.com>
Date:   Mon Jan 27 14:55:02 2025 +0000

    clean-up create_obj_attrs_section: comment about .gnu.attributes VS .gnu.build.attributes

Diff:
---
 gas/write.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/gas/write.c b/gas/write.c
index 325c4402061..c725841d505 100644
--- a/gas/write.c
+++ b/gas/write.c
@@ -1918,27 +1918,27 @@ subsegs_finish (void)
 }
 
 #ifdef OBJ_ELF
+
 static void
 create_obj_attrs_section (void)
 {
-  segT s;
-  char *p;
-  offsetT size;
-  const char *name;
-
-  size = bfd_elf_obj_attr_size (stdoutput);
+  offsetT size = bfd_elf_obj_attr_size (stdoutput);
   if (size == 0)
     return;
 
-  name = get_elf_backend_data (stdoutput)->obj_attrs_section;
-  if (!name)
+  const char *name = get_elf_backend_data (stdoutput)->obj_attrs_section;
+  if (name == NULL)
+    /* Note: .gnu.attributes is different from GNU_BUILD_ATTRS_SECTION_NAME
+       (a.k.a .gnu.build.attributes). The first one seems to be used by some
+       backends like PowerPC to store the build attributes. The second one is
+       used to store build notes.  */
     name = ".gnu.attributes";
-  s = subseg_new (name, 0);
+  segT s = subseg_new (name, 0);
   elf_section_type (s)
     = get_elf_backend_data (stdoutput)->obj_attrs_section_type;
   bfd_set_section_flags (s, SEC_READONLY | SEC_DATA);
   frag_now_fix ();
-  p = frag_more (size);
+  char *p = frag_more (size);
   bfd_elf_set_obj_attr_contents (stdoutput, (bfd_byte *)p, size);
 
   subsegs_finish_section (s);


More information about the Binutils-cvs mailing list