public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Graeme Russ <graeme.russ@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] Quick linker script questions - Assigning Values to Symbols outside the script
Date: Thu, 17 Jun 2010 22:52:44 +1000	[thread overview]
Message-ID: <4C1A1A9C.5030409@gmail.com> (raw)

Hi All,

I'm messing around with consolidating the linker scripts for x86 so I have
a common platform script in the arch directory. x86 uses some fancy
offset calculations to place the Reset Vector and Reset Handler code at the
end of the Boot ROM. Currently this is done on a per-board basis.

Currently I have in the linker script:

. = 0xfffffe00;
.start32 : AT (TEXT_BASE + 0x3fe00) { KEEP(*(.start32)); }

. = 0xf800;
.start16 : AT (TEXT_BASE + 0x3f800) { KEEP(*(.start16)); }

. = 0xfff0;
.resetvec : AT (TEXT_BASE + 0x3fff0) { KEEP(*(.resetvec)); }

I want to replace this with:

FLASH_SIZE	= 0x40000;
START_32	= 0xfe00;
START_16	= 0xf800;
RESET_SEG_START	= 0xffff0000;
RESET_SEG_SIZE	= 0x10000;
RESET_VEC_LOC	= 0xfff0;

. = RESET_SEG_START + START_32;
.start32 : AT (TEXT_BASE + (FLASH_SIZE - RESET_SEG_SIZE + START_32))
{KEEP(*(.start32)); }

. = START_16;
.start16 : AT (TEXT_BASE + (FLASH_SIZE - RESET_SEG_SIZE + START_16))
{KEEP(*(.start16)); }

. = RESET_VEC_LOC;
.resetvec : AT (TEXT_BASE + (FLASH_SIZE - RESET_SEG_SIZE + RESET_VEC_LOC))
{ KEEP(*(.resetvec)); }

Now that looks far more complicated, but it allows the Boot ROM size to be
defined without having to calculate, by hand, where these sections need to
be placed. It also allows the location of (and therefore the size allocated
to) the 16-bit and 32-bit boot-strap code (which always runs from the Boot
ROM) to be adjusted to maximise that amount of space for the main U-Boot
binary.

FLASH_SIZE, START_32, and START_16 are really the only board specific
definitions (and even then, for the majority of use-cases only FLASH_SIZE
would need adjusting). So I would like to move the bulk of the linker
script to $(SRCTREE)/arch/x86/cpu/u-boot.lds and have these three defined
in something like $(SRCTREE)/board/$(BOARDDIR)/board_defs.lds

But things are not working the way I want them to. The following works...

$(SRCTREE)/board/$(BOARDDIR)/board_defs.lds
FLASH_SIZE	= 0x40000;
START_32	= 0xfa00;
START_16	= 0xff00;

$(SRCTREE)/arch/x86/cpu/u-boot.lds
RESET_SEG_START	= 0xffff0000;
RESET_SEG_SIZE	= 0x10000;
RESET_VEC_LOC	= 0xfff0;

INCLUDE /home/graeme/Source/U-Boot/x86/board/eNET/board_defs.lds
SECTIONS
{
	. = TEXT_BASE;		/* Location of bootcode in flash */
	_i386boot_text_start = .;
	.text  : { *(.text); }
etc...

But the following will not...

$(SRCTREE)/board/$(BOARDDIR)/board_defs.lds
FLASH_SIZE	= 0x40000;
START_32	= 0xfa00;
START_16	= 0xff00;

$(SRCTREE)/board/$(BOARDDIR)/config.mk
PLATFORM_LIBS += -L $(SRCTREE)/board/$(BOARDDIR)

$(SRCTREE)/arch/x86/cpu/u-boot.lds
RESET_SEG_START	= 0xffff0000;
RESET_SEG_SIZE	= 0x10000;
RESET_VEC_LOC	= 0xfff0;

INCLUDE board_defs.lds
SECTIONS
{
	. = TEXT_BASE;		/* Location of bootcode in flash */
	_i386boot_text_start = .;
	.text  : { *(.text); }
etc...

                 reply	other threads:[~2010-06-17 12:52 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4C1A1A9C.5030409@gmail.com \
    --to=graeme.russ@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox