mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] lib/clz_tab.c: put in lib-y rather than obj-y
@ 2015-12-22 17:41 Chris Metcalf
  2015-12-22 17:46 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Chris Metcalf @ 2015-12-22 17:41 UTC (permalink / raw)
  To: linux-kernel, Al Viro, David S. Miller, James Morris, Andrew Morton
  Cc: Chris Metcalf, Sudip Mukherjee

The clz table (__clz_tab) in lib/clz_tab.c is also provided as part
of libgcc.a, and many architectures link against libgcc.  To allow
the linker to avoid a multiple-definition link failure, clz_tab.o
has to be in lib/lib.a rather than lib/builtin.o.  The specific
issue is that libgcc.a comes before lib/builtin.o on vmlinux.o's
link command line, so its _clz.o is pulled to satisfy __clz_tab,
and then when the remainder of lib/builtin.o is pulled in to satisfy
all the other dependencies, the __clz_tab symbols conflict.  By
putting clz_tab.o in lib.a, the linker can simply avoid pulling
it into vmlinux.o when this situation arises.

The definitions of __clz_tab are the same in libgcc.a and in the
kernel; arguably we could also simply rename the kernel version,
but it's unlikely the libgcc version will ever change to become
incompatible, so just using it seems reasonably safe.

Signed-off-by: Chris Metcalf <cmetcalf@ezchip.com>
---
I have this in the tile tree for linux-next since it broke tilepro,
but perhaps it makes more sense for it to get pushed through
Andrew's tree or somewhere else?

 lib/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/Makefile b/lib/Makefile
index 7f1de26613d2..8487893b4deb 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -153,7 +153,7 @@ obj-$(CONFIG_GLOB) += glob.o
 obj-$(CONFIG_MPILIB) += mpi/
 obj-$(CONFIG_SIGNATURE) += digsig.o
 
-obj-$(CONFIG_CLZ_TAB) += clz_tab.o
+lib-$(CONFIG_CLZ_TAB) += clz_tab.o
 
 obj-$(CONFIG_DDR) += jedec_ddr_data.o
 
-- 
2.1.2


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

* Re: [PATCH] lib/clz_tab.c: put in lib-y rather than obj-y
  2015-12-22 17:41 [PATCH] lib/clz_tab.c: put in lib-y rather than obj-y Chris Metcalf
@ 2015-12-22 17:46 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2015-12-22 17:46 UTC (permalink / raw)
  To: cmetcalf; +Cc: linux-kernel, viro, jmorris, akpm, sudipm.mukherjee

From: Chris Metcalf <cmetcalf@ezchip.com>
Date: Tue, 22 Dec 2015 12:41:24 -0500

> The clz table (__clz_tab) in lib/clz_tab.c is also provided as part
> of libgcc.a, and many architectures link against libgcc.  To allow
> the linker to avoid a multiple-definition link failure, clz_tab.o
> has to be in lib/lib.a rather than lib/builtin.o.  The specific
> issue is that libgcc.a comes before lib/builtin.o on vmlinux.o's
> link command line, so its _clz.o is pulled to satisfy __clz_tab,
> and then when the remainder of lib/builtin.o is pulled in to satisfy
> all the other dependencies, the __clz_tab symbols conflict.  By
> putting clz_tab.o in lib.a, the linker can simply avoid pulling
> it into vmlinux.o when this situation arises.
> 
> The definitions of __clz_tab are the same in libgcc.a and in the
> kernel; arguably we could also simply rename the kernel version,
> but it's unlikely the libgcc version will ever change to become
> incompatible, so just using it seems reasonably safe.
> 
> Signed-off-by: Chris Metcalf <cmetcalf@ezchip.com>

No objections from me:

Acked-by: David S. Miller <davem@davemloft.net>

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

end of thread, other threads:[~2015-12-22 17:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-22 17:41 [PATCH] lib/clz_tab.c: put in lib-y rather than obj-y Chris Metcalf
2015-12-22 17:46 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®