Skip to contentSkip to conversation

Makefile: Don't mess with .text section location for selected arches

PATCH In review Alexey Brodkin 2 participants 2 messages Feb 21, 2018 – Feb 23, 2018 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Makefile: Don't mess with .text section location for selected arches

Most of architectures have .text section situated in the very beginning of U-Boot binary and thus it is very logical that CONFIG_SYS_TEXT_BASE is used on final linkage step to specify where U-Boot gets linked to.

For that we pass the following construction to the LD:
---------------------------->8----------------------- xxx-ld ... -Ttext $(CONFIG_SYS_TEXT_BASE) ... ---------------------------->8-----------------------

But there could be exceptions. For example:
1. In case of ARCv2 we want to put vectors table in its own section .ivt in front of .text section which means we need either add an offset to CONFIG_SYS_TEXT_BASE to compensate for .ivt or don't pass "-Ttext" to the LD at all and specify link base in linker script directly.

2. Some architectures even though have .text section in the very beginning of the U-Boot image still use different symbols to specify link-base:
* NIOS2: CONFIG_SYS_MONITOR_BASE (which I really like because that exactly what makes sense - where out image starts but not beginning of its .text section which just happened to match the whole image beginning)
* EXTENSA: CONFIG_SYS_TEXT_ADDR
* X86: Which doesn't use CONFIG_SYS_MONITOR_BASE in case of EFI otherwise sets explicit link base in u-boot.lds

I think that's good to allow for flexibility and don't require each and every architecture or even platform to specify CONFIG_SYS_TEXT_BASE as well as use it to set .text section location.

So let's only pass "-Ttext xxx" for those architectures who don't set link-base explicitly in their linker scripts.

This patch iaddresses comments for previously sent
https://patchwork.ozlabs.org/patch/867540/.

Cc Masahiro Yamada <[email protected]>
Cc Marek Vasut <[email protected]>
Cc Max Filippov <[email protected]>
Cc Simon Glass <[email protected]>
Cc Tom Rini <[email protected]>
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +1 -1
index cd265f546677..57cb4b87d930 100644
@@ -820,7 +820,7 @@ LDFLAGS_u-boot += $(LDFLAGS_FINAL)
 # Avoid 'Not enough room for program headers' error on binutils 2.28 onwards.
 LDFLAGS_u-boot += $(call ld-option, --no-dynamic-linker)
 
-ifneq ($(CONFIG_SYS_TEXT_BASE),)
+ifeq ($(CONFIG_ARC)$(CONFIG_NIOS2)$(CONFIG_X86)$(CONFIG_XTENSA),)
 LDFLAGS_u-boot += -Ttext $(CONFIG_SYS_TEXT_BASE)
 endif
 
Signature · 1 line
2.14.3
#1 lore raw
Quoted 5 lines · Alexey Brodkin

Most of architectures have .text section situated in the very beginning of U-Boot binary and thus it is very logical that CONFIG_SYS_TEXT_BASE is used on final linkage step to specify where U-Boot gets linked to.

For that we pass the following construction to the LD:

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180223/2f8e9614/attachment.sig>