PR273, SOM size -A
authorAlan Modra <amodra@gmail.com>
Thu, 21 Nov 2019 10:14:54 +0000 (20:44 +1030)
committerAlan Modra <amodra@gmail.com>
Thu, 21 Nov 2019 12:03:42 +0000 (22:33 +1030)
The SOM backend creates BFD sections for "spaces", and "sub-spaces".
"sub-spaces" are what we normally think of as a section, "spaces"
aggregate "sub-spaces".  Thus it does not really make sense to include
"spaces" for size -A since that would double count total size.

It so happens that real sections ought to have at least one of the
ALLOC and HAS_CONTENTS flags set, so this patch excludes "spaces" but
excluding BFD sections with no flags set.

PR 273
* size.c (sysv_internal_sizer, sysv_internal_printer): Exclude
sections with no flag bits set.
* testsuite/binutils-all/size.exp: Allow $CODE$ as a text section.

binutils/ChangeLog
binutils/size.c
binutils/testsuite/binutils-all/size.exp

index 2d1a0030883ca7a6b4799251033c77ff737fb63c..c4f7e3d5b3d126a9dd19fed4b83bfb3227ba7d44 100644 (file)
@@ -1,3 +1,10 @@
+2019-11-21  Alan Modra  <amodra@gmail.com>
+
+       PR 273
+       * size.c (sysv_internal_sizer, sysv_internal_printer): Exclude
+       sections with no flag bits set.
+       * testsuite/binutils-all/size.exp: Allow $CODE$ as a text section.
+
 2019-11-21  Nick Clifton  <nickc@redhat.com>
 
        * objcopy.c (merge_gnu_build_notes): Allow for the possibility
index b147221e916f03e6504b097a9a54ce934c47548f..69da30cade772acec2f32567e0bbac33977e4176 100644 (file)
@@ -557,12 +557,16 @@ static void
 sysv_internal_sizer (bfd *file ATTRIBUTE_UNUSED, sec_ptr sec,
                     void *ignore ATTRIBUTE_UNUSED)
 {
-  bfd_size_type size = bfd_section_size (sec);
+  flagword flags = bfd_section_flags (sec);
+  /* Exclude sections with no flags set.  This is to omit som spaces.  */
+  if (flags == 0)
+    return;
 
   if (   ! bfd_is_abs_section (sec)
       && ! bfd_is_com_section (sec)
       && ! bfd_is_und_section (sec))
     {
+      bfd_size_type size = bfd_section_size (sec);
       int namelen = strlen (bfd_section_name (sec));
 
       if (namelen > svi_namelen)
@@ -589,12 +593,16 @@ static void
 sysv_internal_printer (bfd *file ATTRIBUTE_UNUSED, sec_ptr sec,
                       void *ignore ATTRIBUTE_UNUSED)
 {
-  bfd_size_type size = bfd_section_size (sec);
+  flagword flags = bfd_section_flags (sec);
+  if (flags == 0)
+    return;
 
   if (   ! bfd_is_abs_section (sec)
       && ! bfd_is_com_section (sec)
       && ! bfd_is_und_section (sec))
     {
+      bfd_size_type size = bfd_section_size (sec);
+
       svi_total += size;
 
       sysv_one_line (bfd_section_name (sec),
index a102e15c0dec8cc11aec6f2c170d032ed414a211..1c199ba638b835d62d7d0c123f8560b053ec4d2a 100644 (file)
@@ -66,7 +66,7 @@ if {![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest.o]} then {
 
     set got [binutils_run $SIZE "$SIZEFLAGS -A ${testfile}"]
 
-    set want "${testfile}.*(text|TEXT|P)\[^\n\r\]*\[   \]($dec)\[      \]+$dec.*(\\.data|DATA|D_1)\[^\n\r\]*\[         \]($dec)\[      \]+$dec"
+    set want "${testfile}.*(text|TEXT|\\\$CODE\\\$|P)\[^\n\r\]*\[      \]($dec)\[      \]+$dec.*(\\.data|DATA|D_1)\[^\n\r\]*\[         \]($dec)\[      \]+$dec"
 
     if ![regexp $want $got all textname textsize dataname datasize] then {
        fail "size -A"
This page took 0.025636 seconds and 4 git commands to generate.