diff --git a/src/arch/arm/Makefile.inc b/src/arch/arm/Makefile.inc index a1f0b1168a..9410b6e28a 100644 --- a/src/arch/arm/Makefile.inc +++ b/src/arch/arm/Makefile.inc @@ -82,7 +82,7 @@ ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/mainboard.c ################################################################################ # Common recipes for all stages -CFLAGS += -mno-unaligned-access +CFLAGS += -mno-unaligned-access -ffunction-sections -fdata-sections $(objcbfs)/%.bin: $(objcbfs)/%.elf @printf " OBJCOPY $(subst $(obj)/,,$(@))\n" @@ -160,9 +160,9 @@ endif $(objcbfs)/bootblock.debug: $(src)/arch/arm/bootblock.ld $(obj)/ldoptions $$(bootblock-objs) $(obj)/config.h @printf " LINK $(subst $(obj)/,,$(@))\n" ifeq ($(CONFIG_COMPILER_LLVM_CLANG),y) - $(LD) -m armelf_linux_eabi -static -o $@ -L$(obj) $< -T $(src)/arch/arm/bootblock.ld + $(LD) -m armelf_linux_eabi --gc-sections -static -o $@ -L$(obj) $< -T $(src)/arch/arm/bootblock.ld else - $(CC) $(CFLAGS) -nostartfiles -static -o $@ -L$(obj) -T $(src)/arch/arm/bootblock.ld -Wl,--start-group $(bootblock-objs) -Wl,--end-group + $(CC) $(CFLAGS) -nostartfiles -Wl,--gc-sections -static -o $@ -L$(obj) -T $(src)/arch/arm/bootblock.ld -Wl,--start-group $(bootblock-objs) -Wl,--end-group endif ################################################################################ @@ -171,9 +171,9 @@ endif $(objcbfs)/romstage.debug: $$(romstage-objs) $(src)/arch/arm/romstage.ld $(obj)/ldoptions @printf " LINK $(subst $(obj)/,,$(@))\n" ifeq ($(CONFIG_COMPILER_LLVM_CLANG),y) - $(LD) -nostdlib -nostartfiles -static -o $@ -L$(obj) $(romstage-objs) -T $(src)/arch/arm/romstage.ld + $(LD) -nostdlib -nostartfiles --gc-sections -static -o $@ -L$(obj) $(romstage-objs) -T $(src)/arch/arm/romstage.ld else - $(CC) $(CFLAGS) -nostartfiles -static -o $@ -L$(obj) -T $(src)/arch/arm/romstage.ld -Wl,--start-group $(romstage-objs) -Wl,--end-group + $(CC) $(CFLAGS) -nostartfiles -Wl,--gc-sections -static -o $@ -L$(obj) -T $(src)/arch/arm/romstage.ld -Wl,--start-group $(romstage-objs) -Wl,--end-group endif ################################################################################ @@ -182,9 +182,9 @@ endif $(objcbfs)/coreboot_ram.debug: $$(ramstage-objs) $(src)/arch/arm/coreboot_ram.ld $(obj)/ldoptions @printf " CC $(subst $(obj)/,,$(@))\n" ifeq ($(CONFIG_COMPILER_LLVM_CLANG),y) - $(LD) -m -m armelf_linux_eabi -o $@ --wrap __divdi3 --wrap __udivdi3 --wrap __moddi3 --wrap __umoddi3 --wrap __uidiv --start-group $(ramstage-objs) --end-group -T $(src)/arch/arm/coreboot_ram.ld + $(LD) -m -m armelf_linux_eabi --gc-sections -o $@ --wrap __divdi3 --wrap __udivdi3 --wrap __moddi3 --wrap __umoddi3 --wrap __uidiv --start-group $(ramstage-objs) --end-group -T $(src)/arch/arm/coreboot_ram.ld else - $(CC) $(CFLAGS) -nostartfiles -static -o $@ -L$(obj) -Wl,--start-group $(ramstage-objs) -Wl,--end-group -T $(src)/arch/arm/coreboot_ram.ld + $(CC) $(CFLAGS) -nostartfiles -Wl,--gc-sections -static -o $@ -L$(obj) -Wl,--start-group $(ramstage-objs) -Wl,--end-group -T $(src)/arch/arm/coreboot_ram.ld endif ################################################################################ diff --git a/src/arch/arm/bootblock.ld b/src/arch/arm/bootblock.ld index 3210733200..9fc330b716 100644 --- a/src/arch/arm/bootblock.ld +++ b/src/arch/arm/bootblock.ld @@ -23,23 +23,25 @@ OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") OUTPUT_ARCH(arm) INCLUDE ldoptions +ENTRY(_start) TARGET(binary) SECTIONS { - ROMLOC = CONFIG_BOOTBLOCK_BASE; + . = CONFIG_BOOTBLOCK_BASE; - /* This section might be better named .setup */ - .rom ROMLOC : { - _rom = .; + .bootblock . : { *(.start); - *(.id); + KEEP(*(.id)); *(.text); *(.text.*); - *(.rom.text); - *(.rom.data); - *(.rom.data.*); + *(.rodata); *(.rodata.*); - _erom = .; + *(.data); + *(.data.*); + *(.bss); + *(.bss.*); + *(.sbss); + *(.sbss.*); } = 0xff /DISCARD/ : { diff --git a/src/arch/arm/coreboot_ram.ld b/src/arch/arm/coreboot_ram.ld index ea6bc7937a..d7a6269f6a 100644 --- a/src/arch/arm/coreboot_ram.ld +++ b/src/arch/arm/coreboot_ram.ld @@ -43,7 +43,7 @@ SECTIONS .ctors : { . = ALIGN(0x100); __CTOR_LIST__ = .; - *(.ctors); + KEEP(*(.ctors)); LONG(0); __CTOR_END__ = .; } @@ -52,17 +52,17 @@ SECTIONS _rodata = .; . = ALIGN(4); console_drivers = .; - *(.rodata.console_drivers) + KEEP(*(.rodata.console_drivers)); econsole_drivers = . ; . = ALIGN(4); pci_drivers = . ; - *(.rodata.pci_driver) + KEEP(*(.rodata.pci_driver)); epci_drivers = . ; cpu_drivers = . ; - *(.rodata.cpu_driver) + KEEP(*(.rodata.cpu_driver)); ecpu_drivers = . ; _bs_init_begin = .; - *(.bs_init) + KEEP(*(.bs_init)); _bs_init_end = .; *(.rodata) *(.rodata.*) @@ -82,6 +82,7 @@ SECTIONS .data : { _data = .; *(.data) + *(.data.*) _edata = .; } @@ -89,26 +90,27 @@ SECTIONS * initialized on startup. (typically uninitialized global variables) * crt0.S fills between _bss and _ebss with zeroes. */ - _bss = .; .bss . : { + _bss = .; *(.bss) + *(.bss.*) *(.sbss) - *(COMMON) + *(.sbss.*) + _ebss = .; } - _ebss = .; _end = .; /* coreboot really "ends" here. Only heap and stack are placed after * this line. */ - _heap = .; .heap . : { + _heap = .; /* Reserve CONFIG_HEAP_SIZE bytes for the heap */ . = CONFIG_HEAP_SIZE ; . = ALIGN(4); + _eheap = .; } - _eheap = .; /* The ram segment. This includes all memory used by the memory * resident copy of coreboot, except the tables that are produced on diff --git a/src/arch/arm/romstage.ld b/src/arch/arm/romstage.ld index d5d9ddecdd..e1b09c032e 100644 --- a/src/arch/arm/romstage.ld +++ b/src/arch/arm/romstage.ld @@ -36,19 +36,19 @@ SECTIONS . = CONFIG_ROMSTAGE_BASE; .romtext . : { - _rom = .; _start = .; *(.text.stage_entry.arm); *(.text.startup); *(.text); + *(.text.*); } .romdata . : { *(.rodata); - *(.machine_param); + *(.rodata.*); *(.data); + *(.data.*); . = ALIGN(8); - _erom = .; } /* bss does not contain data, it is just a space that should be zero @@ -59,12 +59,12 @@ SECTIONS . = ALIGN(8); _bss = .; *(.bss) + *(.bss.*) *(.sbss) - *(COMMON) + *(.sbss.*) + _ebss = .; } - _ebss = .; - _end = .; /* Discard the sections we don't need/want */