public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Proposed patch to objectcopy.c
@ 2005-02-24 10:39 Daniel Marques
  2005-03-01 11:44 ` Nick Clifton
  2005-03-15 17:44 ` Nick Clifton
  0 siblings, 2 replies; 3+ messages in thread
From: Daniel Marques @ 2005-02-24 10:39 UTC (permalink / raw)
  To: binutils

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

Hello.

I would like to propose the attached patch to objectcopy.c.

This patch adds the command-line flag '--globalize-symbol <name>', which 
will "force symbol <name> to be marked as global". In effect, it does 
the inverse of the '--localize-symbol <name>' flag.

As globalizing a symbol is not necessarily safe, usually one would 
redefine it at the same time:
	/objcopy --redefine-sym local4=fixed_local4 --globalize-symbol 
fixed_local4 a.o

The order of the relative operations is important.

This feature will be useful for "printf-style" debugging of a library 
from a client.  It will be very useful for 
application-level-checkpointing, when a code intermittently writes its 
state to disk, and needs to be able to copy the data held in a library.

Please let me know what you think.

Thanks.

Dan

[-- Attachment #2: patch.objectcopy --]
[-- Type: text/plain, Size: 2795 bytes --]

Index: objcopy.c
===================================================================
RCS file: /cvs/src/src/binutils/objcopy.c,v
retrieving revision 1.74
diff -u -r1.74 objcopy.c
--- objcopy.c	22 Feb 2005 00:50:06 -0000	1.74
+++ objcopy.c	24 Feb 2005 00:03:23 -0000
@@ -195,6 +195,7 @@
 static struct symlist *strip_unneeded_list = NULL;
 static struct symlist *keep_specific_list = NULL;
 static struct symlist *localize_specific_list = NULL;
+static struct symlist *globalize_specific_list = NULL;
 static struct symlist *keepglobal_specific_list = NULL;
 static struct symlist *weaken_specific_list = NULL;
 static struct redefine_node *redefine_sym_list = NULL;
@@ -236,6 +237,7 @@
     OPTION_STRIP_UNNEEDED_SYMBOLS,
     OPTION_KEEP_SYMBOLS,
     OPTION_LOCALIZE_SYMBOLS,
+    OPTION_GLOBALIZE_SYMBOL, 
     OPTION_KEEPGLOBAL_SYMBOLS,
     OPTION_WEAKEN_SYMBOLS,
     OPTION_RENAME_SECTION,
@@ -306,6 +308,7 @@
   {"discard-locals", no_argument, 0, 'X'},
   {"format", required_argument, 0, 'F'}, /* Obsolete */
   {"gap-fill", required_argument, 0, OPTION_GAP_FILL},
+  {"globalize-symbol", required_argument, 0, OPTION_GLOBALIZE_SYMBOL},
   {"help", no_argument, 0, 'h'},
   {"impure", no_argument, 0, OPTION_IMPURE},
   {"info", no_argument, 0, OPTION_FORMATS_INFO},
@@ -416,6 +419,7 @@
      --only-keep-debug             Strip everything but the debug information\n\
   -K --keep-symbol <name>          Only copy symbol <name>\n\
   -L --localize-symbol <name>      Force symbol <name> to be marked as a local\n\
+     --globalize-symbol <name>     Force symbol <name> to be marked as a global\n\
   -G --keep-global-symbol <name>   Localize all symbols except <name>\n\
   -W --weaken-symbol <name>        Force symbol <name> to be marked as a weak\n\
      --weaken                      Force all global symbols to be marked as weak\n\
@@ -937,6 +941,12 @@
 	  sym->flags &= ~(BSF_GLOBAL | BSF_WEAK);
 	  sym->flags |= BSF_LOCAL;
 	}
+      if (keep && !undefined && (flags & BSF_LOCAL) 
+	  && ( (globalize_specific_list != NULL) && is_specified_symbol (name, globalize_specific_list)))
+	{
+	  sym->flags &= ~(BSF_LOCAL);
+	  sym->flags |= BSF_GLOBAL;
+	}
 
       if (keep)
 	to[dst_count++] = sym;
@@ -1389,6 +1399,7 @@
       || strip_specific_list != NULL
       || keep_specific_list != NULL
       || localize_specific_list != NULL
+      || globalize_specific_list != NULL
       || keepglobal_specific_list != NULL
       || weaken_specific_list != NULL
       || prefix_symbols_string
@@ -2548,6 +2559,10 @@
 	  add_specific_symbol (optarg, &localize_specific_list);
 	  break;
 
+	case OPTION_GLOBALIZE_SYMBOL:
+	  add_specific_symbol (optarg, &globalize_specific_list);		
+	  break;
+
 	case 'G':
 	  add_specific_symbol (optarg, &keepglobal_specific_list);
 	  break;

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Proposed patch to objectcopy.c
  2005-02-24 10:39 Proposed patch to objectcopy.c Daniel Marques
@ 2005-03-01 11:44 ` Nick Clifton
  2005-03-15 17:44 ` Nick Clifton
  1 sibling, 0 replies; 3+ messages in thread
From: Nick Clifton @ 2005-03-01 11:44 UTC (permalink / raw)
  To: Daniel Marques; +Cc: binutils

Hi Daniel,

> This patch adds the command-line flag '--globalize-symbol <name>', which 
> will "force symbol <name> to be marked as global". In effect, it does 
> the inverse of the '--localize-symbol <name>' flag.

> Please let me know what you think.

This is just to let you know that I have not forgotten about this patch 
but I am going to wait until after the 2.16 branch has been taken to 
review it.  I think that a new feature like this, which has the 
potential to introduce sublte new bugs, should wait until after the 
branch.  That way there will be lots of time to test it before releasing 
it to the public at large.

Cheers
   Nick


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Proposed patch to objectcopy.c
  2005-02-24 10:39 Proposed patch to objectcopy.c Daniel Marques
  2005-03-01 11:44 ` Nick Clifton
@ 2005-03-15 17:44 ` Nick Clifton
  1 sibling, 0 replies; 3+ messages in thread
From: Nick Clifton @ 2005-03-15 17:44 UTC (permalink / raw)
  To: Daniel Marques; +Cc: binutils

Hi Daniel,

> I would like to propose the attached patch to objectcopy.c.
> 
> This patch adds the command-line flag '--globalize-symbol <name>', which 
> will "force symbol <name> to be marked as global". In effect, it does 
> the inverse of the '--localize-symbol <name>' flag.

I like it.  The patch is relatively clean and simple and I can see how 
it might be useful.  I have therefore decided to apply it to the 
mainline sources along with these three changes:

   1.  I have added a "--globalize-symbols=<file>" switch along the 
lines of the "--localize-symbols=<file>" switch, so that multiple 
symbols can be easily converted by placing their names into a file.

   2.  I have added documentation to the binutils.texi file and 
mentioned in the new feature in the NEWS file.

   3.  I have created this ChangeLog entry to go along with the changes:

binutils/ChangeLog
2005-03-15  Daniel Marques  <marques@cs.cornell.edu>
             Nick Clifton  <nickc@redhat.com>

	* objcopy.c (globalize_specific_list): New linked list of symbols
	to convert from local binding into global binding.
	(command_line_switch): Add OPTION_GLOBALIZE_SYMBOL and
	OPTION_GLOBALIZE_SYMBOLS.
	(copy_options): Add "globalize-symbol" and "globalize-symbols".
	(copy_usage): Document the new switches.
	(filter_symbols): Convert defined local symbols mentioned on the
	globalize_specific_list into global symbols.
	(copy_object): Perform actions if the globalize_specific_list is
	not empty.
	(copy_main): Handle new switches.
	* NEWS: Mention new feature.
	* doc/binutils.texi: Document new switches.
Cheers
   Nick

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-03-15 17:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-24 10:39 Proposed patch to objectcopy.c Daniel Marques
2005-03-01 11:44 ` Nick Clifton
2005-03-15 17:44 ` Nick Clifton

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).