COFF: make objcopy / strip honor --keep-file-symbols
authorJan Beulich <jbeulich@suse.com>
Thu, 19 May 2022 10:44:08 +0000 (12:44 +0200)
committerJan Beulich <jbeulich@suse.com>
Thu, 19 May 2022 10:44:08 +0000 (12:44 +0200)
So far this option had no effect when used together with e.g.
--strip-debug. Set BSF_FILE on these symbols to change that.

While altering this also join two adjacent blocks of case labeled
statements with identical code.

bfd/coffcode.h

index 0a6605191383c2eb7346a3b7e295a929bb8b4c27..1ffb6032bed73443a3034c2aa64934be275a9dc1 100644 (file)
@@ -4755,6 +4755,9 @@ coff_slurp_symbol_table (bfd * abfd)
                dst->symbol.value = src->u.syment.n_value;
              break;
 
+           case C_FILE:        /* File name.  */
+             dst->symbol.flags = BSF_FILE;
+             /* Fall through.  */
            case C_MOS:         /* Member of structure.  */
            case C_EOS:         /* End of structure.  */
            case C_REGPARM:     /* Register parameter.  */
@@ -4768,11 +4771,6 @@ coff_slurp_symbol_table (bfd * abfd)
            case C_MOE:         /* Member of enumeration.  */
            case C_MOU:         /* Member of union.  */
            case C_UNTAG:       /* Union tag.  */
-             dst->symbol.flags = BSF_DEBUGGING;
-             dst->symbol.value = (src->u.syment.n_value);
-             break;
-
-           case C_FILE:        /* File name.  */
            case C_STRTAG:      /* Structure tag.  */
 #ifdef RS6000COFF_C
            case C_GSYM:
@@ -4790,7 +4788,7 @@ coff_slurp_symbol_table (bfd * abfd)
            case C_FUN:
            case C_ESTAT:
 #endif
-             dst->symbol.flags = BSF_DEBUGGING;
+             dst->symbol.flags |= BSF_DEBUGGING;
              dst->symbol.value = (src->u.syment.n_value);
              break;