From: jgunthorpe@obsidianresearch.com (Jason Gunthorpe)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] [ARM] Use AT() in the linker script to create correct program headers
Date: Mon, 1 Oct 2012 12:35:43 -0600 [thread overview]
Message-ID: <20121001183543.GC22342@obsidianresearch.com> (raw)
In-Reply-To: <20121001175647.GD2100@linaro.org>
On Mon, Oct 01, 2012 at 06:56:47PM +0100, Dave Martin wrote:
> > > If the kernel is intended to be loadable at a physical address which is
> > > not statically known, no ELF loader that does not ignore the ELF
> > > phdr
> >
> > In this case you can't really use a standard ELF loader to load the
> > kernel so, LOAD_OFFSET = 0 is fine. My case is using an ELF loader,
> > and I have set options for a static physical load address.
>
> Generally, people should try to be compatible with the single kernel
> image effort unless there's a really compelling reason not to.
Well, all the embedded kernels we use are always custom built and
minimized for the target. So as long as there are options to minimize
the kernel size/increase performance by taking out the relocation
stuff, we are going to use them.
All our boards on PPC and ARM use DT kernels now, and we try to flow
back all the generic stuff as best we can. As someone that makes
custom boards, I really like DT, it makes things much easier :)
> Wouldn't your firmware be incapable of loading a multiplatform kernel?
Well, no, it boots ELFs, so it can boot anything, with any memory
layout. A 2nd stage loader would be required to boot standard kernels,
that loader would be an ELF with 1 section for the 2nd stage, 1
section for the zImage and 1 section for the initrd, with proper load
headers.
Creating such a system is a lot of annoyance, so we never have - it is
*so much* easier to just boot vmlinux ELF directly.
> Well, that was a bit of a pedantic point I admit, but there are
> conflicting definitions of what "virtual address" really means in these
> situations. The original SYSV ABI spec explicitly specifies that
> e_entry is a virtual address, but is also rather vague about how the
> paddr fields should be interpreted.
Granted the spec is vauge, but convention for loaders seems to be that
it is a physical address these days.
It could be a virtual address, and the loader could translate it by
looking at the phdrs, but I don't see any other arches doing that?
> All that AT(ADDR(blah) - LOAD_OFFSET) stuff is cumbersome, but if it's
> at least consistent with other architectures then it may not such a
> disaster. It's not universal though: less than 50% of the arches in
> the kernel currently seem to use this.
I agree it is not nice, but I once did try to make PHDRS work as you
described, but was never successful. IIRC there were serious linker
bugs) As you note the AT method is consistent with other arches, and
the generic vmlinux.lds.h
> > Yes, if you use more loader stages then the load headers are ignored.
> > Our boot loaders on our boards boot straight ELF vmlinux.gz so they
> > need correct load headers.
> If your image is compressed anyway though, why are you not using zImage?
We store the kernel in a CRAMFS, the loader pulls it out and
decompresses it, processes the ELF sections 'on the fly' and jumps to
it. Using zImage would result in double-decompression, and reallly has
no benefits to us.
Jason
next prev parent reply other threads:[~2012-10-01 18:35 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-30 23:21 [PATCH] [ARM] Use AT() in the linker script to create correct program headers Jason Gunthorpe
2012-10-01 15:39 ` Dave Martin
2012-10-01 16:06 ` Jason Gunthorpe
2012-10-01 17:56 ` Dave Martin
2012-10-01 18:35 ` Jason Gunthorpe [this message]
2012-10-02 10:23 ` Dave Martin
2012-10-02 17:47 ` Jason Gunthorpe
2012-10-03 10:43 ` Dave Martin
2012-10-03 18:44 ` Jason Gunthorpe
2012-10-04 11:36 ` Dave Martin
2012-10-04 17:59 ` Jason Gunthorpe
2012-10-08 10:46 ` Dave Martin
2012-10-09 18:25 ` Jason Gunthorpe
2012-10-10 9:55 ` Dave Martin
2012-10-12 21:24 ` Jason Gunthorpe
2012-10-05 8:45 ` Russell King - ARM Linux
2012-10-08 10:24 ` Dave Martin
2012-10-09 17:37 ` Jason Gunthorpe
2012-10-10 9:18 ` Dave Martin
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=20121001183543.GC22342@obsidianresearch.com \
--to=jgunthorpe@obsidianresearch.com \
--cc=linux-arm-kernel@lists.infradead.org \
/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;
as well as URLs for NNTP newsgroup(s).