From bertrand at jacquin.bzh Sat Apr 25 16:15:03 2020 From: bertrand at jacquin.bzh (Bertrand Jacquin) Date: Sat, 25 Apr 2020 15:15:03 +0100 Subject: [PATCH] build: do not produce a dynamically linked position independent executable In-Reply-To: <20200425141503.2410627-1-bertrand@jacquin.bzh> References: <20200425141503.2410627-1-bertrand@jacquin.bzh> Message-ID: <20200425141503.2410627-4-bertrand@jacquin.bzh> --- rules.mk | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rules.mk b/rules.mk index 23d55f677f58..5ff80d86509b 100644 --- a/rules.mk +++ b/rules.mk @@ -63,6 +63,9 @@ MCFLAGS += -specs=nosys.specs # Do not use the standard system startup files when linking MCFLAGS += -nostartfiles +# Don't produce a dynamically linked position independent executable +MCFLAGS += -no-pie + MCFLAGS += -mcpu=$(MCU) LDFLAGS += $(MCFLAGS) -T$(LDSCRIPT) \ -Wl,-Map=$(BUILDDIR)/$(PROJECT).map,--cref,--no-warn-mismatch,--gc-sections From bertrand at jacquin.bzh Sat Apr 25 16:15:02 2020 From: bertrand at jacquin.bzh (Bertrand Jacquin) Date: Sat, 25 Apr 2020 15:15:02 +0100 Subject: [PATCH] build: move -nostartfiles earlier In-Reply-To: <20200425141503.2410627-1-bertrand@jacquin.bzh> References: <20200425141503.2410627-1-bertrand@jacquin.bzh> Message-ID: <20200425141503.2410627-3-bertrand@jacquin.bzh> --- rules.mk | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rules.mk b/rules.mk index c0f99a6c92e2..23d55f677f58 100644 --- a/rules.mk +++ b/rules.mk @@ -60,8 +60,11 @@ ifeq ($(EMULATION),) # Discard compiler default specs MCFLAGS += -specs=nosys.specs +# Do not use the standard system startup files when linking +MCFLAGS += -nostartfiles + MCFLAGS += -mcpu=$(MCU) -LDFLAGS += $(MCFLAGS) -nostartfiles -T$(LDSCRIPT) \ +LDFLAGS += $(MCFLAGS) -T$(LDSCRIPT) \ -Wl,-Map=$(BUILDDIR)/$(PROJECT).map,--cref,--no-warn-mismatch,--gc-sections else DEFS += -D_GNU_SOURCE From bertrand at jacquin.bzh Sat Apr 25 16:15:01 2020 From: bertrand at jacquin.bzh (Bertrand Jacquin) Date: Sat, 25 Apr 2020 15:15:01 +0100 Subject: [PATCH] build: discard compiler default specs In-Reply-To: <20200425141503.2410627-1-bertrand@jacquin.bzh> References: <20200425141503.2410627-1-bertrand@jacquin.bzh> Message-ID: <20200425141503.2410627-2-bertrand@jacquin.bzh> This allow to overwrite any potential default specs defined in local gcc build like stack-protector which is now enforced by more and more Linux distributions while it should not apply in chopstx use case --- rules.mk | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rules.mk b/rules.mk index 3915268418d4..c0f99a6c92e2 100644 --- a/rules.mk +++ b/rules.mk @@ -57,6 +57,9 @@ LDFLAGS = ### ifeq ($(EMULATION),) +# Discard compiler default specs +MCFLAGS += -specs=nosys.specs + MCFLAGS += -mcpu=$(MCU) LDFLAGS += $(MCFLAGS) -nostartfiles -T$(LDSCRIPT) \ -Wl,-Map=$(BUILDDIR)/$(PROJECT).map,--cref,--no-warn-mismatch,--gc-sections From bertrand at jacquin.bzh Sat Apr 25 16:15:00 2020 From: bertrand at jacquin.bzh (Bertrand Jacquin) Date: Sat, 25 Apr 2020 15:15:00 +0100 Subject: [PATCH] build: initilize empty MCFLAGS and LDFLAGS Message-ID: <20200425141503.2410627-1-bertrand@jacquin.bzh> Such variables are modified later, it make it clearer to read when variable are only appened --- rules.mk | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/rules.mk b/rules.mk index 110079efdaaa..3915268418d4 100644 --- a/rules.mk +++ b/rules.mk @@ -50,14 +50,17 @@ IINCDIR = $(patsubst %,-I%,$(INCDIR)) LLIBDIR = $(patsubst %,-L%,$(LIBDIR)) VPATH = $(sort $(dir $(CSRC))) + +# Initilize empty LDFLAGS and MCFLAGS +MCFLAGS = +LDFLAGS = + ### ifeq ($(EMULATION),) -MCFLAGS = -mcpu=$(MCU) -LDFLAGS = $(MCFLAGS) -nostartfiles -T$(LDSCRIPT) \ +MCFLAGS += -mcpu=$(MCU) +LDFLAGS += $(MCFLAGS) -nostartfiles -T$(LDSCRIPT) \ -Wl,-Map=$(BUILDDIR)/$(PROJECT).map,--cref,--no-warn-mismatch,--gc-sections else -MCFLAGS = -LDFLAGS = DEFS += -D_GNU_SOURCE endif