This is the mail archive of the
binutils@sourceware.cygnus.com
mailing list for the binutils project.
Re: Patch for strip
On Sat, May 13, 2000 at 10:32:35PM +1000, Alan Modra wrote:
> On Sat, 13 May 2000, Guido Flohr wrote:
>
> > On Sat, May 13, 2000 at 12:37:18PM +1000, Alan Modra wrote:
> > > I'm inclined to just say that running strip on a relocatable file is a
> > > silly thing to do.
> >
> > Why is it silly to strip debug symbols from a relocatable file?
>
> It isn't. I spoke too quickly.
>
I updated my patch according to Ian's comment. I will check in if I
don't hear any objetions by tomorrow.
H.J.
----
2000-05-12 H.J. Lu (hjl@gnu.org)
* objcopy.c (filter_symbols): Don't strip global symbols in
relocatable object files.
Index: objcopy.c
===================================================================
RCS file: /work/cvs/gnu/binutils/binutils/objcopy.c,v
retrieving revision 1.10
diff -u -p -r1.10 objcopy.c
--- objcopy.c 2000/05/12 15:11:30 1.10
+++ objcopy.c 2000/05/13 16:13:31
@@ -556,7 +556,11 @@ filter_symbols (abfd, obfd, osyms, isyms
{
register asymbol **from = isyms, **to = osyms;
long src_count = 0, dst_count = 0;
+ int relocatable;
+ relocatable = (abfd->flags & (HAS_RELOC | EXEC_P | DYNAMIC))
+ == HAS_RELOC;
+
for (; src_count < symcount; src_count++)
{
asymbol *sym = from[src_count];
@@ -609,6 +613,9 @@ filter_symbols (abfd, obfd, osyms, isyms
|| ((flags & BSF_SECTION_SYM) != 0
&& ((*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