From d812147943601bc96ee06cf70b9339a868290c59 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Sun, 14 May 2000 17:13:16 +0000 Subject: [PATCH] 2000-05-14 H.J. Lu (hjl@gnu.org) * objcopy.c (filter_symbols): Don't strip global symbols in relocatable object files. --- binutils/ChangeLog | 5 +++++ binutils/objcopy.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 0403f87fd30..7ee94d4ae74 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,8 @@ +2000-05-14 H.J. Lu (hjl@gnu.org) + + * objcopy.c (filter_symbols): Don't strip global symbols in + relocatable object files. + 2000-05-14 Alan Modra * size.c (usage): Associate short options with corresponding long diff --git a/binutils/objcopy.c b/binutils/objcopy.c index 0d778a36c65..36d5f4c76e3 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)) -- 2.30.2