@@ -30,8 +30,8 @@ LITTLE_ENDIAN ?= 0
3030
3131ifneq ($(LITTLE_ENDIAN ) ,0)
3232ARCH_COMPILEFLAGS += -mlittle-endian
33- ARCH_LDFLAGS += -EL
34- GLOBAL_MODULE_LDFLAGS += -EL
33+ ARCH_LDFLAGS += -Wl,- EL
34+ GLOBAL_MODULE_LDFLAGS += -Wl,- EL
3535endif
3636
3737LIBGCC := $(shell $(TOOLCHAIN_PREFIX ) gcc $(GLOBAL_COMPILEFLAGS ) $(ARCH_COMPILEFLAGS ) $(GLOBAL_COMPILEFLAGS ) -print-libgcc-file-name)
@@ -42,7 +42,9 @@ cc-option = $(shell if test -z "`$(1) $(2) -S -o /dev/null -xc /dev/null 2>&1`";
4242
4343ARCH_OPTFLAGS := -O2
4444
45- ARCH_LDFLAGS += -relax
45+ # -L$(BUILDDIR) is needed so the linker can find the xilinx.ld it wants
46+ ARCH_LDFLAGS += -Wl,-relax -L$(BUILDDIR )
47+ GLOBAL_MODULE_LDFLAGS += -L$(BUILDDIR )
4648
4749KERNEL_BASE ?= $(MEMBASE )
4850KERNEL_LOAD_OFFSET ?= 0
@@ -54,9 +56,11 @@ GLOBAL_DEFINES += \
5456
5557# potentially generated files that should be cleaned out with clean make rule
5658GENERATED += \
57- $(BUILDDIR ) /linker.ld
59+ $(BUILDDIR ) /linker.ld \
60+ $(BUILDDIR ) /xilinx.ld
61+
62+ # Rules for generating the linker scripts
5863
59- # rules for generating the linker
6064$(BUILDDIR ) /linker.ld : $(LOCAL_DIR ) /linker.ld $(wildcard arch/* .ld) linkerscript.phony
6165 @echo generating $@
6266 @$(MKDIR )
@@ -66,6 +70,16 @@ $(BUILDDIR)/linker.ld: $(LOCAL_DIR)/linker.ld $(wildcard arch/*.ld) linkerscript
6670linkerscript.phony :
6771.PHONY : linkerscript.phony
6872
69- LINKER_SCRIPT += $(BUILDDIR ) /linker.ld
73+ # Note: This is all messy and horrible
74+ # GCC needs to find a xilinx.ld, we usually pass the LINKER_SCRIPT as -dT (default linker script), and so
75+ # does GCC when it can't find a -T option in the command line
76+ # Because of that, we pass the actual linker script as linker.ld
77+
78+ $(BUILDDIR ) /xilinx.ld :
79+ $(NOECHO ) touch $@
80+
81+ EXTRA_LINKER_SCRIPTS += $(BUILDDIR ) /linker.ld
82+
83+ LINKER_SCRIPT += $(BUILDDIR ) /xilinx.ld
7084
7185include make/module.mk
0 commit comments