public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/61395] New: Linker cannot find symbols in object files compiled with recent GCC
@ 2014-06-02 21:16 mimamer at gmail dot com
  2014-06-02 21:19 ` [Bug c/61395] " pinskia at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: mimamer at gmail dot com @ 2014-06-02 21:16 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61395

            Bug ID: 61395
           Summary: Linker cannot find symbols in object files compiled
                    with recent GCC
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mimamer at gmail dot com

Apologies in advance for any mistakes in posting this bug report. If what I am
describing is not a bug in GCC please direct me to a place where I can ask for
help on this issue -- thanks!

I recently upgraded from GCC 4.3.4 to 4.9.0, which I set up as a cross compiler
from i686-pc-cygwin to i686-pc-elf together with static and shared libgcc
support. I created a shared libgcc.so version from libgcc.a using 'ld' and
specifying --whole-archive (as well as the other usual flags). Now, when I try
to link even a very simple test program that emits a symbol defined in a shared
library such as libgcc.so the link step fails with GCC/ld complaining that the
symbol (e.g., __divdi3) cannot be found. I can verify that the symbol is
available in libgcc.so's .symtab (as FUNC LOCAL DEFAULT 12) and specified in
main.o's .symtab (as NOTYPE GLOBAL DEFAULT UND), yet when I try to link main.o
with -lgcc (or libgcc.so) I get "Undefined reference to `__divdi3'". Upgrading
the linker did not have any effect. I can also verify that the linker finds all
input files in the right places, so I am completely at lost what is going wrong
here, and though I suspect a compiler bug (since this did work for me with GCC
4.3.4) I may easily be wrong. Apologies again!


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c/61395] Linker cannot find symbols in object files compiled with recent GCC
  2014-06-02 21:16 [Bug c/61395] New: Linker cannot find symbols in object files compiled with recent GCC mimamer at gmail dot com
@ 2014-06-02 21:19 ` pinskia at gcc dot gnu.org
  2014-06-02 21:24 ` mimamer at gmail dot com
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2014-06-02 21:19 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61395

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                URL|                            |c support. I created a
                   |                            |shared libgcc.so version
                   |                            |from libgcc.a using 'ld'
                   |                            |and specifying
                   |                            |--whole-archive (as well as
                   |                            |the other usual flags).
                   |                            |Now, when I try to link
                   |                            |even a very simple test
                   |                            |program that emits a symbol
                   |                            |defined in a shared library
                   |                            |such as libgcc.so the link
                   |                            |step fails with GCC/ld
                   |                            |complaining that the symbol
                   |                            |(e.g., __divdi3) cannot be
                   |                            |found. I can verify that
                   |                            |the symbol is available in
                   |                            |libgcc.so's .symtab (as
                   |                            |FUNC LOCAL DEFAULT 12) and
                   |                            |specified in main.o's
                   |                            |.symtab (as NOTYPE GLOBAL
                   |                            |DEFAULT UND), yet when I
                   |                            |try to link main.o with
                   |                            |-lgcc (or libgcc.so) I get
                   |                            |"Undefined reference to
                   |                            |`__divdi3'". Upgrading the
                   |                            |linker did not have any
                   |                            |effect. I can also verify
                   |                            |that the linker finds all
                   |                            |input files in the right
                   |                            |places, so I am completely
                   |                            |at lost what is going wrong
         Resolution|---                         |INVALID

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The symbols in libgcc.a are marked as hidden.  This is the wrong way to build a
shared library version.  Also -elf targets don't support shared libraries at
all.  If this is your own target, you should create a new target triplet
instead of reusing the -elf ones.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c/61395] Linker cannot find symbols in object files compiled with recent GCC
  2014-06-02 21:16 [Bug c/61395] New: Linker cannot find symbols in object files compiled with recent GCC mimamer at gmail dot com
  2014-06-02 21:19 ` [Bug c/61395] " pinskia at gcc dot gnu.org
@ 2014-06-02 21:24 ` mimamer at gmail dot com
  2014-06-02 21:26 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: mimamer at gmail dot com @ 2014-06-02 21:24 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61395

mimamer at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|INVALID                     |FIXED

--- Comment #2 from mimamer at gmail dot com ---
Well, since this did work for 4.3.4, what is the proper way to build libgcc.so?
No, I cannot specify my own triplet, the target is a custom OS under
development.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c/61395] Linker cannot find symbols in object files compiled with recent GCC
  2014-06-02 21:16 [Bug c/61395] New: Linker cannot find symbols in object files compiled with recent GCC mimamer at gmail dot com
  2014-06-02 21:19 ` [Bug c/61395] " pinskia at gcc dot gnu.org
  2014-06-02 21:24 ` mimamer at gmail dot com
@ 2014-06-02 21:26 ` pinskia at gcc dot gnu.org
  2014-06-02 23:02 ` mimamer at gmail dot com
  2014-06-02 23:20 ` mimamer at gmail dot com
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2014-06-02 21:26 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61395

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to mimamer from comment #2)
> Well, since this did work for 4.3.4, what is the proper way to build
> libgcc.so? 

The proper way is to edit the t-* files under libgcc for your target.

> No, I cannot specify my own triplet, the target is a custom OS
> under development.

That is an incorrect, you can define your own new triplet something like
arch-*-miameros .


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c/61395] Linker cannot find symbols in object files compiled with recent GCC
  2014-06-02 21:16 [Bug c/61395] New: Linker cannot find symbols in object files compiled with recent GCC mimamer at gmail dot com
                   ` (2 preceding siblings ...)
  2014-06-02 21:26 ` pinskia at gcc dot gnu.org
@ 2014-06-02 23:02 ` mimamer at gmail dot com
  2014-06-02 23:20 ` mimamer at gmail dot com
  4 siblings, 0 replies; 6+ messages in thread
From: mimamer at gmail dot com @ 2014-06-02 23:02 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61395

--- Comment #4 from mimamer at gmail dot com ---
I'm sorry to bother you one more time. All symbols are marked as hidden in
libgcc.a, true. But they become "local default" when I create a shared
libgcc.so from it. Just to help me understand what is going on I tried
globalizing the __divdi symbol in my libgcc.so with objcopy, but I still cannot
successfully link it. Why? (Thanks again.) (And btw, creating my own t-* files
seems like horror.)


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c/61395] Linker cannot find symbols in object files compiled with recent GCC
  2014-06-02 21:16 [Bug c/61395] New: Linker cannot find symbols in object files compiled with recent GCC mimamer at gmail dot com
                   ` (3 preceding siblings ...)
  2014-06-02 23:02 ` mimamer at gmail dot com
@ 2014-06-02 23:20 ` mimamer at gmail dot com
  4 siblings, 0 replies; 6+ messages in thread
From: mimamer at gmail dot com @ 2014-06-02 23:20 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61395

mimamer at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |CLOSED
         Resolution|FIXED                       |INVALID

--- Comment #5 from mimamer at gmail dot com ---
(change status to INVALID, erroneously had it changed before)


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-06-02 23:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-02 21:16 [Bug c/61395] New: Linker cannot find symbols in object files compiled with recent GCC mimamer at gmail dot com
2014-06-02 21:19 ` [Bug c/61395] " pinskia at gcc dot gnu.org
2014-06-02 21:24 ` mimamer at gmail dot com
2014-06-02 21:26 ` pinskia at gcc dot gnu.org
2014-06-02 23:02 ` mimamer at gmail dot com
2014-06-02 23:20 ` mimamer at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).