@@ -4,9 +4,14 @@ nocov-y += libelf.o
SECTIONS := text data $(SPECIAL_DATA_SECTIONS)
ccflags-y += -Wno-pointer-sign
+ldflags-y += -r
+OBJCOPYFLAGS += $(foreach s,$(SECTIONS),--rename-section .$(s)=.init.$(s))
-libelf.o: libelf-temp.o Makefile
- $(OBJCOPY) $(foreach s,$(SECTIONS),--rename-section .$(s)=.init.$(s)) $< $@
+libelf-temp-objs := libelf-tools.o libelf-loader.o libelf-dominfo.o #libelf-relocate.o
+targets += $(libelf-temp-objs) libelf-temp.o
-libelf-temp.o: libelf-tools.o libelf-loader.o libelf-dominfo.o #libelf-relocate.o
- $(LD) $(LDFLAGS) -r -o $@ $^
+$(obj)/libelf.o: $(obj)/libelf-temp.o FORCE
+ $(call if_changed,objcopy)
+
+$(obj)/libelf-temp.o: $(addprefix $(obj)/,$(libelf-temp-objs)) FORCE
+ $(call if_changed,ld)
Use existing command line of objcopy and ld instead of writing new one and simply edit the flags. `targets' is to let know kbuild that other files beside the one declared in obj-bin-y will be built. Signed-off-by: Anthony PERARD <anthony.perard@citrix.com> --- xen/common/libelf/Makefile | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)