linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Kumar Gala <galak@kernel.crashing.org>
To: paulus@samba.org
Cc: linuxppc-dev@ozlabs.org
Subject: [PATCH 10/12] [POWERPC] Update linker script to properly set physical addresses
Date: Thu, 10 Apr 2008 05:48:49 -0500	[thread overview]
Message-ID: <1207824531-27168-11-git-send-email-galak@kernel.crashing.org> (raw)
In-Reply-To: <1207824531-27168-10-git-send-email-galak@kernel.crashing.org>

We can set LOAD_OFFSET and use the AT attribute on sections and the
linker will properly set the physical address of the LOAD program
header for us.

This allows us to know how the PHYSICAL_START the user configured a
kernel with by just looking at the resulting vmlinux ELF.

This is pretty much stolen from how x86 does things in their linker
scripts.

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
---
 arch/powerpc/kernel/vmlinux.lds.S |   47 ++++++++++++++++++-------------------
 include/asm-powerpc/page.h        |    1 +
 2 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
index b5a76bc..0c3000b 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -31,7 +31,7 @@ SECTIONS
  */
 
 	/* Text and gots */
-	.text : {
+	.text : AT(ADDR(.text) - LOAD_OFFSET) {
 		ALIGN_FUNCTION();
 		*(.text.head)
 		_text = .;
@@ -56,7 +56,7 @@ SECTIONS
 	RODATA
 
 	/* Exception & bug tables */
-	__ex_table : {
+	__ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
 		__start___ex_table = .;
 		*(__ex_table)
 		__stop___ex_table = .;
@@ -72,7 +72,7 @@ SECTIONS
 	. = ALIGN(PAGE_SIZE);
 	__init_begin = .;
 
-	.init.text : {
+	.init.text : AT(ADDR(.init.text) - LOAD_OFFSET) {
 		_sinittext = .;
 		INIT_TEXT
 		_einittext = .;
@@ -81,11 +81,11 @@ SECTIONS
 	/* .exit.text is discarded at runtime, not link time,
 	 * to deal with references from __bug_table
 	 */
-	.exit.text : {
+	.exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
 		EXIT_TEXT
 	}
 
-	.init.data : {
+	.init.data : AT(ADDR(.init.data) - LOAD_OFFSET) {
 		INIT_DATA
 		__vtop_table_begin = .;
 		*(.vtop_fixup);
@@ -101,19 +101,19 @@ SECTIONS
 	}
 
 	. = ALIGN(16);
-	.init.setup : {
+	.init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) {
 		__setup_start = .;
 		*(.init.setup)
 		__setup_end = .;
 	}
 
-	.initcall.init : {
+	.initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) {
 		__initcall_start = .;
 		INITCALLS
 		__initcall_end = .;
 		}
 
-	.con_initcall.init : {
+	.con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) {
 		__con_initcall_start = .;
 		*(.con_initcall.init)
 		__con_initcall_end = .;
@@ -122,14 +122,14 @@ SECTIONS
 	SECURITY_INIT
 
 	. = ALIGN(8);
-	__ftr_fixup : {
+	__ftr_fixup : AT(ADDR(__ftr_fixup) - LOAD_OFFSET) {
 		__start___ftr_fixup = .;
 		*(__ftr_fixup)
 		__stop___ftr_fixup = .;
 	}
 #ifdef CONFIG_PPC64
 	. = ALIGN(8);
-	__fw_ftr_fixup : {
+	__fw_ftr_fixup : AT(ADDR(__fw_ftr_fixup) - LOAD_OFFSET) {
 		__start___fw_ftr_fixup = .;
 		*(__fw_ftr_fixup)
 		__stop___fw_ftr_fixup = .;
@@ -137,14 +137,14 @@ SECTIONS
 #endif
 #ifdef CONFIG_BLK_DEV_INITRD
 	. = ALIGN(PAGE_SIZE);
-	.init.ramfs : {
+	.init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) {
 		__initramfs_start = .;
 		*(.init.ramfs)
 		__initramfs_end = .;
 	}
 #endif
 	. = ALIGN(PAGE_SIZE);
-	.data.percpu : {
+	.data.percpu  : AT(ADDR(.data.percpu) - LOAD_OFFSET) {
 		__per_cpu_start = .;
 		*(.data.percpu)
 		*(.data.percpu.shared_aligned)
@@ -152,7 +152,7 @@ SECTIONS
 	}
 
 	. = ALIGN(8);
-	.machine.desc : {
+	.machine.desc : AT(ADDR(.machine.desc) - LOAD_OFFSET) {
 		__machine_desc_start = . ;
 		*(.machine.desc)
 		__machine_desc_end = . ;
@@ -170,25 +170,24 @@ SECTIONS
 	_sdata = .;
 
 #ifdef CONFIG_PPC32
-	.data    :
-	{
+	.data : AT(ADDR(.data) - LOAD_OFFSET) {
 		DATA_DATA
 		*(.sdata)
 		*(.got.plt) *(.got)
 	}
 #else
-	.data : {
+	.data : AT(ADDR(.data) - LOAD_OFFSET) {
 		DATA_DATA
 		*(.data.rel*)
 		*(.toc1)
 		*(.branch_lt)
 	}
 
-	.opd : {
+	.opd : AT(ADDR(.opd) - LOAD_OFFSET) {
 		*(.opd)
 	}
 
-	.got : {
+	.got : AT(ADDR(.got) - LOAD_OFFSET) {
 		__toc_start = .;
 		*(.got)
 		*(.toc)
@@ -205,26 +204,26 @@ SECTIONS
 #else
 	. = ALIGN(16384);
 #endif
-	.data.init_task : {
+	.data.init_task : AT(ADDR(.data.init_task) - LOAD_OFFSET) {
 		*(.data.init_task)
 	}
 
 	. = ALIGN(PAGE_SIZE);
-	.data.page_aligned : {
+	.data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) {
 		*(.data.page_aligned)
 	}
 
-	.data.cacheline_aligned : {
+	.data.cacheline_aligned : AT(ADDR(.data.cacheline_aligned) - LOAD_OFFSET) {
 		*(.data.cacheline_aligned)
 	}
 
 	. = ALIGN(L1_CACHE_BYTES);
-	.data.read_mostly : {
+	.data.read_mostly : AT(ADDR(.data.read_mostly) - LOAD_OFFSET) {
 		*(.data.read_mostly)
 	}
 
 	. = ALIGN(PAGE_SIZE);
-	__data_nosave : {
+	.data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
 		__nosave_begin = .;
 		*(.data.nosave)
 		. = ALIGN(PAGE_SIZE);
@@ -235,7 +234,7 @@ SECTIONS
  * And finally the bss
  */
 
-	.bss : {
+	.bss : AT(ADDR(.bss) - LOAD_OFFSET) {
 		__bss_start = .;
 		*(.sbss) *(.scommon)
 		*(.dynbss)
diff --git a/include/asm-powerpc/page.h b/include/asm-powerpc/page.h
index df47bbb..6c85060 100644
--- a/include/asm-powerpc/page.h
+++ b/include/asm-powerpc/page.h
@@ -53,6 +53,7 @@
 
 #define PAGE_OFFSET     ASM_CONST(CONFIG_KERNEL_START)
 #define KERNELBASE      (PAGE_OFFSET + PHYSICAL_START)
+#define LOAD_OFFSET	PAGE_OFFSET
 
 #ifdef CONFIG_FLATMEM
 #define pfn_valid(pfn)		((pfn) < max_mapnr)
-- 
1.5.4.1

  reply	other threads:[~2008-04-10 10:53 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-10 10:48 [PATCH 00/12 v3] [POWERPC] ppc32 mm init clean and 85xx kernel reloc Kumar Gala
2008-04-10 10:48 ` [PATCH 01/12] [POWERPC] Remove Kconfig option BOOT_LOAD Kumar Gala
2008-04-10 10:48   ` [PATCH 02/12] [POWERPC] Provide access to arch/powerpc include path on ppc64 Kumar Gala
2008-04-10 10:48     ` [PATCH 03/12] [POWERPC] Remove and replace uses of PPC_MEMSTART with memstart_addr Kumar Gala
2008-04-10 10:48       ` [PATCH 04/12] [POWERPC] Introduce lowmem_end_addr to distiguish from total_lowmem Kumar Gala
2008-04-10 10:48         ` [PATCH 05/12] [POWERPC] 85xx: Cleanup TLB initialization Kumar Gala
2008-04-10 10:48           ` [PATCH 06/12] [POWERPC] Use lowmem_end_addr to limit lmb allocations on ppc32 Kumar Gala
2008-04-10 10:48             ` [PATCH 07/12] [POWERPC] Rename __initial_memory_limit to __initial_memory_limit_addr Kumar Gala
2008-04-10 10:48               ` [PATCH 08/12] [POWERPC] Clean up some linker and symbol usage Kumar Gala
2008-04-10 10:48                 ` [PATCH 09/12] [POWERPC] Move phys_addr_t definition into asm/types.h Kumar Gala
2008-04-10 10:48                   ` Kumar Gala [this message]
2008-04-10 10:48                     ` [PATCH 11/12] [POWERPC] bootwrapper: use physical address in PHDR for uImage Kumar Gala
2008-04-10 10:48                       ` [PATCH 12/12] [POWERPC] 85xx: Add support for relocatble kernel (and booting at non-zero) Kumar Gala
2008-04-15 10:57                         ` Paul Mackerras
2008-04-15 15:24                           ` Kumar Gala
2008-04-15 22:53                           ` Kumar Gala
2008-04-16  0:03                             ` Paul Mackerras
2008-04-16  0:50                               ` Kumar Gala
2008-04-15 10:12                   ` [PATCH 09/12] [POWERPC] Move phys_addr_t definition into asm/types.h Paul Mackerras
2008-04-15 14:51                     ` Kumar Gala
2008-04-15  7:34       ` [PATCH 03/12] [POWERPC] Remove and replace uses of PPC_MEMSTART with memstart_addr Paul Mackerras
2008-04-15 14:35         ` Kumar Gala
2008-04-15 14:51           ` Kumar Gala

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=1207824531-27168-11-git-send-email-galak@kernel.crashing.org \
    --to=galak@kernel.crashing.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=paulus@samba.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).