This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Proposed patch to objectcopy.c


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]