bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: strip_unneeded removes to much symbols


From: Nick Clifton
Subject: Re: strip_unneeded removes to much symbols
Date: 24 May 2001 10:43:04 +0100
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7

Hi Reinhard,

> If I use mingw32-strip --strip-debug on the libraries and link my
> executable, all works as expected. But if I use --strip-unneeded and
> try to link I get an error about a not found symbol.

My apologies for taking so long to get back to you.

I believe that I have now found the cause of this problem.  Strip is
removing the symbol because it thinks that it is not being used by any
relocations.  In fact it isn't. at least not inside the library.  The
problem is that the symbol is referenced from the code in your
application, and strip had know way of knowing this.

Well actually, it could have guessed.  I am attaching a patch below
which will prevent strip from removing global symbols in $idata
sections.  This should fix the problem.  It certainly does appear to
work for the test case you sent.

Please  apply this patch, rebuild strip, and then test it.  If you let
know if it works, I will then check the patch into the sources.

Cheers
        Nick

2001-05-24  Nick Clifton  <address@hidden>

        * objcopy.c (filter_symbols): Do not strip global symbols in
        $idata sections as they may be referenced from object files
        outside of the current archive.

Index: binutils/objcopy.c
===================================================================
RCS file: /cvs/src/src/binutils/objcopy.c,v
retrieving revision 1.17
diff -p -r1.17 objcopy.c
*** objcopy.c   2001/03/13 06:43:57     1.17
--- objcopy.c   2001/05/24 08:40:56
*************** filter_symbols (abfd, obfd, osyms, isyms
*** 636,641 ****
--- 636,647 ----
        else if (relocatable                    /* Relocatable file. */
               && (flags & (BSF_GLOBAL | BSF_WEAK)) != 0)
        keep = 1;
+       else if (bfd_decode_symclass (sym) == 'I')
+       /* Global symbols in $idata sections need to be retained
+          even if relocatable is false.  External users of the
+          library containing the $idata section may reference these
+          symbols.  */
+         keep = 1;
        else if ((flags & BSF_GLOBAL) != 0      /* Global symbol.  */
               || (flags & BSF_WEAK) != 0
               || bfd_is_und_section (bfd_get_section (sym))





reply via email to

[Prev in Thread] Current Thread [Next in Thread]