diff options
author | Travis Geiselbrecht <geist@foobox.com> | 2013-06-20 21:03:56 -0700 |
---|---|---|
committer | Travis Geiselbrecht <geist@foobox.com> | 2013-06-20 21:03:56 -0700 |
commit | 28bc7f4b6d432352715eee09a3229797318961dd (patch) | |
tree | 2874727d7b49e60fced91d38dfcc1968e41f4d1e | |
parent | 702d16892778d776a593a99ef60a5c607685d39b (diff) | |
download | lk-28bc7f4b6d432352715eee09a3229797318961dd.tar.gz |
[arch] factor some common parts of linker scripts into a separate file
INCLUDE the parts of the linker script that are specific to lk into
each of the arch's scripts.
-rw-r--r-- | arch/arm/rules.mk | 4 | ||||
-rw-r--r-- | arch/arm/system-onesegment.ld | 18 | ||||
-rw-r--r-- | arch/arm/system-twosegment.ld | 18 | ||||
-rw-r--r-- | arch/shared_data_sections.ld | 14 | ||||
-rw-r--r-- | arch/shared_rodata_sections.ld | 5 | ||||
-rw-r--r-- | arch/x86/kernel.ld | 21 | ||||
-rw-r--r-- | arch/x86/rules.mk | 2 |
7 files changed, 31 insertions, 51 deletions
diff --git a/arch/arm/rules.mk b/arch/arm/rules.mk index d6865b3d..6fbd8b94 100644 --- a/arch/arm/rules.mk +++ b/arch/arm/rules.mk @@ -230,12 +230,12 @@ GENERATED += \ # rules for generating the linker scripts -$(BUILDDIR)/system-onesegment.ld: $(LOCAL_DIR)/system-onesegment.ld +$(BUILDDIR)/system-onesegment.ld: $(LOCAL_DIR)/system-onesegment.ld $(wildcard arch/*.ld) @echo generating $@ @$(MKDIR) $(NOECHO)sed "s/%MEMBASE%/$(MEMBASE)/;s/%MEMSIZE%/$(MEMSIZE)/" < $< > $@ -$(BUILDDIR)/system-twosegment.ld: $(LOCAL_DIR)/system-twosegment.ld +$(BUILDDIR)/system-twosegment.ld: $(LOCAL_DIR)/system-twosegment.ld $(wildcard arch/*.ld) @echo generating $@ @$(MKDIR) $(NOECHO)sed "s/%ROMBASE%/$(ROMBASE)/;s/%MEMBASE%/$(MEMBASE)/;s/%MEMSIZE%/$(MEMSIZE)/" < $< > $@ diff --git a/arch/arm/system-onesegment.ld b/arch/arm/system-onesegment.ld index bf297030..e88b6f52 100644 --- a/arch/arm/system-onesegment.ld +++ b/arch/arm/system-onesegment.ld @@ -49,10 +49,7 @@ SECTIONS .rodata : ALIGN(4) { __rodata_start = .; *(.rodata .rodata.* .gnu.linkonce.r.*) - . = ALIGN(4); - __drivers = .; - KEEP(*(.drivers)) - __drivers_end = .; +INCLUDE "arch/shared_rodata_sections.ld" . = ALIGN(4); __rodata_end = .; } @@ -64,18 +61,7 @@ SECTIONS /* in one segment binaries, the rom data address is on top of the ram data address */ __data_start = .; *(.data .data.* .gnu.linkonce.d.*) - . = ALIGN(4); - __commands_start = .; - KEEP (*(.commands)) - __commands_end = .; - . = ALIGN(4); - __apps_start = .; - KEEP (*(.apps)) - __apps_end = .; - . = ALIGN(4); - __devices = .; - KEEP(*(.devices)) - __devices_end = .; +INCLUDE "arch/shared_data_sections.ld" } .ctors : ALIGN(4) { diff --git a/arch/arm/system-twosegment.ld b/arch/arm/system-twosegment.ld index c197858f..6dd99e5d 100644 --- a/arch/arm/system-twosegment.ld +++ b/arch/arm/system-twosegment.ld @@ -49,10 +49,7 @@ SECTIONS .rodata : ALIGN(4) { __rodata_start = .; *(.rodata .rodata.* .gnu.linkonce.r.*) - . = ALIGN(4); - __drivers = .; - KEEP(*(.drivers)) - __drivers_end = .; +INCLUDE "arch/shared_rodata_sections.ld" . = ALIGN(4); __rodata_end = . ; } @@ -66,18 +63,7 @@ SECTIONS .data : AT ( ADDR (.rodata) + SIZEOF (.rodata) ) ALIGN(4) { *(.data .data.* .gnu.linkonce.d.*) - . = ALIGN(4); - __commands_start = .; - KEEP (*(.commands)) - __commands_end = .; - . = ALIGN(4); - __apps_start = .; - KEEP (*(.apps)) - __apps_end = .; - . = ALIGN(4); - __devices = .; - KEEP(*(.devices)) - __devices_end = .; +INCLUDE "arch/shared_data_sections.ld" } /* code that is located in ram */ diff --git a/arch/shared_data_sections.ld b/arch/shared_data_sections.ld new file mode 100644 index 00000000..765d1c21 --- /dev/null +++ b/arch/shared_data_sections.ld @@ -0,0 +1,14 @@ +/* should be included in all lk linker scripts in the .data segment */ +. = ALIGN(4); +__commands_start = .; +KEEP (*(.commands)) +__commands_end = .; +. = ALIGN(4); +__apps_start = .; +KEEP (*(.apps)) +__apps_end = .; +. = ALIGN(4); +__devices = .; +KEEP(*(.devices)) +__devices_end = .; + diff --git a/arch/shared_rodata_sections.ld b/arch/shared_rodata_sections.ld new file mode 100644 index 00000000..2146fb20 --- /dev/null +++ b/arch/shared_rodata_sections.ld @@ -0,0 +1,5 @@ +/* should be included in all lk linker scripts in the .rodata segment */ +. = ALIGN(4); +__drivers = .; +KEEP(*(.drivers)) +__drivers_end = .; diff --git a/arch/x86/kernel.ld b/arch/x86/kernel.ld index 3657c7a8..5934b94b 100644 --- a/arch/x86/kernel.ld +++ b/arch/x86/kernel.ld @@ -31,30 +31,19 @@ SECTIONS *(.gnu.linkonce.t.*) } =0x9090 - .rodata : { + .rodata : ALIGN(4) { + __rodata_start = .; *(.rodata*) *(.gnu.linkonce.r.*) +INCLUDE "arch/shared_rodata_sections.ld" . = ALIGN(4); - __drivers = .; - KEEP(*(.drivers)) - __drivers_end = .; + __rodata_end = .; } .data : ALIGN(4096) { __data_start = .; *(.data .data.* .gnu.linkonce.d.*) - . = ALIGN(4); - __commands_start = .; - KEEP (*(.commands)) - __commands_end = .; - . = ALIGN(4); - __apps_start = .; - KEEP (*(.apps)) - __apps_end = .; - . = ALIGN(4); - __devices = .; - KEEP(*(.devices)) - __devices_end = .; +INCLUDE "arch/shared_data_sections.ld" } __ctor_list = .; .ctors : { *(.ctors) } diff --git a/arch/x86/rules.mk b/arch/x86/rules.mk index c2a27d9a..545bc35b 100644 --- a/arch/x86/rules.mk +++ b/arch/x86/rules.mk @@ -38,7 +38,7 @@ GENERATED += \ # rules for generating the linker scripts -$(BUILDDIR)/kernel.ld: $(LOCAL_DIR)/kernel.ld +$(BUILDDIR)/kernel.ld: $(LOCAL_DIR)/kernel.ld $(wildcard arch/*.ld) @echo generating $@ @$(MKDIR) $(NOECHO)cp $< $@ |