linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] Makefile: Tell compiler to generate bare-metal code
@ 2022-01-17 15:33 Andre Przywara
  2022-01-17 16:47 ` Mark Rutland
  2022-01-17 17:49 ` Russell King (Oracle)
  0 siblings, 2 replies; 7+ messages in thread
From: Andre Przywara @ 2022-01-17 15:33 UTC (permalink / raw)
  To: Mark Rutland; +Cc: Jaxson Han, linux-arm-kernel, Robin Murphy

Our GCC invocation does not provide many parameters, which lets the
toolchain fill in its own default setup.
In case of a native build or when using a full-featured cross-compiler,
this probably means Linux userland, which is not what we want for a
bare-metal application like boot-wrapper.

Tell the compiler to forget about those standard settings, and only use
what we explicitly ask for. In particular that means to not use toolchain
provided libraries, since they might pull in more code than we want, and
might not run well in the boot-wrapper environment.

Disable the stack protector, as this adds code that relies on userland:
"If a guard check fails, an error message is printed and the program
exits." (from the gcc manpage).

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
---
Hi,

compared to [PATCH v2 3/9] this drops the more contentious options (for
now, at least), and focuses on what's really needed. Including
-fno-stack-protector, as the need for this showed up in the cleanup series
already.

Cheers,
Andre

 Makefile.am | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Makefile.am b/Makefile.am
index f941b07..581840e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -125,6 +125,8 @@ CHOSEN_NODE	:= chosen {						\
 CPPFLAGS	+= $(INITRD_FLAGS)
 CFLAGS		+= -I$(top_srcdir)/include/ -I$(top_srcdir)/$(ARCH_SRC)/include/
 CFLAGS		+= -Wall -fomit-frame-pointer
+CFLAGS		+= -ffreestanding -nostdlib	# this is not for userland
+CFLAGS		+= -fno-stack-protector		# no terminal to print
 CFLAGS		+= -ffunction-sections -fdata-sections
 CFLAGS		+= -fno-pic -fno-pie
 LDFLAGS		+= --gc-sections
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-01-17 18:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-17 15:33 [PATCH v3] Makefile: Tell compiler to generate bare-metal code Andre Przywara
2022-01-17 16:47 ` Mark Rutland
2022-01-17 16:53   ` Andre Przywara
2022-01-17 17:24     ` Mark Rutland
2022-01-17 17:49 ` Russell King (Oracle)
2022-01-17 18:04   ` Russell King (Oracle)
2022-01-17 18:25   ` Andre Przywara

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).