From: Roland McGrath Date: Thu, 19 Jul 2007 08:48:40 +0000 (-0700) Subject: Use --build-id ld option X-Git-Tag: v2.6.23-rc1~388 X-Git-Url: http://git.kernel.org/?p=linux%2Fkernel%2Fgit%2Ftorvalds%2Flinux-2.6.git;a=commitdiff_plain;h=18991197b4b588255ccabf472ebc84db7b66a19c Use --build-id ld option This change passes the --build-id when linking the kernel and when linking modules, if ld supports it. This is a new GNU ld option that synthesizes an ELF note section inside the read-only data. The note in this section contains unique identifying bits called the "build ID", which are generated so as to be different for any two linked ELF files that aren't identical. The build ID can be recovered from stripped files, memory dumps, etc. and used to look up the original program built, locate debuginfo or other details or history associated with it. For normal program linking, the compiler passes --build-id to ld by default, but the option is needed when using ld directly as we do. Signed-off-by: Roland McGrath Cc: Andi Kleen Cc: Paul Mackerras Cc: Benjamin Herrenschmidt Cc: Richard Henderson Cc: Ivan Kokshaysky Cc: Martin Schwidefsky Cc: Heiko Carstens Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/Makefile b/Makefile index ddbfcac..eccb03b 100644 --- a/Makefile +++ b/Makefile @@ -514,6 +514,12 @@ CFLAGS += $(call cc-option,-Wdeclaration-after-statement,) # disable pointer signed / unsigned warnings in gcc 4.0 CFLAGS += $(call cc-option,-Wno-pointer-sign,) +# Use --build-id when available. +LDFLAGS_BUILD_ID = $(patsubst -Wl$(comma)%,%,\ + $(call ld-option, -Wl$(comma)--build-id,)) +LDFLAGS_MODULE += $(LDFLAGS_BUILD_ID) +LDFLAGS_vmlinux += $(LDFLAGS_BUILD_ID) + # Default kernel image to build when no specific target is given. # KBUILD_IMAGE may be overruled on the command line or # set in the environment From: Roland McGrath Date: Mon, 23 Jul 2007 08:12:08 +0000 (-0700) Subject: kbuild: use LDFLAGS_MODULE only for .ko links X-Git-Tag: v2.6.23-rc2~266^2~3 X-Git-Url: http://git.kernel.org/?p=linux%2Fkernel%2Fgit%2Ftorvalds%2Flinux-2.6.git;a=commitdiff_plain;h=114f51577724b782a30f4f5ceaee9880de93d776 kbuild: use LDFLAGS_MODULE only for .ko links Sam Ravnborg pointed out that Documentation/kbuild/makefiles.txt already says this is what it's for. This patch makes the reality live up to the documentation. This fixes the problem of LDFLAGS_BUILD_ID getting into too many places. Signed-off-by: Roland McGrath Signed-off-by: Sam Ravnborg --- diff --git a/Makefile b/Makefile index 23f81c9..dfe3d16 100644 --- a/Makefile +++ b/Makefile @@ -299,7 +299,7 @@ CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ -Wbitwise $(C MODFLAGS = -DMODULE CFLAGS_MODULE = $(MODFLAGS) AFLAGS_MODULE = $(MODFLAGS) -LDFLAGS_MODULE = -r +LDFLAGS_MODULE = CFLAGS_KERNEL = AFLAGS_KERNEL = diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 3f7b451..7fd6055 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -315,7 +315,7 @@ quiet_cmd_link_multi-y = LD $@ cmd_link_multi-y = $(LD) $(ld_flags) -r -o $@ $(link_multi_deps) quiet_cmd_link_multi-m = LD [M] $@ -cmd_link_multi-m = $(LD) $(ld_flags) $(LDFLAGS_MODULE) -o $@ $(link_multi_deps) +cmd_link_multi-m = $(cmd_link_multi-y) # We would rather have a list of rules like # foo.o: $(foo-objs) diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index 1818c50..d988f5d 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -98,7 +98,7 @@ targets += $(modules:.ko=.mod.o) # Step 6), final link of the modules quiet_cmd_ld_ko_o = LD [M] $@ - cmd_ld_ko_o = $(LD) $(LDFLAGS) $(LDFLAGS_MODULE) -o $@ \ + cmd_ld_ko_o = $(LD) -r $(LDFLAGS) $(LDFLAGS_MODULE) -o $@ \ $(filter-out FORCE,$^) $(modules): %.ko :%.o %.mod.o FORCE