public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Daniel Marques <marques@cs.cornell.edu>
To: binutils@sources.redhat.com
Subject: Proposed patch to objectcopy.c
Date: Thu, 24 Feb 2005 10:39:00 -0000	[thread overview]
Message-ID: <421D209E.4060502@cs.cornell.edu> (raw)

[-- 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;

             reply	other threads:[~2005-02-24  0:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-24 10:39 Daniel Marques [this message]
2005-03-01 11:44 ` Nick Clifton
2005-03-15 17:44 ` Nick Clifton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=421D209E.4060502@cs.cornell.edu \
    --to=marques@cs.cornell.edu \
    --cc=binutils@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).