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
7 Use --build-id ld option
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
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>
32 diff --git a/Makefile b/Makefile
33 index ddbfcac..eccb03b 100644
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,)
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)
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
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
57 kbuild: use LDFLAGS_MODULE only for .ko links
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
64 Signed-off-by: Roland McGrath <roland@redhat.com>
65 Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
68 diff --git a/Makefile b/Makefile
69 index 23f81c9..dfe3d16 100644
72 @@ -299,7 +299,7 @@ CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ -Wbitwise $(C
74 CFLAGS_MODULE = $(MODFLAGS)
75 AFLAGS_MODULE = $(MODFLAGS)
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)
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)
92 # We would rather have a list of rules like
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)
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,$^)
106 $(modules): %.ko :%.o %.mod.o FORCE
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
116 x86_64: Put allocated ELF notes in read-only data segment
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.
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.
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>
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 = .;
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
155 i386: Put allocated ELF notes in read-only data segment
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.
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.
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>
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 = .;
190 .tracedata : AT(ADDR(.tracedata) - LOAD_OFFSET) {
191 @@ -208,6 +210,4 @@ SECTIONS
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
206 - .notes : { *(.note.*) } :note
207 + .notes : AT(ADDR(.notes) - LOAD_OFFSET) { \
208 + VMLINUX_SYMBOL(__start_notes) = .; \
210 + VMLINUX_SYMBOL(__stop_notes) = .; \