aboutsummaryrefslogtreecommitdiff
path: root/binutils/objcopy.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2000-05-14 17:13:16 +0000
committerH.J. Lu <hjl.tools@gmail.com>2000-05-14 17:13:16 +0000
commitd812147943601bc96ee06cf70b9339a868290c59 (patch)
tree9ae47e8b3c43e9b741d9e7ac39a3b289dbe98370 /binutils/objcopy.c
parent4132022df14e11a413f383a14042b49c663979ba (diff)
downloadgdb-d812147943601bc96ee06cf70b9339a868290c59.zip
gdb-d812147943601bc96ee06cf70b9339a868290c59.tar.gz
gdb-d812147943601bc96ee06cf70b9339a868290c59.tar.bz2
2000-05-14 H.J. Lu (hjl@gnu.org)
* objcopy.c (filter_symbols): Don't strip global symbols in relocatable object files.
Diffstat (limited to 'binutils/objcopy.c')
-rw-r--r--binutils/objcopy.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index 0d778a3..36d5f4c 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -556,6 +556,8 @@ filter_symbols (abfd, obfd, osyms, isyms, symcount)
{
register asymbol **from = isyms, **to = osyms;
long src_count = 0, dst_count = 0;
+ int relocatable = (abfd->flags & (HAS_RELOC | EXEC_P | DYNAMIC))
+ == HAS_RELOC;
for (; src_count < symcount; src_count++)
{
@@ -610,6 +612,9 @@ filter_symbols (abfd, obfd, osyms, isyms, symcount)
&& ((*bfd_get_section (sym)->symbol_ptr_ptr)->flags
& BSF_KEEP) != 0))
keep = 1;
+ else if (relocatable /* Relocatable file. */
+ && (flags & (BSF_GLOBAL | BSF_WEAK)) != 0)
+ keep = 1;
else if ((flags & BSF_GLOBAL) != 0 /* Global symbol. */
|| (flags & BSF_WEAK) != 0
|| bfd_is_und_section (bfd_get_section (sym))