diff options
-rw-r--r-- | binutils/objcopy.c | 31 | ||||
-rw-r--r-- | binutils/testsuite/binutils-all/symbols-5.d | 8 | ||||
-rw-r--r-- | binutils/testsuite/binutils-all/symbols-5.s | 3 |
3 files changed, 27 insertions, 15 deletions
diff --git a/binutils/objcopy.c b/binutils/objcopy.c index 26f9d4a..f54ae73 100644 --- a/binutils/objcopy.c +++ b/binutils/objcopy.c @@ -1730,14 +1730,6 @@ filter_symbols (bfd *abfd, bfd *obfd, asymbol **osyms, if (keep) { - if (((flags & (BSF_GLOBAL | BSF_GNU_UNIQUE)) - || undefined) - && (weaken || is_specified_symbol (name, weaken_specific_htab))) - { - sym->flags &= ~ (BSF_GLOBAL | BSF_GNU_UNIQUE); - sym->flags |= BSF_WEAK; - } - if (!undefined && (flags & (BSF_GLOBAL | BSF_WEAK)) && (is_specified_symbol (name, localize_specific_htab) @@ -1745,18 +1737,27 @@ filter_symbols (bfd *abfd, bfd *obfd, asymbol **osyms, && ! is_specified_symbol (name, keepglobal_specific_htab)) || (localize_hidden && is_hidden_symbol (sym)))) { - sym->flags &= ~ (BSF_GLOBAL | BSF_WEAK); - sym->flags |= BSF_LOCAL; + flags &= ~(BSF_GLOBAL | BSF_WEAK); + flags |= BSF_LOCAL; } - if (!undefined - && (flags & BSF_LOCAL) - && is_specified_symbol (name, globalize_specific_htab)) + else if (!undefined + && (flags & BSF_LOCAL) + && is_specified_symbol (name, globalize_specific_htab)) + { + flags &= ~BSF_LOCAL; + flags |= BSF_GLOBAL; + } + + if (((flags & (BSF_GLOBAL | BSF_GNU_UNIQUE)) + || undefined) + && (weaken || is_specified_symbol (name, weaken_specific_htab))) { - sym->flags &= ~ BSF_LOCAL; - sym->flags |= BSF_GLOBAL; + flags &= ~(BSF_GLOBAL | BSF_GNU_UNIQUE); + flags |= BSF_WEAK; } + sym->flags = flags; to[dst_count++] = sym; } } diff --git a/binutils/testsuite/binutils-all/symbols-5.d b/binutils/testsuite/binutils-all/symbols-5.d new file mode 100644 index 0000000..ffaa950 --- /dev/null +++ b/binutils/testsuite/binutils-all/symbols-5.d @@ -0,0 +1,8 @@ +#name: globalize and weaken 'foo' +#PROG: objcopy +#objcopy: --globalize-symbol foo -W foo +#source: symbols-5.s +#nm: -n + +#... +0+ [VW] foo diff --git a/binutils/testsuite/binutils-all/symbols-5.s b/binutils/testsuite/binutils-all/symbols-5.s new file mode 100644 index 0000000..aa01b9e --- /dev/null +++ b/binutils/testsuite/binutils-all/symbols-5.s @@ -0,0 +1,3 @@ + .text +foo: + .word 0x0 |