From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH] libaio: Fix library creation for ARC with -Os
Date: Tue, 18 Sep 2018 11:15:06 +0200 [thread overview]
Message-ID: <20180918111506.0648d78c@windsurf> (raw)
In-Reply-To: <c9ec03f9f05e251fd8e7b99c0ffb06593db32b1c.camel@synopsys.com>
Hello,
On Tue, 18 Sep 2018 08:03:19 +0000, Alexey Brodkin wrote:
> This is how libaio.so is linked now (before my patch) with
> omitted some non-important options:
> ----------------------->8-------------------
> arc-buildroot-linux-uclibc-gcc -shared -matomic -Os -nostdlib -nostartfiles -fPIC \
> -o libaio.so io_queue_init.os io_queue_release.os io_queue_wait.os io_queue_run.os \
> io_getevents.os io_submit.os io_cancel.os io_setup.os io_destroy.os raw_syscall.os compat-0_1.os
> ----------------------->8-------------------
>
> And that's what happens with my patch:
> ----------------------->8-------------------
> arc-buildroot-linux-uclibc-gcc -shared -matomic -Os -nostdlib -nostartfiles -fPIC \
> -o libaio.so io_queue_init.os io_queue_release.os io_queue_wait.os io_queue_run.os \
> io_getevents.os io_submit.os io_cancel.os io_setup.os io_destroy.os raw_syscall.os compat-0_1.os -lgcc
> ----------------------->8-------------------
>
> Note "-lgcc" in the latter case.
Thank you, I do understand that passing LDFLAGS=-lgcc will add -lgcc to
the link command line :-)
The question is: why does libaio needs to be told explicitly to link
against libgcc, and not any other package.
And I believe the reason is because -nostdlib -nostartfiles are used.
Why is libaio using those flags? Is there a good reason ?
> Now let's see what happens with millicode symbols in both cases.
> Pre-patch case:
> ----------------------->8-------------------
> # arc-linux-gnu-readelf -s libaio.so | grep __st_r13_to_r17
> 3: 00000000 0 NOTYPE GLOBAL DEFAULT UND __st_r13_to_r17
> 41: 00000000 0 NOTYPE GLOBAL DEFAULT UND __st_r13_to_r17
> ----------------------->8-------------------
>
> Note millicode's "__st_r13_to_r17" is GLOBAL UNDEFINED symbol.
> Thus during linkage of the final application that symbol will
> need to be resolved and LD finds it in libgcc.a and essentially
> refuses to proceed as there's no way for shared library to
> use a function that is implemented in a different static library.
>
> Post-patch case:
> ----------------------->8-------------------
> # arc-linux-gnu-readelf -s libaio.so | grep __st_r13_to_r17
> 38: 000006cc 18 FUNC LOCAL DEFAULT 9 __st_r13_to_r17
> ----------------------->8-------------------
>
> Note "__st_r13_to_r17" is locally defined so shared library doesn't
> need anything from libgcc.a.
Indeed.
> > Why is this problem happening only with libaio, and not with other
> > packages ?
>
> That's a good question :)
> I may assume other shared libs gets linked with libgcc.a, i.e. all
> symbols from libgcc including millicode get built into libXXX.so.
See above: -nostdlib -nostartfiles are used in libaio. That's the
difference. The question is why libaio is using those flags.
Best regards,
Thomas
--
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
next prev parent reply other threads:[~2018-09-18 9:15 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-17 20:43 [Buildroot] [PATCH] libaio: Fix library creation for ARC with -Os Alexey Brodkin
2018-09-18 7:36 ` Thomas Petazzoni
2018-09-18 8:03 ` Alexey Brodkin
2018-09-18 9:15 ` Thomas Petazzoni [this message]
2018-09-18 9:17 ` Alexey Brodkin
2018-09-18 9:26 ` Thomas Petazzoni
2018-09-18 9:30 ` Alexey Brodkin
[not found] ` <098ECE41A0A6114BB2A07F1EC238DE89667FD144@de02wembxa.internal.synopsys.com>
2018-09-18 12:44 ` Alexey Brodkin
2018-09-18 13:58 ` Thomas Petazzoni
2018-09-28 13:36 ` Alexey Brodkin
2018-09-18 9:20 ` Thomas Petazzoni
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=20180918111506.0648d78c@windsurf \
--to=thomas.petazzoni@bootlin.com \
--cc=buildroot@busybox.net \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.