Discussion:
[PATCH] [objcopy] Return a fatal error when --keep-global-symbol(s) is used with --globalize-symbols, since it is an error prone pattern.
Jordan Rupprecht via binutils
2018-10-09 21:16:16 UTC
Permalink
For more context, see https://sourceware.org/ml/binutils/2018-09/msg00031.html
---
binutils/objcopy.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index 9af3c1eb1b..33ca452e8b 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -4753,6 +4753,8 @@ copy_main (int argc, char *argv[])
bfd_boolean show_version = FALSE;
bfd_boolean change_warn = TRUE;
bfd_boolean formats_info = FALSE;
+ bfd_boolean use_globalize = FALSE;
+ bfd_boolean use_keep_global = FALSE;
int c;
struct stat statbuf;
const bfd_arch_info_type *input_arch = NULL;
@@ -4871,10 +4873,12 @@ copy_main (int argc, char *argv[])
break;

case OPTION_GLOBALIZE_SYMBOL:
+ use_globalize = TRUE;
add_specific_symbol (optarg, globalize_specific_htab);
break;

case 'G':
+ use_keep_global = TRUE;
add_specific_symbol (optarg, keepglobal_specific_htab);
break;

@@ -5306,11 +5310,13 @@ copy_main (int argc, char *argv[])
break;

case OPTION_GLOBALIZE_SYMBOLS:
+ use_globalize = TRUE;
add_specific_symbols (optarg, globalize_specific_htab,
&globalize_specific_buffer);
break;

case OPTION_KEEPGLOBAL_SYMBOLS:
+ use_keep_global = TRUE;
add_specific_symbols (optarg, keepglobal_specific_htab,
&keepglobal_specific_buffer);
break;
@@ -5444,6 +5450,9 @@ copy_main (int argc, char *argv[])
default:
copy_usage (stderr, 1);
}
+ if (use_globalize && use_keep_global)
+ fatal(_("--globalize-symbol(s) may not be used with -G or "
+ "--keep-global-symbol(s)"));
}

if (formats_info)
--
2.19.0.605.g01d371f741-goog
Nick Clifton
2018-10-11 10:44:43 UTC
Permalink
Hi Jordan,

Thanks very much for the patch. It is fine, and I have applied it
to the binutils sources. I did make a couple of additions:

* I updated the documentation to mention that the two options should
not be used together.

* I added a test to the binutils testsuite to make sure that the
error message is produced.

* I created an entry in the binutils/ChangeLog file describing the
patch.

Cheers
Nick

PS. Since the patch was quite simple, I have treated it as "obvious"
which means that you do not need a FSF copyright assignment. If
however in the future you wish to contribute bigger patches - and I
hope that you will - then you will need a copyright assignment in
place.

Loading...