Setting tag linux-2.6-22-50
[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
107
108
109
110 From: Roland McGrath <roland@redhat.com>
111 Date: Thu, 19 Jul 2007 08:48:37 +0000 (-0700)
112 Subject: x86_64: Put allocated ELF notes in read-only data segment
113 X-Git-Tag: v2.6.23-rc1~393
114 X-Git-Url: http://git.kernel.org/?p=linux%2Fkernel%2Fgit%2Ftorvalds%2Flinux-2.6.git;a=commitdiff_plain;h=2e1d5b8f24a887caded5ae3ceb2f341d4fbd1861
115
116 x86_64: Put allocated ELF notes in read-only data segment
117
118 This changes the x86_64 linker script to use the asm-generic NOTES macro so
119 that ELF note sections with SHF_ALLOC set are linked into the kernel image
120 along with other read-only data.  The PT_NOTE also points to their location.
121
122 This paves the way for putting useful build-time information into ELF notes
123 that can be found easily later in a kernel memory dump.
124
125 Signed-off-by: Roland McGrath <roland@redhat.com>
126 Cc: Andi Kleen <ak@suse.de>
127 Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
128 Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
129 ---
130
131 diff --git a/arch/x86_64/kernel/vmlinux.lds.S b/arch/x86_64/kernel/vmlinux.lds.S
132 index 2259069..5c57ea4 100644
133 --- a/arch/x86_64/kernel/vmlinux.lds.S
134 +++ b/arch/x86_64/kernel/vmlinux.lds.S
135 @@ -48,7 +48,9 @@ SECTIONS
136    __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) { *(__ex_table) }
137    __stop___ex_table = .;
138  
139 -  BUG_TABLE
140 +  NOTES :text :note
141 +
142 +  BUG_TABLE :text
143  
144    RODATA
145  
146
147
148
149 From: Roland McGrath <roland@redhat.com>
150 Date: Thu, 19 Jul 2007 08:48:36 +0000 (-0700)
151 Subject: i386: Put allocated ELF notes in read-only data segment
152 X-Git-Tag: v2.6.23-rc1~394
153 X-Git-Url: http://git.kernel.org/?p=linux%2Fkernel%2Fgit%2Ftorvalds%2Flinux-2.6.git;a=commitdiff_plain;h=cbe87121f1545bb3e98ae114519bf0c4db27d6ab
154
155 i386: Put allocated ELF notes in read-only data segment
156
157 This changes the i386 linker script and the asm-generic macro it uses so that
158 ELF note sections with SHF_ALLOC set are linked into the kernel image along
159 with other read-only data.  The PT_NOTE also points to their location.
160
161 This paves the way for putting useful build-time information into ELF notes
162 that can be found easily later in a kernel memory dump.
163
164 Signed-off-by: Roland McGrath <roland@redhat.com>
165 Cc: Andi Kleen <ak@suse.de>
166 Cc: Paul Mackerras <paulus@samba.org>
167 Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
168 Cc: Richard Henderson <rth@twiddle.net>
169 Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
170 Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
171 Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
172 Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
173 Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
174 ---
175
176 diff --git a/arch/i386/kernel/vmlinux.lds.S b/arch/i386/kernel/vmlinux.lds.S
177 index 4dc44b8..7d72cce 100644
178 --- a/arch/i386/kernel/vmlinux.lds.S
179 +++ b/arch/i386/kernel/vmlinux.lds.S
180 @@ -60,7 +60,9 @@ SECTIONS
181         __stop___ex_table = .;
182    }
183  
184 -  BUG_TABLE
185 +  NOTES :text :note
186 +
187 +  BUG_TABLE :text
188  
189    . = ALIGN(4);
190    .tracedata : AT(ADDR(.tracedata) - LOAD_OFFSET) {
191 @@ -208,6 +210,4 @@ SECTIONS
192    STABS_DEBUG
193  
194    DWARF_DEBUG
195 -
196 -  NOTES
197  }
198 diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
199 index a2b09ed..0240e05 100644
200 --- a/include/asm-generic/vmlinux.lds.h
201 +++ b/include/asm-generic/vmlinux.lds.h
202 @@ -224,7 +224,11 @@
203         }
204  
205  #define NOTES                                                          \
206 -       .notes : { *(.note.*) } :note
207 +       .notes : AT(ADDR(.notes) - LOAD_OFFSET) {                       \
208 +               VMLINUX_SYMBOL(__start_notes) = .;                      \
209 +               *(.note.*)                                              \
210 +               VMLINUX_SYMBOL(__stop_notes) = .;                       \
211 +       }
212  
213  #define INITCALLS                                                      \
214         *(.initcall0.init)                                              \
215