Skip to content

Commit

Permalink
kbuild: unify cmd_dt_S_dtb and cmd_dt_S_dtbo
Browse files Browse the repository at this point in the history
cmd_dt_S_dtb and cmd_dt_S_dtbo are almost the same; the only difference
is the prefix of the begin/end symbols. (__dtb vs __dtbo)

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
  • Loading branch information
Masahiro Yamada committed Jan 22, 2023
1 parent ee2162b commit ecd42fb
Showing 1 changed file with 15 additions and 30 deletions.
45 changes: 15 additions & 30 deletions scripts/Makefile.lib
Original file line number Diff line number Diff line change
Expand Up @@ -368,40 +368,25 @@ DTC_FLAGS += $(DTC_FLAGS_$(basetarget))
DTC_FLAGS += $(if $(filter $(patsubst $(obj)/%,%,$@), $(base-dtb-y)), -@)

# Generate an assembly file to wrap the output of the device tree compiler
quiet_cmd_dt_S_dtb= DTBS $@
cmd_dt_S_dtb= \
{ \
echo '\#include <asm-generic/vmlinux.lds.h>'; \
echo '.section .dtb.init.rodata,"a"'; \
echo '.balign STRUCT_ALIGNMENT'; \
echo '.global __dtb_$(subst -,_,$(*F))_begin'; \
echo '__dtb_$(subst -,_,$(*F))_begin:'; \
echo '.incbin "$<" '; \
echo '__dtb_$(subst -,_,$(*F))_end:'; \
echo '.global __dtb_$(subst -,_,$(*F))_end'; \
echo '.balign STRUCT_ALIGNMENT'; \
} > $@
quiet_cmd_wrap_S_dtb = WRAP $@
cmd_wrap_S_dtb = { \
symbase=__$(patsubst .%,%,$(suffix $<))_$(subst -,_,$(notdir $*)); \
echo '\#include <asm-generic/vmlinux.lds.h>'; \
echo '.section .dtb.init.rodata,"a"'; \
echo '.balign STRUCT_ALIGNMENT'; \
echo ".global $${symbase}_begin"; \
echo "$${symbase}_begin:"; \
echo '.incbin "$<" '; \
echo ".global $${symbase}_end"; \
echo "$${symbase}_end:"; \
echo '.balign STRUCT_ALIGNMENT'; \
} > $@

$(obj)/%.dtb.S: $(obj)/%.dtb FORCE
$(call if_changed,dt_S_dtb)

# Generate an assembly file to wrap the output of the device tree compiler
quiet_cmd_dt_S_dtbo= DTBOS $@
cmd_dt_S_dtbo= \
{ \
echo '\#include <asm-generic/vmlinux.lds.h>'; \
echo '.section .dtb.init.rodata,"a"'; \
echo '.balign STRUCT_ALIGNMENT'; \
echo '.global __dtbo_$(subst -,_,$(*F))_begin'; \
echo '__dtbo_$(subst -,_,$(*F))_begin:'; \
echo '.incbin "$<" '; \
echo '__dtbo_$(subst -,_,$(*F))_end:'; \
echo '.global __dtbo_$(subst -,_,$(*F))_end'; \
echo '.balign STRUCT_ALIGNMENT'; \
} > $@
$(call if_changed,wrap_S_dtb)

$(obj)/%.dtbo.S: $(obj)/%.dtbo FORCE
$(call if_changed,dt_S_dtbo)
$(call if_changed,wrap_S_dtb)

quiet_cmd_dtc = DTC $@
cmd_dtc = $(HOSTCC) -E $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \
Expand Down

0 comments on commit ecd42fb

Please sign in to comment.