From: ebiederm@xmission.com (Eric W. Biederman)
To: "H. Peter Anvin" <hpa@zytor.com>
Cc: Tejun Heo <tj@kernel.org>, hacklu <embedway.linux@gmail.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH 2/4] x86 boot: Optimize the elf header handling.
Date: Sun, 08 Jul 2012 23:53:15 -0700 [thread overview]
Message-ID: <87bojp5stg.fsf_-_@xmission.com> (raw)
In-Reply-To: <87fw915sv4.fsf_-_@xmission.com> (Eric W. Biederman's message of "Sun, 08 Jul 2012 23:52:15 -0700")
Create a space for the elf headers at the begginng of the kernels
image in memory.
- Rework arch/x86/kernel/vmlinux.lds.S so that we allow room for
the ELF header in the loaded image. This removes the need in
the ELF executalbe to insert padding between the ELf headers
and the data of the first program segment. This reduces the
size of vmlinux by 2MB on x86_64. This removes an overlap
of the ELF header and kernel text in arch/x86/boot/compressed
that required code to moved.
- Move the symbol _text outside of the .text section, and add the
fixups in relocs.c to add relocations against _text. This allows
the symbol _text to come before the ELF header and effectively
including the ELF header in the text section.
If this isn't done _text moves 344 bytes in memory on x86_64 and
creates subtle breakage in routines like cleanup_highmap, which
assume _text is at the beginning of the kernels memory and that
_text is 4K+ aligned.
The current usage of the symbol _text is already that _text
specifies the beginning of the kernel's memory and that _stext
specifies where the kernel's code actually starts.
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
---
arch/x86/kernel/vmlinux.lds.S | 9 +++++----
arch/x86/tools/relocs.c | 1 +
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
index 22a1530..d6e1a44 100644
--- a/arch/x86/kernel/vmlinux.lds.S
+++ b/arch/x86/kernel/vmlinux.lds.S
@@ -68,7 +68,7 @@ jiffies_64 = jiffies;
#endif
PHDRS {
- text PT_LOAD FLAGS(5); /* R_E */
+ text PT_LOAD FLAGS(5) FILEHDR; /* R_E */
data PT_LOAD FLAGS(6); /* RW_ */
#ifdef CONFIG_X86_64
#ifdef CONFIG_SMP
@@ -82,16 +82,17 @@ PHDRS {
SECTIONS
{
#ifdef CONFIG_X86_32
- . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
+ _text = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
+ . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR + SIZEOF_HEADERS;
phys_startup_32 = startup_32 - LOAD_OFFSET;
#else
- . = __START_KERNEL;
+ _text = __START_KERNEL;
+ . = __START_KERNEL + SIZEOF_HEADERS;
phys_startup_64 = startup_64 - LOAD_OFFSET;
#endif
/* Text and read-only data */
.text : AT(ADDR(.text) - LOAD_OFFSET) {
- _text = .;
/* bootstrapping code */
HEAD_TEXT
#ifdef CONFIG_X86_32
diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
index 5a1847d..6f32b7b 100644
--- a/arch/x86/tools/relocs.c
+++ b/arch/x86/tools/relocs.c
@@ -72,6 +72,7 @@ static const char * const sym_regex_kernel[S_NSYMTYPES] = {
"__end_rodata|"
"__initramfs_start|"
"(jiffies|jiffies_64)|"
+ "_text|"
"_end)$"
};
--
1.7.5.4
next prev parent reply other threads:[~2012-07-09 6:53 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-17 5:56 why the decompressed procedure move kernel from address 0x100000(1M) to 0x1000000(16M) +x hacklu
2012-06-02 23:48 ` Eric W. Biederman
2012-06-03 3:10 ` H. Peter Anvin
2012-06-03 8:41 ` Eric W. Biederman
2012-06-03 13:01 ` H. Peter Anvin
2012-06-03 20:30 ` [PATCH 1/2] x86, boot: Don't overlap the compressed and non-compressed image Eric W. Biederman
2012-06-03 20:32 ` [PATCH 2/2] x86, boot: Optimize the elf header handling Eric W. Biederman
2012-07-01 14:56 ` [tip:x86/boot] " tip-bot for Eric W. Biederman
2012-07-01 15:04 ` [PATCH 2/2] " H. Peter Anvin
2012-07-01 15:34 ` H. Peter Anvin
2012-07-01 16:08 ` Eric W. Biederman
2012-07-01 16:11 ` H. Peter Anvin
2012-07-01 16:26 ` Eric W. Biederman
2012-07-01 16:44 ` H. Peter Anvin
2012-07-01 17:09 ` Eric W. Biederman
2012-07-01 17:15 ` H. Peter Anvin
2012-07-01 18:25 ` Eric W. Biederman
2012-07-01 18:37 ` H. Peter Anvin
2012-07-01 19:20 ` Eric W. Biederman
2012-07-01 19:23 ` H. Peter Anvin
2012-07-01 20:40 ` Eric W. Biederman
2012-07-01 20:52 ` H. Peter Anvin
2012-07-09 6:50 ` Eric W. Biederman
2012-07-09 6:52 ` [PATCH 1/4] x86 boot: Jump to the entry point address in the elf header Eric W. Biederman
2012-07-09 6:53 ` Eric W. Biederman [this message]
2012-07-09 6:55 ` [PATCH 3/4] x86 boot: When building vmlinux.bin properly precompute the memory image Eric W. Biederman
2012-07-09 6:56 ` [PATCH 4/4] x86 boot: Tell ld the kernel doesn't want 2MB file offset alignment Eric W. Biederman
2012-07-09 6:59 ` [PATCH 1/4] x86 boot: Jump to the entry point address in the elf header Eric W. Biederman
2012-07-02 16:56 ` [PATCH 2/2] x86, boot: Optimize the elf header handling Tejun Heo
2012-07-09 7:03 ` Eric W. Biederman
2012-07-01 2:23 ` [PATCH 1/2] x86, boot: Don't overlap the compressed and non-compressed image Eric W. Biederman
2012-07-01 2:32 ` H. Peter Anvin
2012-07-01 5:22 ` Eric W. Biederman
2012-07-01 14:55 ` [tip:x86/boot] x86, boot: Don' t " tip-bot for Eric W. Biederman
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=87bojp5stg.fsf_-_@xmission.com \
--to=ebiederm@xmission.com \
--cc=embedway.linux@gmail.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=tj@kernel.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).