From: Richard Henderson <rth@twiddle.net>
To: Rusty Russell <rusty@rustcorp.com.au>
Cc: linux-kernel@vger.kernel.org
Subject: Re: in-kernel linking issues
Date: Fri, 15 Nov 2002 04:51:46 -0800 [thread overview]
Message-ID: <20021115045146.A23944@twiddle.net> (raw)
In-Reply-To: <20021115084757.A640A2C145@lists.samba.org>; from rusty@rustcorp.com.au on Fri, Nov 15, 2002 at 07:44:40PM +1100
One more thing:
Are you really REALLY sure you don't want to load ET_DYN or ET_EXEC
files (aka shared libraries or executables) instead of ET_REL files
(aka .o files)?
If you load ET_DYN or ET_EXEC objects, then a lot of the ugliness
wrt linking can be left to the linker, where it belongs. You'd only
need to process the dynamic relocations remaining in the object.
Which would avoid the problems I mentioned earlier today wrt section
layout, and would also avoid the effort to create .got sections and
the like.
The .init bits could be allocated to their own segment via linker
script widgetry. E.g.
PHDRS {
core PT_LOAD;
init PT_LOAD;
rel PT_LOAD;
dyn PT_DYNAMIC;
}
SECTIONS
{
.text : { *(.text) } :core
.rodata : { *(.rodata) *(.rodata.*) } :core
.data : { *(.data) CONSTRUCTORS } :core
.got : { *(.got.plt) *(.got) } :core
.sdata : { *(.sdata) } :core
.sbss : { *(.sbss) *(.scommon) } :core
.bss : { *(.bss) *(.dynbss) *(COMMON) } :core
.init.text ALIGN(PAGE_SIZE) : { *(.init.text) } :init
.init.data : { *(.init.data) } :init
.hash : { *(.hash) } :rel
.dynsym : { *(.dynsym) } :rel
.dynstr : { *(.dynstr) } :rel
.rel.dyn : { *(.rel*) } :rel
.dynamic : { *(.dynamic) } :rel :dyn
}
to be used like so
ld -T z.ld -shared -o z.so z.o
Now we've got things nicely collected into three program headers:
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
LOAD 0x001000 0x00000000 0x00000000 0x00020 0x00024 RWE 0x1000
LOAD 0x002000 0x00001000 0x00001000 0x00014 0x00014 RWE 0x1000
LOAD 0x002014 0x00001014 0x00001014 0x002a4 0x002a4 RW 0x1000
DYNAMIC 0x002240 0x00001240 0x00001240 0x00078 0x00078 RW 0x4
Section to Segment mapping:
Segment Sections...
00 .text .got .bss
01 .init.text .init.data
02 .hash .dynsym .dynstr .rel.dyn .dynamic
03 .dynamic
The first segment contains the core sections, as you've got them now.
The second contains the init sections, which can be freed after running
the module init routine, and the third contains all of the dynamic
linking information, which can be discarded almost immediately.
(Though perhaps it's just as easy to discard it with the .init segment.)
This does reduce the freedom to allocate the init sections completely
separately from the core sections, but that seems a small price to pay
for the extreme reduction in complexity for the in-kernel loader.
Thoughts?
r~
next prev parent reply other threads:[~2002-11-15 12:44 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20021114143701.A30355@twiddle.net.suse.lists.linux.kernel>
2002-11-15 4:13 ` in-kernel linking issues Andi Kleen
2002-11-15 4:21 ` Richard Henderson
2002-11-15 8:44 ` Rusty Russell
2002-11-15 10:29 ` Andi Kleen
2002-11-15 12:51 ` Richard Henderson [this message]
2002-11-15 13:16 ` Russell King
2002-11-15 22:30 ` Richard Henderson
2002-11-15 21:21 ` Rusty Russell
2002-11-15 22:22 ` Richard Henderson
2002-11-15 22:45 ` Rusty Russell
2002-11-15 23:47 ` Richard Henderson
2002-11-16 6:19 ` Rusty Russell
2002-11-18 16:46 ` Kai Germaschewski
2002-11-19 6:26 ` Rusty Russell
2002-11-14 22:37 Richard Henderson
2002-11-16 5:47 ` Rusty Russell
2002-11-16 22:51 ` Richard Henderson
[not found] ` <20021117130132.AA5352C058@lists.samba.org>
2002-11-17 20:59 ` Richard Henderson
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=20021115045146.A23944@twiddle.net \
--to=rth@twiddle.net \
--cc=linux-kernel@vger.kernel.org \
--cc=rusty@rustcorp.com.au \
/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