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
35eff4
index f6fe17d88da5..eb6ddbf37f30 100644
3b5c96
--- a/arch/arm64/kernel/vdso/Makefile
3b5c96
+++ b/arch/arm64/kernel/vdso/Makefile
35eff4
@@ -52,7 +52,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
Josh Boyer fbff9e
index 53e6c9b979ec..e427844e9bb0 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 $@
Jesse Keating 7a3296
-      cmd_vdso32ld = $(CROSS32CC) $(c_flags) -Wl,-T $^ -o $@
Jesse Keating 7a3296
+      cmd_vdso32ld = $(CROSS32CC) $(c_flags) -Wl,-T $^ -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
Josh Boyer fbff9e
index effca9404b17..713891a92d23 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 $@
Jesse Keating 7a3296
-      cmd_vdso64ld = $(CC) $(c_flags) -Wl,-T $^ -o $@
Jesse Keating 7a3296
+      cmd_vdso64ld = $(CC) $(c_flags) -Wl,-T $^ -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
Josh Boyer fbff9e
index 8ad2b34ad151..e153572ab351 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
Josh Boyer fbff9e
index 2a8ddfd12a5b..452ca53561fe 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
cf5928
index e97032069f88..9ea82f444dea 100644
35eff4
--- a/arch/x86/entry/vdso/Makefile
35eff4
+++ b/arch/x86/entry/vdso/Makefile
f1193f
@@ -172,8 +172,9 @@ $(vdso32-images:%=$(obj)/%.dbg): $(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
 
Josh Boyer fbff9e
 VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv) \
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
088a50
index 1a10d8ac8162..092d0c0cf72c 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()
Josh Boyer be64ba
 			-lutil ${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