Reset to the original
[linux-2.6.git] / linux-2.6-020-build-id.patch
1 From: Roland McGrath <roland@redhat.com>
2 Date: Thu, 19 Jul 2007 08:48:40 +0000 (-0700)
3 Subject: Use --build-id ld option
4 X-Git-Tag: v2.6.23-rc1~388
5 X-Git-Url: http://git.kernel.org/?p=linux%2Fkernel%2Fgit%2Ftorvalds%2Flinux-2.6.git;a=commitdiff_plain;h=18991197b4b588255ccabf472ebc84db7b66a19c
6
7 Use --build-id ld option
8
9 This change passes the --build-id when linking the kernel and when linking
10 modules, if ld supports it.  This is a new GNU ld option that synthesizes an
11 ELF note section inside the read-only data.  The note in this section contains
12 unique identifying bits called the "build ID", which are generated so as to be
13 different for any two linked ELF files that aren't identical.  The build ID
14 can be recovered from stripped files, memory dumps, etc.  and used to look up
15 the original program built, locate debuginfo or other details or history
16 associated with it.  For normal program linking, the compiler passes
17 --build-id to ld by default, but the option is needed when using ld directly
18 as we do.
19
20 Signed-off-by: Roland McGrath <roland@redhat.com>
21 Cc: Andi Kleen <ak@suse.de>
22 Cc: Paul Mackerras <paulus@samba.org>
23 Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
24 Cc: Richard Henderson <rth@twiddle.net>
25 Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
26 Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
27 Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
28 Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
29 Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
30 ---
31
32 diff --git a/Makefile b/Makefile
33 index ddbfcac..eccb03b 100644
34 --- a/Makefile
35 +++ b/Makefile
36 @@ -514,6 +514,12 @@ CFLAGS += $(call cc-option,-Wdeclaration-after-statement,)
37  # disable pointer signed / unsigned warnings in gcc 4.0
38  CFLAGS += $(call cc-option,-Wno-pointer-sign,)
39  
40 +# Use --build-id when available.
41 +LDFLAGS_BUILD_ID = $(patsubst -Wl$(comma)%,%,\
42 +                             $(call ld-option, -Wl$(comma)--build-id,))
43 +LDFLAGS_MODULE += $(LDFLAGS_BUILD_ID)
44 +LDFLAGS_vmlinux += $(LDFLAGS_BUILD_ID)
45 +
46  # Default kernel image to build when no specific target is given.
47  # KBUILD_IMAGE may be overruled on the command line or
48  # set in the environment
49
50
51 From: Roland McGrath <roland@redhat.com>
52 Date: Mon, 23 Jul 2007 08:12:08 +0000 (-0700)
53 Subject: kbuild: use LDFLAGS_MODULE only for .ko links
54 X-Git-Tag: v2.6.23-rc2~266^2~3
55 X-Git-Url: http://git.kernel.org/?p=linux%2Fkernel%2Fgit%2Ftorvalds%2Flinux-2.6.git;a=commitdiff_plain;h=114f51577724b782a30f4f5ceaee9880de93d776
56
57 kbuild: use LDFLAGS_MODULE only for .ko links
58
59 Sam Ravnborg pointed out that Documentation/kbuild/makefiles.txt already
60 says this is what it's for.  This patch makes the reality live up to the
61 documentation.  This fixes the problem of LDFLAGS_BUILD_ID getting into too
62 many places.
63
64 Signed-off-by: Roland McGrath <roland@redhat.com>
65 Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
66 ---
67
68 diff --git a/Makefile b/Makefile
69 index 23f81c9..dfe3d16 100644
70 --- a/Makefile
71 +++ b/Makefile
72 @@ -299,7 +299,7 @@ CHECKFLAGS     := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ -Wbitwise $(C
73  MODFLAGS       = -DMODULE
74  CFLAGS_MODULE   = $(MODFLAGS)
75  AFLAGS_MODULE   = $(MODFLAGS)
76 -LDFLAGS_MODULE  = -r
77 +LDFLAGS_MODULE  =
78  CFLAGS_KERNEL  =
79  AFLAGS_KERNEL  =
80  
81 diff --git a/scripts/Makefile.build b/scripts/Makefile.build
82 index 3f7b451..7fd6055 100644
83 --- a/scripts/Makefile.build
84 +++ b/scripts/Makefile.build
85 @@ -315,7 +315,7 @@ quiet_cmd_link_multi-y = LD      $@
86  cmd_link_multi-y = $(LD) $(ld_flags) -r -o $@ $(link_multi_deps)
87  
88  quiet_cmd_link_multi-m = LD [M]  $@
89 -cmd_link_multi-m = $(LD) $(ld_flags) $(LDFLAGS_MODULE) -o $@ $(link_multi_deps)
90 +cmd_link_multi-m = $(cmd_link_multi-y)
91  
92  # We would rather have a list of rules like
93  #      foo.o: $(foo-objs)
94 diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
95 index 1818c50..d988f5d 100644
96 --- a/scripts/Makefile.modpost
97 +++ b/scripts/Makefile.modpost
98 @@ -98,7 +98,7 @@ targets += $(modules:.ko=.mod.o)
99  
100  # Step 6), final link of the modules
101  quiet_cmd_ld_ko_o = LD [M]  $@
102 -      cmd_ld_ko_o = $(LD) $(LDFLAGS) $(LDFLAGS_MODULE) -o $@           \
103 +      cmd_ld_ko_o = $(LD) -r $(LDFLAGS) $(LDFLAGS_MODULE) -o $@                \
104                           $(filter-out FORCE,$^)
105  
106  $(modules): %.ko :%.o %.mod.o FORCE