Skip to content

Commit 8ccaf3c

Browse files
Shawnshhwenlingz
authored andcommitted
use genld.sh to generate link_ram.ld
Use genld.sh instead of config.h to generate link_ram.ld. It can avoid the conflicts of the syntax between ld script and C. V1->V2: change the deps name to config, Tracked-On: #861 Signed-off-by: Huihuang Shi <huihuang.shi@intel.com> reviewed-by: Junjie Mao <junjie.mao@intel.com>
1 parent 203016b commit 8ccaf3c

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

hypervisor/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ include $(BASEDIR)/../scripts/deps.mk
3434

3535
include scripts/kconfig/kconfig.mk
3636

37+
LD_IN_TOOL = scripts/genld.sh
38+
BASH = $(shell which bash)
39+
3740
CFLAGS += -Wall -W
3841
CFLAGS += -ffunction-sections -fdata-sections
3942
CFLAGS += -fshort-wchar -ffreestanding
@@ -248,7 +251,7 @@ $(HV_OBJDIR)/$(HV_FILE).bin: $(HV_OBJDIR)/$(HV_FILE).out
248251
$(OBJCOPY) -O binary $< $(HV_OBJDIR)/$(HV_FILE).bin
249252

250253
$(HV_OBJDIR)/$(HV_FILE).out: $(C_OBJS) $(S_OBJS)
251-
$(CC) -E -x c $(patsubst %, -I%, $(INCLUDE_PATH)) $(ARCH_LDSCRIPT_IN) | grep -v '^#' > $(ARCH_LDSCRIPT)
254+
${BASH} ${LD_IN_TOOL} $(ARCH_LDSCRIPT_IN) $(ARCH_LDSCRIPT) ${HV_OBJDIR}/.config
252255
$(CC) -Wl,-Map=$(HV_OBJDIR)/$(HV_FILE).map -o $@ $(LDFLAGS) $(ARCH_LDFLAGS) -T$(ARCH_LDSCRIPT) $^
253256

254257
.PHONY: clean

hypervisor/bsp/ld/link_ram.ld.in

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#include "config.h"
2-
31
ENTRY(cpu_primary_start_32)
42

53
MEMORY

hypervisor/scripts/genld.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
in=$1
4+
out=$2
5+
config=$3
6+
7+
cp $in $out
8+
grep -v "^#" ${config} | while read line; do
9+
IFS='=' read -ra arr <<<"$line"
10+
field=${arr[0]}
11+
value=${arr[1]}
12+
sed -i "s/\b$field\b/$value/g" $out
13+
done

0 commit comments

Comments
 (0)