aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2016-01-15 14:01:22 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2016-08-07 23:46:30 -0400
commit7f2084fa55e6cb61f61b4224d4a8bafaeee55f9f (patch)
tree4f9f5e144b7b452f32d6d6132cad6d744f93a189 /scripts
parent29b4817d4018df78086157ea3a55c1d9424a7cfc (diff)
[kbuild] handle exports in lib-y objects reliably
Collect the symbols exported by anything that goes into lib.a and add an empty object (lib-exports.o) with explicit undefs for each of those to obj-y. That allows to relax the rules regarding the use of exports in lib-* objects - right now an object with export can be in lib-* only if we are guaranteed that there always will be users in built-in parts of the tree, otherwise it needs to be in obj-*. As the result, we have an unholy mix of lib- and obj- in lib/Makefile and (especially) in arch/*/lib/Makefile. Moreover, a change in generic part of the kernel can lead to mysteriously missing exports on some configs. With this change we don't have to worry about that anymore. One side effect is that built-in.o now pulls everything with exports from the corresponding lib.a (if such exists). That's exactly what we want for linking vmlinux and fortunately it's almost the only thing built-in.o is used in. arch/ia64/hp/sim/boot/bootloader is the only exception and it's easy to get rid of now - just turn everything in arch/ia64/lib into lib-* and don't bother with arch/ia64/lib/built-in.o anymore. [AV: stylistic fix from Michal folded in] Acked-by: Michal Marek <mmarek@suse.cz> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Makefile.build20
1 files changed, 20 insertions, 0 deletions
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 11602e5efb3b..cd9bf22bb027 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -81,6 +81,7 @@ endif
81 81
82ifneq ($(strip $(lib-y) $(lib-m) $(lib-)),) 82ifneq ($(strip $(lib-y) $(lib-m) $(lib-)),)
83lib-target := $(obj)/lib.a 83lib-target := $(obj)/lib.a
84obj-y += $(obj)/lib-ksyms.o
84endif 85endif
85 86
86ifneq ($(strip $(obj-y) $(obj-m) $(obj-) $(subdir-m) $(lib-target)),) 87ifneq ($(strip $(obj-y) $(obj-m) $(obj-) $(subdir-m) $(lib-target)),)
@@ -395,6 +396,25 @@ $(lib-target): $(lib-y) FORCE
395 $(call if_changed,link_l_target) 396 $(call if_changed,link_l_target)
396 397
397targets += $(lib-target) 398targets += $(lib-target)
399
400dummy-object = $(obj)/.lib_exports.o
401ksyms-lds = $(dot-target).lds
402ifdef CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX
403ref_prefix = EXTERN(_
404else
405ref_prefix = EXTERN(
406endif
407
408quiet_cmd_export_list = EXPORTS $@
409cmd_export_list = $(OBJDUMP) -h $< | \
410 sed -ne '/___ksymtab/{s/.*+/$(ref_prefix)/;s/ .*/)/;p}' >$(ksyms-lds);\
411 rm -f $(dummy-object);\
412 $(AR) rcs$(KBUILD_ARFLAGS) $(dummy-object);\
413 $(LD) $(ld_flags) -r -o $@ -T $(ksyms-lds) $(dummy-object);\
414 rm $(dummy-object) $(ksyms-lds)
415
416$(obj)/lib-ksyms.o: $(lib-target) FORCE
417 $(call if_changed,export_list)
398endif 418endif
399 419
400# 420#