b88033
From a9488dbeccf188f0bd83b9d5704892f2c0f97fdc Mon Sep 17 00:00:00 2001
Kyle McMartin ed27f0
From: Roland McGrath <roland@redhat.com>
Kyle McMartin f89b4f
Date: Mon, 6 Oct 2008 23:03:03 -0700
Kyle McMartin f89b4f
Subject: [PATCH] kbuild: AFTER_LINK
Kyle McMartin ed27f0
Kyle McMartin f89b4f
If the make variable AFTER_LINK is set, it is a command line to run
Kyle McMartin f89b4f
after each final link.  This includes vmlinux itself and vDSO images.
Kyle McMartin f89b4f
6a9155
Bugzilla: N/A
6a9155
Upstream-status: ??
6a9155
Kyle McMartin f89b4f
Signed-off-by: Roland McGrath <roland@redhat.com>
Josh Boyer fbff9e
---
Josh Boyer fbff9e
 arch/arm64/kernel/vdso/Makefile     | 3 ++-
Josh Boyer fbff9e
 arch/powerpc/kernel/vdso32/Makefile | 3 ++-
Josh Boyer fbff9e
 arch/powerpc/kernel/vdso64/Makefile | 3 ++-
Josh Boyer fbff9e
 arch/s390/kernel/vdso32/Makefile    | 3 ++-
Josh Boyer fbff9e
 arch/s390/kernel/vdso64/Makefile    | 3 ++-
35eff4
 arch/x86/entry/vdso/Makefile        | 5 +++--
Josh Boyer fbff9e
 scripts/link-vmlinux.sh             | 4 ++++
Josh Boyer fbff9e
 7 files changed, 17 insertions(+), 7 deletions(-)
28a80a
3b5c96
diff --git a/arch/arm64/kernel/vdso/Makefile b/arch/arm64/kernel/vdso/Makefile
b88033
index b467fd0..feeff5e 100644
3b5c96
--- a/arch/arm64/kernel/vdso/Makefile
3b5c96
+++ b/arch/arm64/kernel/vdso/Makefile
b88033
@@ -55,7 +55,8 @@ $(obj-vdso): %.o: %.S FORCE
3b5c96
 
3b5c96
 # Actual build commands
7de7a7
 quiet_cmd_vdsold = VDSOL   $@
28a80a
-      cmd_vdsold = $(CC) $(c_flags) -Wl,-n -Wl,-T $^ -o $@
28a80a
+      cmd_vdsold = $(CC) $(c_flags) -Wl,-n -Wl,-T $^ -o $@ \
7de7a7
+				    $(if $(AFTER_LINK),;$(AFTER_LINK))
7de7a7
 quiet_cmd_vdsoas = VDSOA   $@
3b5c96
       cmd_vdsoas = $(CC) $(a_flags) -c -o $@ $<
3b5c96
 
Jesse Keating 7a3296
diff --git a/arch/powerpc/kernel/vdso32/Makefile b/arch/powerpc/kernel/vdso32/Makefile
b88033
index 6abffb7..7b103bb 100644
Jesse Keating 7a3296
--- a/arch/powerpc/kernel/vdso32/Makefile
Jesse Keating 7a3296
+++ b/arch/powerpc/kernel/vdso32/Makefile
3b5c96
@@ -43,7 +43,8 @@ $(obj-vdso32): %.o: %.S
Jesse Keating 7a3296
 
Jesse Keating 7a3296
 # actual build commands
Jesse Keating 7a3296
 quiet_cmd_vdso32ld = VDSO32L $@
28b020
-      cmd_vdso32ld = $(CROSS32CC) $(c_flags) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^)
28b020
+      cmd_vdso32ld = $(CROSS32CC) $(c_flags) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^) \
Jesse Keating 7a3296
+		     $(if $(AFTER_LINK),; $(AFTER_LINK))
Jesse Keating 7a3296
 quiet_cmd_vdso32as = VDSO32A $@
Jesse Keating 7a3296
       cmd_vdso32as = $(CROSS32CC) $(a_flags) -c -o $@ $<
Jesse Keating 7a3296
 
Jesse Keating 7a3296
diff --git a/arch/powerpc/kernel/vdso64/Makefile b/arch/powerpc/kernel/vdso64/Makefile
b88033
index 8c8f2ae..a743ebe 100644
Jesse Keating 7a3296
--- a/arch/powerpc/kernel/vdso64/Makefile
Jesse Keating 7a3296
+++ b/arch/powerpc/kernel/vdso64/Makefile
Jesse Keating 7a3296
@@ -36,7 +36,8 @@ $(obj-vdso64): %.o: %.S
Jesse Keating 7a3296
 
Jesse Keating 7a3296
 # actual build commands
Jesse Keating 7a3296
 quiet_cmd_vdso64ld = VDSO64L $@
28b020
-      cmd_vdso64ld = $(CC) $(c_flags) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^)
28b020
+      cmd_vdso64ld = $(CC) $(c_flags) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^) \
Jesse Keating 7a3296
+		     $(if $(AFTER_LINK),; $(AFTER_LINK))
Jesse Keating 7a3296
 quiet_cmd_vdso64as = VDSO64A $@
Jesse Keating 7a3296
       cmd_vdso64as = $(CC) $(a_flags) -c -o $@ $<
Jesse Keating 7a3296
 
Kyle McMartin 9e0d2f
diff --git a/arch/s390/kernel/vdso32/Makefile b/arch/s390/kernel/vdso32/Makefile
b88033
index ee8a18e..63e33fa 100644
Kyle McMartin 9e0d2f
--- a/arch/s390/kernel/vdso32/Makefile
Kyle McMartin 9e0d2f
+++ b/arch/s390/kernel/vdso32/Makefile
Josh Boyer be64ba
@@ -43,7 +43,8 @@ $(obj-vdso32): %.o: %.S
Kyle McMartin 9e0d2f
 
Kyle McMartin 9e0d2f
 # actual build commands
Kyle McMartin 9e0d2f
 quiet_cmd_vdso32ld = VDSO32L $@
Kyle McMartin 9e0d2f
-      cmd_vdso32ld = $(CC) $(c_flags) -Wl,-T $^ -o $@
Kyle McMartin 9e0d2f
+      cmd_vdso32ld = $(CC) $(c_flags) -Wl,-T $^ -o $@ \
Kyle McMartin 9e0d2f
+		     $(if $(AFTER_LINK),; $(AFTER_LINK))
Kyle McMartin 9e0d2f
 quiet_cmd_vdso32as = VDSO32A $@
Kyle McMartin 9e0d2f
       cmd_vdso32as = $(CC) $(a_flags) -c -o $@ $<
Kyle McMartin 9e0d2f
 
Kyle McMartin 9e0d2f
diff --git a/arch/s390/kernel/vdso64/Makefile b/arch/s390/kernel/vdso64/Makefile
b88033
index c4b03f9..550450f 100644
Kyle McMartin 9e0d2f
--- a/arch/s390/kernel/vdso64/Makefile
Kyle McMartin 9e0d2f
+++ b/arch/s390/kernel/vdso64/Makefile
Josh Boyer be64ba
@@ -43,7 +43,8 @@ $(obj-vdso64): %.o: %.S
Kyle McMartin 9e0d2f
 
Kyle McMartin 9e0d2f
 # actual build commands
Kyle McMartin 9e0d2f
 quiet_cmd_vdso64ld = VDSO64L $@
Kyle McMartin 9e0d2f
-      cmd_vdso64ld = $(CC) $(c_flags) -Wl,-T $^ -o $@
Kyle McMartin 9e0d2f
+      cmd_vdso64ld = $(CC) $(c_flags) -Wl,-T $^ -o $@ \
Kyle McMartin 9e0d2f
+		     $(if $(AFTER_LINK),; $(AFTER_LINK))
Kyle McMartin 9e0d2f
 quiet_cmd_vdso64as = VDSO64A $@
Kyle McMartin 9e0d2f
       cmd_vdso64as = $(CC) $(a_flags) -c -o $@ $<
Kyle McMartin 9e0d2f
 
35eff4
diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile
b88033
index 265c0ed..fd90c7d 100644
35eff4
--- a/arch/x86/entry/vdso/Makefile
35eff4
+++ b/arch/x86/entry/vdso/Makefile
b88033
@@ -159,8 +159,9 @@ $(obj)/vdso32.so.dbg: FORCE \
Josh Boyer be64ba
 quiet_cmd_vdso = VDSO    $@
Josh Boyer be64ba
       cmd_vdso = $(CC) -nostdlib -o $@ \
Josh Boyer be64ba
 		       $(VDSO_LDFLAGS) $(VDSO_LDFLAGS_$(filter %.lds,$(^F))) \
Josh Boyer be64ba
-		       -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
Josh Boyer be64ba
-		 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
Josh Boyer be64ba
+		       -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) \
Josh Boyer be64ba
+		$(if $(AFTER_LINK),; $(AFTER_LINK)) && \
Josh Boyer be64ba
+		sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
Josh Boyer be64ba
 
861ffc
 VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=both) \
7de7a7
 	$(call cc-ldoption, -Wl$(comma)--build-id) -Wl,-Bsymbolic $(LTO_CFLAGS)
Josh Boyer be64ba
diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
b88033
index dacf71a..72cbefd 100755
Josh Boyer be64ba
--- a/scripts/link-vmlinux.sh
Josh Boyer be64ba
+++ b/scripts/link-vmlinux.sh
Josh Boyer be64ba
@@ -65,6 +65,10 @@ vmlinux_link()
623665
 			-lutil -lrt -lpthread ${1}
Josh Boyer be64ba
 		rm -f linux
Josh Boyer be64ba
 	fi
Josh Boyer be64ba
+	if [ -n "${AFTER_LINK}" ]; then
Josh Boyer be64ba
+		/usr/lib/rpm/debugedit -b ${RPM_BUILD_DIR} -d /usr/src/debug -i ${2} \
Josh Boyer be64ba
+			> ${2}.id
Josh Boyer be64ba
+	fi
Josh Boyer be64ba
 }
Josh Boyer be64ba
 
Josh Boyer be64ba
 
861ffc
-- 
b88033
2.5.0
861ffc