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 ++-
Josh Boyer fbff9ed
 arch/x86/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
7de7a7f
index ff3bddea482d..d8a439dd6351 100644
3b5c960
--- a/arch/arm64/kernel/vdso/Makefile
3b5c960
+++ b/arch/arm64/kernel/vdso/Makefile
7de7a7f
@@ -48,7 +48,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
Josh Boyer fbff9ed
index 53e6c9b979ec..e427844e9bb0 100644
Jesse Keating 7a32965
--- a/arch/powerpc/kernel/vdso32/Makefile
Jesse Keating 7a32965
+++ b/arch/powerpc/kernel/vdso32/Makefile
3b5c960
@@ -43,7 +43,8 @@ $(obj-vdso32): %.o: %.S
Jesse Keating 7a32965
 
Jesse Keating 7a32965
 # actual build commands
Jesse Keating 7a32965
 quiet_cmd_vdso32ld = VDSO32L $@
Jesse Keating 7a32965
-      cmd_vdso32ld = $(CROSS32CC) $(c_flags) -Wl,-T $^ -o $@
Jesse Keating 7a32965
+      cmd_vdso32ld = $(CROSS32CC) $(c_flags) -Wl,-T $^ -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
Josh Boyer fbff9ed
index effca9404b17..713891a92d23 100644
Jesse Keating 7a32965
--- a/arch/powerpc/kernel/vdso64/Makefile
Jesse Keating 7a32965
+++ b/arch/powerpc/kernel/vdso64/Makefile
Jesse Keating 7a32965
@@ -36,7 +36,8 @@ $(obj-vdso64): %.o: %.S
Jesse Keating 7a32965
 
Jesse Keating 7a32965
 # actual build commands
Jesse Keating 7a32965
 quiet_cmd_vdso64ld = VDSO64L $@
Jesse Keating 7a32965
-      cmd_vdso64ld = $(CC) $(c_flags) -Wl,-T $^ -o $@
Jesse Keating 7a32965
+      cmd_vdso64ld = $(CC) $(c_flags) -Wl,-T $^ -o $@ \
Jesse Keating 7a32965
+		     $(if $(AFTER_LINK),; $(AFTER_LINK))
Jesse Keating 7a32965
 quiet_cmd_vdso64as = VDSO64A $@
Jesse Keating 7a32965
       cmd_vdso64as = $(CC) $(a_flags) -c -o $@ $<
Jesse Keating 7a32965
 
Kyle McMartin 9e0d2f6
diff --git a/arch/s390/kernel/vdso32/Makefile b/arch/s390/kernel/vdso32/Makefile
Josh Boyer fbff9ed
index 8ad2b34ad151..e153572ab351 100644
Kyle McMartin 9e0d2f6
--- a/arch/s390/kernel/vdso32/Makefile
Kyle McMartin 9e0d2f6
+++ b/arch/s390/kernel/vdso32/Makefile
Josh Boyer be64ba5
@@ -43,7 +43,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
Josh Boyer fbff9ed
index 2a8ddfd12a5b..452ca53561fe 100644
Kyle McMartin 9e0d2f6
--- a/arch/s390/kernel/vdso64/Makefile
Kyle McMartin 9e0d2f6
+++ b/arch/s390/kernel/vdso64/Makefile
Josh Boyer be64ba5
@@ -43,7 +43,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
 
Josh Boyer be64ba5
diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
7de7a7f
index 5a4affe025e8..8ff38ce94c8e 100644
Josh Boyer be64ba5
--- a/arch/x86/vdso/Makefile
Josh Boyer be64ba5
+++ b/arch/x86/vdso/Makefile
7de7a7f
@@ -171,8 +171,9 @@ $(vdso32-images:%=$(obj)/%.dbg): $(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
 
Josh Boyer fbff9ed
 VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv) \
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
7f1b8a8
index 86a4fe75f453..161637ed5611 100755
Josh Boyer be64ba5
--- a/scripts/link-vmlinux.sh
Josh Boyer be64ba5
+++ b/scripts/link-vmlinux.sh
Josh Boyer be64ba5
@@ -65,6 +65,10 @@ vmlinux_link()
Josh Boyer be64ba5
 			-lutil ${1}
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
 
6a91557
-- 
1e63a38
2.1.0
6a91557