@@ -28,8 +28,8 @@ LITTLE_ENDIAN ?= 0
2828
2929ifneq ($(LITTLE_ENDIAN ) ,0)
3030ARCH_COMPILEFLAGS += -mlittle-endian
31- ARCH_LDFLAGS += -EL
32- GLOBAL_MODULE_LDFLAGS += -EL
31+ ARCH_LDFLAGS += -Wl,- EL
32+ GLOBAL_MODULE_LDFLAGS += -Wl,- EL
3333endif
3434
3535LIBGCC := $(shell $(TOOLCHAIN_PREFIX ) gcc $(GLOBAL_COMPILEFLAGS ) $(ARCH_COMPILEFLAGS ) $(GLOBAL_COMPILEFLAGS ) -print-libgcc-file-name)
@@ -40,7 +40,9 @@ cc-option = $(shell if test -z "`$(1) $(2) -S -o /dev/null -xc /dev/null 2>&1`";
4040
4141ARCH_OPTFLAGS := -O2
4242
43- ARCH_LDFLAGS += -relax
43+ # -L$(BUILDDIR) is needed so the linker can find the xilinx.ld it wants
44+ ARCH_LDFLAGS += -Wl,-relax -L$(BUILDDIR )
45+ GLOBAL_MODULE_LDFLAGS += -L$(BUILDDIR )
4446
4547KERNEL_BASE ?= $(MEMBASE )
4648KERNEL_LOAD_OFFSET ?= 0
@@ -52,9 +54,11 @@ GLOBAL_DEFINES += \
5254
5355# potentially generated files that should be cleaned out with clean make rule
5456GENERATED += \
55- $(BUILDDIR ) /linker.ld
57+ $(BUILDDIR ) /linker.ld \
58+ $(BUILDDIR ) /xilinx.ld
59+
60+ # Rules for generating the linker scripts
5661
57- # rules for generating the linker
5862$(BUILDDIR ) /linker.ld : $(LOCAL_DIR ) /linker.ld $(wildcard arch/* .ld) linkerscript.phony
5963 @echo generating $@
6064 @$(MKDIR )
@@ -64,6 +68,16 @@ $(BUILDDIR)/linker.ld: $(LOCAL_DIR)/linker.ld $(wildcard arch/*.ld) linkerscript
6468linkerscript.phony :
6569.PHONY : linkerscript.phony
6670
67- LINKER_SCRIPT += $(BUILDDIR ) /linker.ld
71+ # Note: This is all messy and horrible
72+ # GCC needs to find a xilinx.ld, we usually pass the LINKER_SCRIPT as -dT (default linker script), and so
73+ # does GCC when it can't find a -T option in the command line
74+ # Because of that, we pass the actual linker script as linker.ld
75+
76+ $(BUILDDIR ) /xilinx.ld :
77+ $(NOECHO ) touch $@
78+
79+ EXTRA_LINKER_SCRIPTS += $(BUILDDIR ) /linker.ld
80+
81+ LINKER_SCRIPT += $(BUILDDIR ) /xilinx.ld
6882
6983include make/module.mk
0 commit comments