Show AIX gc'd symbol address adjustments in map file
authorDouglas B Rupp <rupp@adacore.com>
Mon, 18 May 2020 11:59:53 +0000 (21:29 +0930)
committerAlan Modra <amodra@gmail.com>
Mon, 18 May 2020 13:11:32 +0000 (22:41 +0930)
* ldemul.h (ldemul_print_symbol): New.
(ld_emulation_xfer_type) <print_symbol): Likewise.
* ldemul.c (ldemul_print_symbol): New.
* ldlang.c (SECTION_NAME_MAP_LANGTH): Move to ...
(print_one_symbol): Make global and move declaration to ...
(print_all_symbols): Rename print_one_symbol to ldemul_print_symbol
(print_input_section): Likewise
* ldlang.h: ... here.
* emultempl/aix.em (gld${EMULATION_NAME}_print_symbol): New.
(ld_emulation_xfer_struct): Use it.
* emultempl/armcoff.em (ld_emulation_xfer_struct): Add print_symbol
and default to NULL.
* emultempl/beos.em (ld_emulation_xfer_struct): Likewise
* emultempl/elf.em (ld_emulation_xfer_struct): Likewise
* emultempl/generic.em (ld_emulation_xfer_struct): Likewise
* emultempl/linux.em (ld_emulation_xfer_struct): Likewise
* emultempl/msp430.em (ld_emulation_xfer_struct): Likewise
* emultempl/pe.em (ld_emulation_xfer_struct): Likewise
* emultempl/pep.em (ld_emulation_xfer_struct): Likewise
* emultempl/ticoff.em (ld_emulation_xfer_struct): Likewise
* emultempl/vanilla.em (ld_emulation_xfer_struct): Likewise

16 files changed:
ld/ChangeLog
ld/emultempl/aix.em
ld/emultempl/armcoff.em
ld/emultempl/beos.em
ld/emultempl/elf.em
ld/emultempl/generic.em
ld/emultempl/linux.em
ld/emultempl/msp430.em
ld/emultempl/pe.em
ld/emultempl/pep.em
ld/emultempl/ticoff.em
ld/emultempl/vanilla.em
ld/ldemul.c
ld/ldemul.h
ld/ldlang.c
ld/ldlang.h

index 2b30359b96805c03936c01f32b07108141501190..b719d456fb0b9c06acb16706b52d9a82ec0effe8 100644 (file)
@@ -1,3 +1,27 @@
+2020-05-18  Douglas B Rupp  <rupp@adacore.com>
+
+       * ldemul.h (ldemul_print_symbol): New.
+       (ld_emulation_xfer_type) <print_symbol): Likewise.
+       * ldemul.c (ldemul_print_symbol): New.
+       * ldlang.c (SECTION_NAME_MAP_LANGTH): Move to ...
+       (print_one_symbol): Make global and move declaration to ...
+       (print_all_symbols): Rename print_one_symbol to ldemul_print_symbol
+       (print_input_section): Likewise
+       * ldlang.h: ... here.
+       * emultempl/aix.em (gld${EMULATION_NAME}_print_symbol): New.
+       (ld_emulation_xfer_struct): Use it.
+       * emultempl/armcoff.em (ld_emulation_xfer_struct): Add print_symbol
+       and default to NULL.
+       * emultempl/beos.em (ld_emulation_xfer_struct): Likewise
+       * emultempl/elf.em (ld_emulation_xfer_struct): Likewise
+       * emultempl/generic.em (ld_emulation_xfer_struct): Likewise
+       * emultempl/linux.em (ld_emulation_xfer_struct): Likewise
+       * emultempl/msp430.em (ld_emulation_xfer_struct): Likewise
+       * emultempl/pe.em (ld_emulation_xfer_struct): Likewise
+       * emultempl/pep.em (ld_emulation_xfer_struct): Likewise
+       * emultempl/ticoff.em (ld_emulation_xfer_struct): Likewise
+       * emultempl/vanilla.em (ld_emulation_xfer_struct): Likewise
+
 2020-05-18  Sergei Trofimovich  <siarheit@google.com>
 
        * ldmain.c (add_archive_element): Fix s/claimi/claim/ typo
index 5b73c3e7e59aacc02d62dab7bda4941b2592002a..de313e1f1741d63b979ec7074f43e8b4d736e7c6 100644 (file)
@@ -1534,6 +1534,36 @@ gld${EMULATION_NAME}_open_dynamic_archive (const char *arch,
   return TRUE;
 }
 
+static bfd_boolean
+gld${EMULATION_NAME}_print_symbol (struct bfd_link_hash_entry *hash_entry,
+                                  void *ptr)
+{
+  asection *sec = (asection *) ptr;
+
+  if ((hash_entry->type == bfd_link_hash_defined
+       || hash_entry->type == bfd_link_hash_defweak)
+      && sec == hash_entry->u.def.section)
+    {
+      int i;
+      struct xcoff_link_hash_entry *h;
+
+      for (i = 0; i < SECTION_NAME_MAP_LENGTH; i++)
+       print_space ();
+      minfo ("0x%V   ",
+            (hash_entry->u.def.value
+             + hash_entry->u.def.section->output_offset
+             + hash_entry->u.def.section->output_section->vma));
+
+      /* Flag symbol if it has been garbage collected.  */
+      h = (struct xcoff_link_hash_entry *) hash_entry;
+      if ((h != NULL) && !(h->flags & XCOFF_MARK))
+       minfo (" -->gc");
+      minfo ("             %pT\n", hash_entry->root.string);
+    }
+
+  return TRUE;
+}
+
 struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = {
   gld${EMULATION_NAME}_before_parse,
   syslib_default,
@@ -1564,6 +1594,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = {
   NULL,                                /* new_vers_pattern */
   NULL,                                /* extra_map_file_text */
   ${LDEMUL_EMIT_CTF_EARLY-NULL},
-  ${LDEMUL_EXAMINE_STRTAB_FOR_CTF-NULL}
+  ${LDEMUL_EXAMINE_STRTAB_FOR_CTF-NULL},
+  gld${EMULATION_NAME}_print_symbol
 };
 EOF
index c539e2facca90f876dae7fb07b9b90d88fde8e8b..ff22af4eb371fc15819190f9bc60ae992b6b7c91 100644 (file)
@@ -286,6 +286,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
   NULL,        /* new_vers_pattern */
   NULL,        /* extra_map_file_text */
   ${LDEMUL_EMIT_CTF_EARLY-NULL},
-  ${LDEMUL_EXAMINE_STRTAB_FOR_CTF-NULL}
+  ${LDEMUL_EXAMINE_STRTAB_FOR_CTF-NULL},
+  ${LDEMUL_PRINT_SYMBOL-NULL}
 };
 EOF
index 2c3e5e5370d039c8ff69e116dd7a134327625908..442ff1222c6e4ddfd2a6e5ab363788295f5f2a48 100644 (file)
@@ -786,6 +786,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
   NULL,        /* new_vers_pattern */
   NULL,        /* extra_map_file_text */
   ${LDEMUL_EMIT_CTF_EARLY-NULL},
-  ${LDEMUL_EXAMINE_STRTAB_FOR_CTF-NULL}
+  ${LDEMUL_EXAMINE_STRTAB_FOR_CTF-NULL},
+  ${LDEMUL_PRINT_SYMBOL-NULL}
 };
 EOF
index 899030016c0d8519f6edd4c5232ef338f60e4ff6..eac2ce2f4ca2f5e87fb0c14f6216ba368aee59ed 100644 (file)
@@ -903,6 +903,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
   ${LDEMUL_NEW_VERS_PATTERN-NULL},
   ${LDEMUL_EXTRA_MAP_FILE_TEXT-NULL},
   ${LDEMUL_EMIT_CTF_EARLY-NULL},
-  ${LDEMUL_EXAMINE_STRTAB_FOR_CTF-NULL}
+  ${LDEMUL_EXAMINE_STRTAB_FOR_CTF-NULL},
+  ${LDEMUL_PRINT_SYMBOL-NULL}
 };
 EOF
index a39c9332075852c61878e2e8f86c74897f169bf2..24d3c1d9c68ed5895848eda1e622ee80d4e6a9d1 100644 (file)
@@ -161,6 +161,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
   ${LDEMUL_NEW_VERS_PATTERN-NULL},
   ${LDEMUL_EXTRA_MAP_FILE_TEXT-NULL},
   ${LDEMUL_EMIT_CTF_EARLY-NULL},
-  ${LDEMUL_EXAMINE_STRTAB_FOR_CTF-NULL}
+  ${LDEMUL_EXAMINE_STRTAB_FOR_CTF-NULL},
+  ${LDEMUL_PRINT_SYMBOL-NULL}
 };
 EOF
index f4ae6cfba2948d1edd9e08d12787f33806b4c627..e9d802c657cdab833c6e7b5287fd7c565e1e27aa 100644 (file)
@@ -213,6 +213,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
   NULL,        /* new_vers_pattern */
   NULL,        /* extra_map_file_text */
   ${LDEMUL_EMIT_CTF_EARLY-NULL},
-  ${LDEMUL_EXAMINE_STRTAB_FOR_CTF-NULL}
+  ${LDEMUL_EXAMINE_STRTAB_FOR_CTF-NULL},
+  ${LDEMUL_PRINT_SYMBOL-NULL}
 };
 EOF
index 861c1dcda0a1e5cbdd55e686c36a85cef66430dd..850c3a836ce605ef1c77001d7502eade22536079 100644 (file)
@@ -848,7 +848,8 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
   ${LDEMUL_NEW_VERS_PATTERN-NULL},
   ${LDEMUL_EXTRA_MAP_FILE_TEXT-NULL},
   ${LDEMUL_EMIT_CTF_EARLY-NULL},
-  ${LDEMUL_EXAMINE_STRTAB_FOR_CTF-NULL}
+  ${LDEMUL_EXAMINE_STRTAB_FOR_CTF-NULL},
+  ${LDEMUL_PRINT_SYMBOL-NULL}
 };
 EOF
 # \f
index ad5d65d024a52c349b0a95ba91abb6a5f207f3d2..3dd36de373dbb7c57f6503a0f252645a7cfe5cce 100644 (file)
@@ -2394,6 +2394,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
   NULL,        /* new_vers_pattern.  */
   NULL,        /* extra_map_file_text.  */
   ${LDEMUL_EMIT_CTF_EARLY-NULL},
-  ${LDEMUL_EXAMINE_STRTAB_FOR_CTF-NULL}
+  ${LDEMUL_EXAMINE_STRTAB_FOR_CTF-NULL},
+  ${LDEMUL_PRINT_SYMBOL-NULL}
 };
 EOF
index aa8bac5f8163279ab31918d4aa9a0d08425b9e17..39ddd8f23ec1208882c40606c19ec5e540734d67 100644 (file)
@@ -2192,6 +2192,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
   NULL,        /* new_vers_pattern.  */
   NULL,        /* extra_map_file_text */
   ${LDEMUL_EMIT_CTF_EARLY-NULL},
-  ${LDEMUL_EXAMINE_STRTAB_FOR_CTF-NULL}
+  ${LDEMUL_EXAMINE_STRTAB_FOR_CTF-NULL},
+  ${LDEMUL_PRINT_SYMBOL-NULL}
 };
 EOF
index 60c0da9f1b16880efb93d74ebd322213a8684c8d..11ddd0c9bada5b348aa1d16acc291b65625d0d60 100644 (file)
@@ -186,6 +186,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
   NULL,        /* new_vers_pattern */
   NULL,  /* extra_map_file_text */
   ${LDEMUL_EMIT_CTF_EARLY-NULL},
-  ${LDEMUL_EXAMINE_STRTAB_FOR_CTF-NULL}
+  ${LDEMUL_EXAMINE_STRTAB_FOR_CTF-NULL},
+  ${LDEMUL_PRINT_SYMBOL-NULL}
 };
 EOF
index ae6f6e4175dcb1d788b4dd9346d3de5c0647a464..70d193c2c7941afe6d698895b33cb4fa31417308 100644 (file)
@@ -87,6 +87,7 @@ struct ld_emulation_xfer_struct ld_vanilla_emulation =
   NULL,        /* new_vers_pattern */
   NULL,        /* extra_map_file_text */
   NULL, /* emit_ctf_early */
-  NULL  /* examine_strtab_for_ctf */
+  NULL, /* examine_strtab_for_ctf */
+  NULL  /* print_symbol */
 };
 EOF
index fa6dfdd18edfb199d4807d2766d02135272881b2..00a6a5ad1338b4b4d67b2d2b06d276b3f193759e 100644 (file)
@@ -428,3 +428,11 @@ ldemul_examine_strtab_for_ctf (struct ctf_file *ctf_output,
     ld_emulation->examine_strtab_for_ctf (ctf_output, syms,
                                          symcount, symstrtab);
 }
+
+bfd_boolean
+ldemul_print_symbol (struct bfd_link_hash_entry *hash_entry, void *ptr)
+{
+  if (ld_emulation->print_symbol)
+    return ld_emulation->print_symbol (hash_entry, ptr);
+  return print_one_symbol (hash_entry, ptr);
+}
index 44e3a92aa7ef26436d71aa3dc6145ab8469e9d54..ca165ac957046df6acec4b31ae232c18d921bba4 100644 (file)
@@ -112,6 +112,8 @@ extern int ldemul_emit_ctf_early
 extern void ldemul_examine_strtab_for_ctf
   (struct ctf_file *, struct elf_sym_strtab *, bfd_size_type,
    struct elf_strtab_hash *);
+extern bfd_boolean ldemul_print_symbol
+  (struct bfd_link_hash_entry *hash_entry, void *ptr);
 
 typedef struct ld_emulation_xfer_struct {
   /* Run before parsing the command line and script file.
@@ -236,6 +238,12 @@ typedef struct ld_emulation_xfer_struct {
      bfd_link_callback is invoked by per-target code.  */
   void (*examine_strtab_for_ctf) (struct ctf_file *, struct elf_sym_strtab *,
                                  bfd_size_type, struct elf_strtab_hash *);
+
+  /* Called when printing a symbol to the map file.   AIX uses this
+     hook to flag gc'd symbols.  */
+  bfd_boolean (*print_symbol)
+    (struct bfd_link_hash_entry *hash_entry, void *ptr);
+
 } ld_emulation_xfer_type;
 
 typedef enum {
index b2cdb3603aa13d443c2e4a56f84c37d6d696d4e1..35791e4e2c015cc83c9388e2ee815a99638ef794 100644 (file)
@@ -155,8 +155,6 @@ static int lang_sizing_iteration = 0;
 #define outside_symbol_address(q) \
   ((q)->value + outside_section_address (q->section))
 
-#define SECTION_NAME_MAP_LENGTH (16)
-
 /* CTF sections smaller than this are not compressed: compression of
    dictionaries this small doesn't gain much, and this lets consumers mmap the
    sections directly out of the ELF file and use them with no decompression
@@ -4619,7 +4617,7 @@ print_input_statement (lang_input_statement_type *statm)
 /* Print all symbols defined in a particular section.  This is called
    via bfd_link_hash_traverse, or by print_all_symbols.  */
 
-static bfd_boolean
+bfd_boolean
 print_one_symbol (struct bfd_link_hash_entry *hash_entry, void *ptr)
 {
   asection *sec = (asection *) ptr;
@@ -4683,7 +4681,7 @@ print_all_symbols (asection *sec)
 
   /* Print the symbols.  */
   for (i = 0; i < ud->map_symbol_def_count; i++)
-    print_one_symbol (entries[i], sec);
+    ldemul_print_symbol (entries[i], sec);
 
   obstack_free (&map_obstack, entries);
 }
@@ -4747,7 +4745,7 @@ print_input_section (asection *i, bfd_boolean is_discarded)
       && i->output_section->owner == link_info.output_bfd)
     {
       if (link_info.reduce_memory_overheads)
-       bfd_link_hash_traverse (link_info.hash, print_one_symbol, i);
+       bfd_link_hash_traverse (link_info.hash, ldemul_print_symbol, i);
       else
        print_all_symbols (i);
 
index 2aa3930f95a31ba1a868d5aab27739fe70938e08..3018c3e2ba5847ff0171a64367855e123e8f1e8e 100644 (file)
@@ -23,6 +23,8 @@
 
 #define DEFAULT_MEMORY_REGION   "*default*"
 
+#define SECTION_NAME_MAP_LENGTH (16)
+
 typedef enum
 {
   lang_input_file_is_l_enum,
@@ -701,4 +703,7 @@ lang_print_memory_usage (void);
 extern void
 lang_add_gc_name (const char *);
 
+extern bfd_boolean
+print_one_symbol (struct bfd_link_hash_entry *hash_entry, void *ptr);
+
 #endif
This page took 0.03234 seconds and 4 git commands to generate.