0ad9385
From 649d991ca7737dd227f2a1ca4f30247daf6a7b4b Mon Sep 17 00:00:00 2001
Kyle McMartin ed27f0b
From: Roland McGrath <roland@redhat.com>
Kyle McMartin f89b4ff
Date: Mon, 6 Oct 2008 23:03:03 -0700
Kyle McMartin f89b4ff
Subject: [PATCH] kbuild: AFTER_LINK
Kyle McMartin ed27f0b
Kyle McMartin f89b4ff
If the make variable AFTER_LINK is set, it is a command line to run
Kyle McMartin f89b4ff
after each final link.  This includes vmlinux itself and vDSO images.
Kyle McMartin f89b4ff
6a91557
Bugzilla: N/A
6a91557
Upstream-status: ??
6a91557
Kyle McMartin f89b4ff
Signed-off-by: Roland McGrath <roland@redhat.com>
Josh Boyer fbff9ed
---
Josh Boyer fbff9ed
 arch/arm64/kernel/vdso/Makefile     | 3 ++-
Josh Boyer fbff9ed
 arch/powerpc/kernel/vdso32/Makefile | 3 ++-
Josh Boyer fbff9ed
 arch/powerpc/kernel/vdso64/Makefile | 3 ++-
Josh Boyer fbff9ed
 arch/s390/kernel/vdso32/Makefile    | 3 ++-
Josh Boyer fbff9ed
 arch/s390/kernel/vdso64/Makefile    | 3 ++-
35eff41
 arch/x86/entry/vdso/Makefile        | 5 +++--
Josh Boyer fbff9ed
 scripts/link-vmlinux.sh             | 4 ++++
Josh Boyer fbff9ed
 7 files changed, 17 insertions(+), 7 deletions(-)
28a80a3
3b5c960
diff --git a/arch/arm64/kernel/vdso/Makefile b/arch/arm64/kernel/vdso/Makefile
0ad9385
index 62c84f7..f44236a 100644
3b5c960
--- a/arch/arm64/kernel/vdso/Makefile
3b5c960
+++ b/arch/arm64/kernel/vdso/Makefile
0ad9385
@@ -54,7 +54,8 @@ $(obj-vdso): %.o: %.S FORCE
3b5c960
 
3b5c960
 # Actual build commands
7de7a7f
 quiet_cmd_vdsold = VDSOL   $@
28a80a3
-      cmd_vdsold = $(CC) $(c_flags) -Wl,-n -Wl,-T $^ -o $@
28a80a3
+      cmd_vdsold = $(CC) $(c_flags) -Wl,-n -Wl,-T $^ -o $@ \
7de7a7f
+				    $(if $(AFTER_LINK),;$(AFTER_LINK))
7de7a7f
 quiet_cmd_vdsoas = VDSOA   $@
3b5c960
       cmd_vdsoas = $(CC) $(a_flags) -c -o $@ $<
3b5c960
 
Jesse Keating 7a32965
diff --git a/arch/powerpc/kernel/vdso32/Makefile b/arch/powerpc/kernel/vdso32/Makefile
0ad9385
index 78a7449..c9592c0 100644
Jesse Keating 7a32965
--- a/arch/powerpc/kernel/vdso32/Makefile
Jesse Keating 7a32965
+++ b/arch/powerpc/kernel/vdso32/Makefile
0ad9385
@@ -44,7 +44,8 @@ $(obj-vdso32): %.o: %.S FORCE
Jesse Keating 7a32965
 
Jesse Keating 7a32965
 # actual build commands
Jesse Keating 7a32965
 quiet_cmd_vdso32ld = VDSO32L $@
28b020a
-      cmd_vdso32ld = $(CROSS32CC) $(c_flags) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^)
28b020a
+      cmd_vdso32ld = $(CROSS32CC) $(c_flags) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^) \
Jesse Keating 7a32965
+		     $(if $(AFTER_LINK),; $(AFTER_LINK))
Jesse Keating 7a32965
 quiet_cmd_vdso32as = VDSO32A $@
Jesse Keating 7a32965
       cmd_vdso32as = $(CROSS32CC) $(a_flags) -c -o $@ $<
Jesse Keating 7a32965
 
Jesse Keating 7a32965
diff --git a/arch/powerpc/kernel/vdso64/Makefile b/arch/powerpc/kernel/vdso64/Makefile
0ad9385
index 31107bf..96aded3 100644
Jesse Keating 7a32965
--- a/arch/powerpc/kernel/vdso64/Makefile
Jesse Keating 7a32965
+++ b/arch/powerpc/kernel/vdso64/Makefile
0ad9385
@@ -33,7 +33,8 @@ $(obj)/%.so: $(obj)/%.so.dbg FORCE
Jesse Keating 7a32965
 
Jesse Keating 7a32965
 # actual build commands
Jesse Keating 7a32965
 quiet_cmd_vdso64ld = VDSO64L $@
28b020a
-      cmd_vdso64ld = $(CC) $(c_flags) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^)
28b020a
+      cmd_vdso64ld = $(CC) $(c_flags) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^) \
0ad9385
+		    $(if $(AFTER_LINK),; $(AFTER_LINK))
Jesse Keating 7a32965
 
0ad9385
 # install commands for the unstripped file
0ad9385
 quiet_cmd_vdso_install = INSTALL $@
Kyle McMartin 9e0d2f6
diff --git a/arch/s390/kernel/vdso32/Makefile b/arch/s390/kernel/vdso32/Makefile
0ad9385
index 6cc9478..94fb536 100644
Kyle McMartin 9e0d2f6
--- a/arch/s390/kernel/vdso32/Makefile
Kyle McMartin 9e0d2f6
+++ b/arch/s390/kernel/vdso32/Makefile
0ad9385
@@ -46,7 +46,8 @@ $(obj-vdso32): %.o: %.S
Kyle McMartin 9e0d2f6
 
Kyle McMartin 9e0d2f6
 # actual build commands
Kyle McMartin 9e0d2f6
 quiet_cmd_vdso32ld = VDSO32L $@
Kyle McMartin 9e0d2f6
-      cmd_vdso32ld = $(CC) $(c_flags) -Wl,-T $^ -o $@
Kyle McMartin 9e0d2f6
+      cmd_vdso32ld = $(CC) $(c_flags) -Wl,-T $^ -o $@ \
Kyle McMartin 9e0d2f6
+		     $(if $(AFTER_LINK),; $(AFTER_LINK))
Kyle McMartin 9e0d2f6
 quiet_cmd_vdso32as = VDSO32A $@
Kyle McMartin 9e0d2f6
       cmd_vdso32as = $(CC) $(a_flags) -c -o $@ $<
Kyle McMartin 9e0d2f6
 
Kyle McMartin 9e0d2f6
diff --git a/arch/s390/kernel/vdso64/Makefile b/arch/s390/kernel/vdso64/Makefile
0ad9385
index 2d54c18..a0e3e9d 100644
Kyle McMartin 9e0d2f6
--- a/arch/s390/kernel/vdso64/Makefile
Kyle McMartin 9e0d2f6
+++ b/arch/s390/kernel/vdso64/Makefile
0ad9385
@@ -46,7 +46,8 @@ $(obj-vdso64): %.o: %.S
Kyle McMartin 9e0d2f6
 
Kyle McMartin 9e0d2f6
 # actual build commands
Kyle McMartin 9e0d2f6
 quiet_cmd_vdso64ld = VDSO64L $@
Kyle McMartin 9e0d2f6
-      cmd_vdso64ld = $(CC) $(c_flags) -Wl,-T $^ -o $@
Kyle McMartin 9e0d2f6
+      cmd_vdso64ld = $(CC) $(c_flags) -Wl,-T $^ -o $@ \
Kyle McMartin 9e0d2f6
+		     $(if $(AFTER_LINK),; $(AFTER_LINK))
Kyle McMartin 9e0d2f6
 quiet_cmd_vdso64as = VDSO64A $@
Kyle McMartin 9e0d2f6
       cmd_vdso64as = $(CC) $(a_flags) -c -o $@ $<
Kyle McMartin 9e0d2f6
 
35eff41
diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile
0ad9385
index d540966..eeb47b6 100644
35eff41
--- a/arch/x86/entry/vdso/Makefile
35eff41
+++ b/arch/x86/entry/vdso/Makefile
0ad9385
@@ -167,8 +167,9 @@ $(obj)/vdso32.so.dbg: FORCE \
Josh Boyer be64ba5
 quiet_cmd_vdso = VDSO    $@
Josh Boyer be64ba5
       cmd_vdso = $(CC) -nostdlib -o $@ \
Josh Boyer be64ba5
 		       $(VDSO_LDFLAGS) $(VDSO_LDFLAGS_$(filter %.lds,$(^F))) \
Josh Boyer be64ba5
-		       -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
Josh Boyer be64ba5
-		 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
Josh Boyer be64ba5
+		       -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) \
Josh Boyer be64ba5
+		$(if $(AFTER_LINK),; $(AFTER_LINK)) && \
Josh Boyer be64ba5
+		sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
Josh Boyer be64ba5
 
861ffc7
 VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=both) \
7de7a7f
 	$(call cc-ldoption, -Wl$(comma)--build-id) -Wl,-Bsymbolic $(LTO_CFLAGS)
Josh Boyer be64ba5
diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
0ad9385
index f742c65..526eee4 100755
Josh Boyer be64ba5
--- a/scripts/link-vmlinux.sh
Josh Boyer be64ba5
+++ b/scripts/link-vmlinux.sh
0ad9385
@@ -111,6 +111,10 @@ vmlinux_link()
0ad9385
 			-lutil -lrt -lpthread
Josh Boyer be64ba5
 		rm -f linux
Josh Boyer be64ba5
 	fi
Josh Boyer be64ba5
+	if [ -n "${AFTER_LINK}" ]; then
Josh Boyer be64ba5
+		/usr/lib/rpm/debugedit -b ${RPM_BUILD_DIR} -d /usr/src/debug -i ${2} \
Josh Boyer be64ba5
+			> ${2}.id
Josh Boyer be64ba5
+	fi
Josh Boyer be64ba5
 }
Josh Boyer be64ba5
 
Josh Boyer be64ba5
 
861ffc7
-- 
0ad9385
2.7.4
861ffc7