public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Show AIX gc'd symbol address adjustments in map file
@ 2020-05-12 16:01 Douglas B Rupp
  0 siblings, 0 replies; only message in thread
From: Douglas B Rupp @ 2020-05-12 16:01 UTC (permalink / raw)
  To: r.sandiford; +Cc: Binutils

[-- Attachment #1: Type: text/plain, Size: 1452 bytes --]


Greetings,

I seek feedback on the attached patch, which enhances the .map file to 
show better address info on AIX XCOFF garbage collected symbols.

--Douglas Rupp, AdaCore

===============

The current .map file output with -nogc is something like this:

  .pr            0x100012b0       0x20 ./pack1.o
                 0x100012b0                .pack1__fooIP
                 0x100012c0                .pack1__bumIP
  .pr            0x100012d0       0x60 ./test1.o

----------

The current .map file output with -gc (the default) is something like this:

  .pr            0x100012b0        0x0 ./pack1.o
                 0x100012b0                .pack1__fooIP
                 0x100012c0                .pack1__bumIP
  .pr            0x100012b0       0x60 ./test1.o

Note that .pack1__fooIP and .pack1__bumIP have been gc'd and the 
addresses make no sense.

------------

The output with the attached patch is something like this:

  .pr            0x100012b0        0x0 ./pack1.o
                 0x100012b0          -->gc 0x100012b0 .pack1__fooIP
                 0x100012c0          -->gc 0x100012b0 .pack1__bumIP
  .pr            0x100012b0       0x60 ./test1.o


[-- Attachment #2: nogc1.diff --]
[-- Type: text/x-patch, Size: 1669 bytes --]

2020-05-12  Douglas B Rupp  <rupp@adacore.com>

	* include/bfdlink.h (aix_gc): New boolean
	* ld/emultempl/aix.em (gld${EMULATION_NAME}_add_options): Set it.
	* ld/ldlang.c (print_one_symbol): Output gc'd symbol info to map file


diff --git include/bfdlink.h include/bfdlink.h
index 773407f861..e00b6fcd76 100644
--- include/bfdlink.h
+++ include/bfdlink.h
@@ -498,6 +498,9 @@ struct bfd_link_info
   /* TRUE if common symbols should be treated as undefined.  */
   unsigned int inhibit_common_definition : 1;
 
+  /* TRUE if AIX style XCOFF garbage collection is ok.  */
+  unsigned int aix_gc: 1;
+
   /* The 1-byte NOP for x86 call instruction.  */
   char call_nop_byte;
 
diff --git ld/emultempl/aix.em ld/emultempl/aix.em
index 92f59f28ed..b9145c2d6f 100644
--- ld/emultempl/aix.em
+++ ld/emultempl/aix.em
@@ -271,6 +271,8 @@ gld${EMULATION_NAME}_add_options
   *longopts = xrealloc (*longopts,
 			nl * sizeof (struct option) + sizeof (xtra_long));
   memcpy (*longopts + nl, &xtra_long, sizeof (xtra_long));
+
+  link_info.aix_gc = TRUE;
 }
 
 static bfd_boolean
diff --git ld/ldlang.c ld/ldlang.c
index 21ef9bea2b..b5b67b4df8 100644
--- ld/ldlang.c
+++ ld/ldlang.c
@@ -4140,6 +4140,11 @@ print_one_symbol (struct bfd_link_hash_entry *hash_entry, void *ptr)
 	      + hash_entry->u.def.section->output_offset
 	      + hash_entry->u.def.section->output_section->vma));
 
+      if (link_info.aix_gc && hash_entry->u.def.section->size == 0)
+	minfo (" -->gc 0x%V   ",
+	       (hash_entry->u.def.section->output_offset
+                + hash_entry->u.def.section->output_section->vma));
+
       minfo ("             %pT\n", hash_entry->root.string);
     }
 

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-05-12 16:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-12 16:01 [PATCH] Show AIX gc'd symbol address adjustments in map file Douglas B Rupp

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).