Skip to content

Commit

Permalink
<make> Feature updated to print size of sections
Browse files Browse the repository at this point in the history
  • Loading branch information
akashkollipara committed Aug 18, 2022
1 parent 189d9f6 commit f9ce0a8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
6 changes: 2 additions & 4 deletions mk/elf.mk
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,16 @@ LD_SUPPLEMENT := $(addprefix $(OUT)/,$(LD_SUPPLEMENT:.ld.sx=.ld))

elf: $(ELF)

$(ELF): $(DEP_LIBS) $(DEP_OBJS) $(LD_SCRIPT) $(LD_SUPPLEMENT)
.SECONDEXPANSION:
$(ELF): $(SIZE) $(DEP_LIBS) $(DEP_OBJS) $(LD_SCRIPT) $(LD_SUPPLEMENT) | $$(SIZE)
@echo "Elf: Generating $(@F) ..."
$(LD) -dT $(LD_SCRIPT) $(addprefix -T , $(LD_SUPPLEMENT)) $(LD_FLAGS) -Map=$(@:.elf=.map) -o $@ $(filter %.o, $^) $(DEP_LIB_PATH) $(DEP_LIBS_ARG) -L $(TL) -lgcc
$(OD) -Dx -h --wide $@ > $(@:.elf=.lst)
$(OC) -O binary $@ $(@:.elf=.bin)
$(OC) -O ihex $@ $(@:.elf=.hex)
@echo "=================================================="
@echo "Size of Executable:"
@cd $(@D); $(SIZE) $(@F)
@echo ""

.SECONDEXPANSION:
$(OUT)/%.ld: %.ld.sx
mkdir -p $(@D)
@echo "Elf: Preprocessing $(@F) ..."
Expand Down
1 change: 0 additions & 1 deletion mk/tc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ OD := $(TC)-objdump
OC := $(TC)-objcopy
STRIP := $(TC)-strip
A2L := $(TC)-addr2line
SIZE := $(TC)-size
endif

ifeq ($(realpath $(TI)),)
Expand Down
8 changes: 8 additions & 0 deletions mk/tc_get.mk
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ T_ALLOWLIST += get_all_tc get_avr_tc get_arm_tc get_riscv_tc

# GIT REPO RECOMMENDED
# Provide git repo path for toolchains for better experience
ESIZE_REPO := https://github.com/VisorFolks/cc_elf_size.git
AVR_TC_REPO ?=
RISC_V_TC_REPO ?=
ARM_TC_REPO ?=
Expand All @@ -23,6 +24,13 @@ get_all_tc: --tc_clear get_avr_tc get_arm_tc get_riscv_tc
--tc_clear:
rm -rf $(TOOLS_ROOT)

SIZE := $(TOOLS_ROOT)/cc_elf_size/size
$(SIZE):
$(info < ! > Fetching ELF-Size utility ...)
cd $(TOOLS_ROOT); git clone $(ESIZE_REPO);
make -C $(@D)
echo "< / > Done !"

get_arm_tc: $(TOOLS_ROOT)/arm-toolchain/bin/arm-none-eabi-gcc
$(TOOLS_ROOT)/arm-toolchain/bin/arm-none-eabi-gcc:
ifeq ($(ARM_TC_REPO),)
Expand Down

0 comments on commit f9ce0a8

Please sign in to comment.