CFLAGS += -finstrument-functions-exclude-file-list=core/fnrec.c
endif
+# Enable per-item sections and section garbage collection. Note that
+# some older versions of gcc support -fdata-sections but treat it as
+# implying -fno-common, which would break our build.
+#
+ifeq ($(CCTYPE),gcc)
+DS_TEST = $(ECHO) 'char x;' | \
+ $(CC) -fdata-sections -S -x c - -o - 2>/dev/null | \
+ grep -E '\.comm' > /dev/null
+DS_FLAGS := $(shell $(DS_TEST) && $(ECHO) '-fdata-sections')
+CFLAGS += -ffunction-sections $(DS_FLAGS)
+endif
+LDFLAGS += --gc-sections
+
# compiler.h is needed for our linking and debugging system
#
CFLAGS += -include compiler.h
.text16 : AT ( _text16_load_offset + __text16 ) {
__text16 = .;
- *(.text.null_trap)
+ KEEP(*(.text.null_trap))
+ KEEP(*(.text.null_trap.*))
*(.text16)
*(.text16.*)
*(.text)
*(.data16.*)
*(.data)
*(.data.*)
- *(SORT(.tbl.*)) /* Various tables. See include/tables.h */
+ KEEP(*(SORT(.tbl.*))) /* Various tables. See include/tables.h */
_edata16_progbits = .;
}
.bss16 : AT ( _data16_load_offset + __bss16 ) {
/DISCARD/ : {
*(.comment)
+ *(.comment.*)
*(.note)
+ *(.note.*)
*(.discard)
+ *(.discard.*)
}
/*
.text16.early 0x0 : AT ( _text16_early_lma ) {
_text16 = .;
- *(.text16.null)
+ KEEP(*(.text16.null))
+ KEEP(*(.text16.null.*))
. += 1; /* Prevent NULL being valid */
*(.text16.early)
*(.text16.early.*)
.textdata 0x0 : AT ( _textdata_lma ) {
_textdata = .;
- *(.text.null_trap)
+ KEEP(*(.text.null_trap))
+ KEEP(*(.text.null_trap.*))
. += 1; /* Prevent NULL being valid */
*(.text)
*(.text.*)
*(.rodata.*)
*(.data)
*(.data.*)
- *(SORT(.tbl.*)) /* Various tables. See include/tables.h */
+ KEEP(*(SORT(.tbl.*))) /* Various tables. See include/tables.h */
_mtextdata = .;
} .bss.textdata (NOLOAD) : AT ( _end_lma ) {
*(.bss)
.zinfo 0x0 : AT ( _zinfo_lma ) {
_zinfo = .;
- *(.zinfo)
- *(.zinfo.*)
+ KEEP(*(.zinfo))
+ KEEP(*(.zinfo.*))
_mzinfo = .;
} .bss.zinfo (NOLOAD) : AT ( _end_lma ) {
_ezinfo = .;
.weak 0x0 : AT ( _end_lma ) {
_weak = .;
*(.weak)
+ *(.weak.*)
_eweak = .;
}
_assert = ASSERT ( ( _weak == _eweak ), ".weak is non-zero length" );
*(.einfo)
*(.einfo.*)
*(.discard)
+ *(.discard.*)
}
/*
_data = .;
*(.data)
*(.data.*)
- *(SORT(.tbl.*)) /* Various tables. See include/tables.h */
+ KEEP(*(SORT(.tbl.*)))
_edata = .;
}
.weak 0x0 : {
_weak = .;
*(.weak)
+ *(.weak.*)
_eweak = .;
}
_assert = ASSERT ( ( _weak == _eweak ), ".weak is non-zero length" );
*(.rel)
*(.rel.*)
*(.discard)
+ *(.discard.*)
}
}
_data = .;
*(.data)
*(.data.*)
- *(SORT(.tbl.*)) /* Various tables. See include/tables.h */
+ KEEP(*(SORT(.tbl.*))) /* Various tables. See include/tables.h */
_edata = .;
}
.weak 0x0 : {
_weak = .;
*(.weak)
+ *(.weak.*)
_eweak = .;
}
_assert = ASSERT ( ( _weak == _eweak ), ".weak is non-zero length" );
*(.einfo)
*(.einfo.*)
*(.discard)
+ *(.discard.*)
}
}
_data = .;
*(.data)
*(.data.*)
- *(SORT(.tbl.*)) /* Various tables. See include/tables.h */
+ KEEP(*(SORT(.tbl.*)))
_edata = .;
}
.weak 0x0 : {
_weak = .;
*(.weak)
+ *(.weak.*)
_eweak = .;
}
_assert = ASSERT ( ( _weak == _eweak ), ".weak is non-zero length" );
*(.rel)
*(.rel.*)
*(.discard)
+ *(.discard.*)
}
}