aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--Makefile.main10
-rw-r--r--skiboot.lds.S5
3 files changed, 13 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index d4a097f..157eda2 100644
--- a/Makefile
+++ b/Makefile
@@ -44,6 +44,8 @@ STACK_CHECK ?= $(DEBUG)
LITTLE_ENDIAN ?= 0
# ELF v2 ABI is more efficient and compact
ELF_ABI_v2 ?= $(LITTLE_ENDIAN)
+# Discard unreferenced code and data at link-time
+DEAD_CODE_ELIMINATION ?= 0
#
# Where is the source directory, must be a full path (no ~)
diff --git a/Makefile.main b/Makefile.main
index 5656cb7..6a69b65 100644
--- a/Makefile.main
+++ b/Makefile.main
@@ -48,7 +48,7 @@ VALGRIND=valgrind -q --show-reachable=yes --error-exitcode=99
# Target options
-OPTS=-Os -ffunction-sections
+OPTS=-Os
DBG=-g
CPPFLAGS := -I$(SRC)/include -Iinclude -MMD -include $(SRC)/include/config.h
@@ -78,6 +78,10 @@ else
CFLAGS += $(call try-cflag,$(CC),-mabi=elfv1)
endif
+ifeq ($(DEAD_CODE_ELIMINATION),1)
+CFLAGS += -ffunction-sections -fdata-sections
+endif
+
ifeq ($(SKIBOOT_GCOV),1)
CFLAGS += -fprofile-arcs -ftest-coverage -DSKIBOOT_GCOV=1
endif
@@ -112,6 +116,10 @@ LDRFLAGS=-melf64ppc
# Debug stuff
#LDFLAGS += -Wl,-v -Wl,-Map,foomap
+ifeq ($(DEAD_CODE_ELIMINATION),1)
+LDFLAGS += -Wl,--gc-sections
+endif
+
AFLAGS := -D__ASSEMBLY__ -mbig-endian -m64
ifeq ($(ELF_ABI_v2),1)
AFLAGS += $(call try-cflag,$(CC),-mabi=elfv2)
diff --git a/skiboot.lds.S b/skiboot.lds.S
index 7d3d0cf..4a5dabe 100644
--- a/skiboot.lds.S
+++ b/skiboot.lds.S
@@ -85,8 +85,8 @@ SECTIONS
. = ALIGN(0x10);
.init : {
__ctors_start = .;
- *(.ctors)
- *(.init_array)
+ KEEP(*(.ctors))
+ KEEP(*(.init_array))
__ctors_end = .;
}
@@ -143,7 +143,6 @@ SECTIONS
__sym_map_start = . ;
KEEP(*(.sym_map))
__sym_map_end = . ;
- KEEP(*(.sym_map))
}
/* We locate the BSS at 2M to leave room for the symbol map */