From mboxrd@z Thu Jan 1 00:00:00 1970 From: Steve Rae Date: Wed, 11 Jun 2014 11:56:00 -0700 Subject: [U-Boot] [PATCH] arm: Allow u-boot to run from offset base address In-Reply-To: References: <1400105145-6628-1-git-send-email-drambo@broadcom.com> <1400107265.16796.8.camel@yellow> <5374CD55.3010703@broadcom.com> <20140515152119.9939F38047D@gemini.denx.de> <5374E64B.1060104@broadcom.com> <20140515191957.74A853804B6@gemini.denx.de> <538367B7.5090108@broadcom.com> <538D18C5.206@broadcom.com> <53961CFE.4090106@broadcom.com> <539746C4.9040004@broadcom.com> <20140610181341.7E10138131B@gemini.denx.de> <53975EC2.1080209@broadcom.com> <20140610203500.0D37038131B@gemini.denx.de> <53979199.5010100@broadcom.com> <20140611044928.25167382C16@gemini.denx.de> Message-ID: <5398A640.3050105@broadcom.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 14-06-10 11:45 PM, Albert ARIBAUD wrote: > Hi Wolfgang, > > On Wed, 11 Jun 2014 06:49:28 +0200, Wolfgang Denk wrote: > >> Dear Steve, >> >> In message <53979199.5010100@broadcom.com> you wrote: >>> >>> OK - I think that one of the alternate proposals would be to >>> conditionally reserve a "32 byte block" prior to the _start symbol (in >>> "arch/arm/cpu/armv8/start.S") which would then be filled in by a >>> post-processing step... This could be implemented by: >> >> Yes, that illustrates the idea. However, this implementation suffers >> from the use of an #ifdef where none is actually needed. Instead, you >> can create your own source file which defines the header; this could >> be then even in it's own segment, say: >> >> your_header.c: >> >> struct your_header { >> u_int32[8]; >> } your_header __attribute__ ((__section__ (".your_hdr"))); >> >> All that is needed then is to make the linker place this segment in >> front of the text segment. >> >> This avoids an ugly #ifdef, and also modifications in the common code. > > Agreed and seconded. > > Plus, using a dedicated 'header' section and a separate C source file > for the header makes it automatic that if no input 'header' section > were provided then no output 'header' section would be emitted; IOW, > we would not need two different linker scripts, a single one would be > useable for both 'headerless' and 'headerful' image types. > > Also, the alignment constraint should be configurable. > >> Best regards, >> >> Wolfgang Denk > > Amicalement, > Albert, Wolfgang, et al. I didn't know about the automatic handling of "conditional" sections in the linker script file - Thanks!!! So if I add a "your_header.c" as above, then (1) I need to modify "arch/arm/cpu/armv8/u-boot.lds": . = 0x00000000; + . = ALIGN(8); + .your_hdr : { + KEEP(*(.your_hdr*)); + } + . = ALIGN(8); .text : { (2) then (I believe) I need to modify the "Makefile" to define the start address of this new section: +LDFLAGS_u-boot += --section-start=".your_hdr"=CONFIG_YOUR_HEADER_ADDR (3) and (I believe) I need to modify the OBJCOPYFLAGS (somewhere) in order to include this new section in the u-boot.bin: +OBJCOPYFLAGS += -j .your_hdr (... I don't actually have this working yet; so I suspect more changes are required ...) And in the end, (I believe) I am just going to have a block (likely 4096 bytes) prepended to the "original" u-boot.bin; which I can do today with no code changes at all.... Remember that original design request was effectively a two line change: + gd->mon_len += CONFIG_SYS_TEXT_BASE % 4096; and + gd->relocaddr += CONFIG_SYS_TEXT_BASE % 4096; Regrettably, since this is not going to be accepted, I am abandoning this change. Thanks, Steve