-
Notifications
You must be signed in to change notification settings - Fork 0
/
Linker.uk
63 lines (56 loc) · 2.14 KB
/
Linker.uk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
RASPI_LDFLAGS-y += -Wl,-m,aarch64elf
ifeq ($(CONFIG_ARM64_ERRATUM_843419),y)
RASPI_LDFLAGS-y += -mfix-cortex-a53-843419
endif
##
## Link image
##
RASPI_IMAGE := $(BUILD_DIR)/$(CONFIG_UK_NAME)_raspi-$(CONFIG_UK_ARCH)
RASPI_ELF_IMAGE := $(RASPI_IMAGE).elf
RASPI_LD_SCRIPT_FLAGS := $(addprefix -Wl$(comma)-dT$(comma),\
$(UK_PLAT_RASPI_DEF_LDS))
RASPI_LD_SCRIPT_FLAGS += $(addprefix -Wl$(comma)-T$(comma),\
$(LIBRASPIPLAT_DEF_LDS) $(EXTRA_LD_SCRIPT-y))
$(RASPI_ELF_IMAGE): $(RASPI_ALIBS) $(RASPI_ALIBS-y) $(RASPI_OLIBS) $(RASPI_OLIBS-y) \
$(UK_ALIBS) $(UK_ALIBS-y) $(UK_OLIBS) $(UK_OLIBS-y)
$(call build_cmd,LD,,$(RASPI_IMAGE).ld.o,\
$(LD) -r $(LIBLDFLAGS) $(LIBLDFLAGS-y) \
$(RASPI_LDFLAGS) $(RASPI_LDFLAGS-y) \
$(RASPI_OLIBS) $(RASPI_OLIBS-y) \
$(UK_OLIBS) $(UK_OLIBS-y) \
-lgcc \
-Wl$(comma)--start-group \
$(RASPI_ALIBS) $(RASPI_ALIBS-y) \
$(UK_ALIBS) $(UK_ALIBS-y) \
-Wl$(comma)--end-group \
-o $(RASPI_IMAGE).ld.o)
$(call build_cmd,OBJCOPY,,$(RASPI_IMAGE).o,\
$(OBJCOPY) -w -G _libraspiplat_entry \
$(RASPI_IMAGE).ld.o $(RASPI_IMAGE).o)
$(call build_cmd,LD,,$@,\
$(LD) $(LDFLAGS) $(LDFLAGS-y) \
$(RASPI_LDFLAGS) $(RASPI_LDFLAGS-y) \
$(RASPI_LD_SCRIPT_FLAGS) \
$(RASPI_IMAGE).o -o $@)
$(call build_bootinfo,$@)
$(RASPI_IMAGE): $(RASPI_IMAGE).elf
$(call build_cmd,SCSTRIP,,$@,\
$(STRIP) -s \
$(SECT_STRIP_FLAGS) $(SECT_STRIP_FLAGS-y) \
$< -o $@ 2>&1 | \
{ $(GREP) -Ev \
"Empty loadable segment detected|section.*lma.*adjusted to.*" || \
true; })
$(call build_cmd,OBJCOPY,,$(RASPI_IMAGE).img,\
$(OBJCOPY) -O binary $(RASPI_ELF_IMAGE) $(BUILD_DIR)/kernel8.img)
# register images to the build
ifeq ($(CONFIG_PLAT_RASPI),y)
UK_DEBUG_IMAGES-y += $(RASPI_ELF_IMAGE)
UK_IMAGES-y += $(RASPI_IMAGE)
endif
# ...for cleaning:
LIBRASPIPLAT_CLEAN += $(call build_clean,$(RASPI_IMAGE).o)
LIBRASPIPLAT_CLEAN += $(call build_clean,$(RASPI_IMAGE).ld.o)
LIBRASPIPLAT_CLEAN += $(call build_clean,$(RASPI_IMAGE).elf)
LIBRASPIPLAT_CLEAN += $(call build_clean,$(RASPI_IMAGE).img)
LIBRASPIPLAT_CLEAN += $(call build_clean,$(BUILD_DIR)/kernel8.img)