public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Michael Tokarev <mjt@tls.msk.ru>
To: Andrew Pinski <pinskia@gmail.com>
Cc: binutils <binutils@sourceware.org>
Subject: Re: puzzling ld behavior, failing to find symbols from .so after adding more .o file
Date: Sat, 26 Mar 2022 18:06:26 +0300	[thread overview]
Message-ID: <c5077107-ad8d-2f91-0908-35bc686b0e03@msgid.tls.msk.ru> (raw)
In-Reply-To: <CA+=Sn1=WzrnnKu2e8ki-SECDaBP=98+qSvChNFc8JkgZzAWdYQ@mail.gmail.com>

26.03.2022 03:25, Andrew Pinski wrote:
> 
> One thing to try is to add -Wl,--no-as-needed (and remove
> -Wl,--as-needed) and see if that helps.

adding --no-as-needed to the beginning and removing --as-needed
at the end does not change anything.

> My bet is there are some ordering issues.

in my tests, I add independent object files to the link line
one by one. More, I keep all the -lfoo at their places, -
in order to replace libfooo.so with libfoo.a, I *remove*
libfoo.so file, so the linker finds only the .a variant.
All the other stuff is here, order stays the same.

..
>> /usr/bin/ld: ./bin/default/../../source3/lib/dbwrap/dbwrap_ctdb.c:1639: undefined reference to `tdb_null'
>> /usr/bin/ld: source3/lib/dbwrap/dbwrap_ctdb.c.45.o: relocation R_X86_64_PC32 against undefined hidden symbol `tdb_null' can not be used when making a
>> shared object

Someone on the IRC told me this:

<trofi> R_X86_64_PC32 is is a relocation required to be local to the module. Note it's not GOT-relative.
<trofi> you need to check how tdb_null is declared when it's compiled

I don't know what is a relocation required to be local or
what is GOT-relative. But I do know there are several
different possibilities for libtdb compilation.

The thing is: it is samba, and the libraries in question
are libraries internal to samba, which were built separately,
and samba is told to use system version of these libs. Maybe
the whole thing is because the build "mixes" system libs and
internal headers with different symbol flags/definitions?

So far, it *seems* the whole thing breaks once I add any .o
file which uses tdb.h/libtdb.  Not yet sure about this, since
I can't add any object file into the mix due to inter-object-file
deps (so I'm adding only the simplest self-contained ones),
but all self-containing tdb-using ones gives this surprize
result.

Where one can see which variant of the symbol an object file
wants compared to the variant which is provided by an .so file?
Which variants are possible?

Thank you!

/mjt

  reply	other threads:[~2022-03-26 15:06 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-25 20:15 Michael Tokarev
2022-03-25 22:43 ` Andrew Bell
2022-03-26 14:56   ` Michael Tokarev
2022-03-26  0:25 ` Andrew Pinski
2022-03-26 15:06   ` Michael Tokarev [this message]
2022-03-26 15:19     ` Michael Tokarev
2022-03-30  1:50       ` Alan Modra
2022-03-26 15:19 ` Andreas Schwab

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c5077107-ad8d-2f91-0908-35bc686b0e03@msgid.tls.msk.ru \
    --to=mjt@tls.msk.ru \
    --cc=binutils@sourceware.org \
    --cc=pinskia@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).