Added GCC options for removing unused functions/dead code. I don't have to split out all the functions from their files!
This commit is contained in:
@@ -24,8 +24,8 @@ BACNET_LIB_TARGET = $(BACNET_LIB_DIR)/lib$(BACNET_LIB_NAME).a
|
|||||||
# Compiler Setup
|
# Compiler Setup
|
||||||
INCLUDES = -I$(BACNET_INCLUDE) -I$(BACNET_PORT)
|
INCLUDES = -I$(BACNET_INCLUDE) -I$(BACNET_PORT)
|
||||||
LIBRARIES=-lc,-lgcc,-lm,-L=$(BACNET_LIB_DIR),-l$(BACNET_LIB_NAME)
|
LIBRARIES=-lc,-lgcc,-lm,-L=$(BACNET_LIB_DIR),-l$(BACNET_LIB_NAME)
|
||||||
CFLAGS = -Wall -g $(INCLUDES) $(DEFINES)
|
CFLAGS = -Wall -g $(INCLUDES) $(DEFINES) -fdata-sections -ffunction-sections
|
||||||
LFLAGS = -Wl,-Map=$(TARGET).map,$(LIBRARIES)
|
LFLAGS = -Wl,-Map=$(TARGET).map,$(LIBRARIES),--gc-sections,-static
|
||||||
|
|
||||||
SRCS = main.c
|
SRCS = main.c
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* ****************************************************************************************************** */
|
/* ****************************************************************************************************** */
|
||||||
/* demo_at91sam7_blink_flash.cmd LINKER SCRIPT */
|
/* LINKER SCRIPT */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* The Linker Script defines how the code and data emitted by the GNU C compiler and assembler are */
|
/* The Linker Script defines how the code and data emitted by the GNU C compiler and assembler are */
|
||||||
@@ -8,10 +8,10 @@
|
|||||||
/* Any symbols defined in the Linker Script are automatically global and available to the rest of the */
|
/* Any symbols defined in the Linker Script are automatically global and available to the rest of the */
|
||||||
/* program. */
|
/* program. */
|
||||||
/* */
|
/* */
|
||||||
/* To force the linker to use this LINKER SCRIPT, just add the -T demo_at91sam7_blink_flash.cmd */
|
/* To force the linker to use this LINKER SCRIPT, just add the -T AT91SAM7S256.LD */
|
||||||
/* directive to the linker flags in the makefile. For example, */
|
/* directive to the linker flags in the makefile. For example, */
|
||||||
/* */
|
/* */
|
||||||
/* LFLAGS = -Map main.map -nostartfiles -T demo_at91sam7_blink_flash.cmd */
|
/* LFLAGS = -Map main.map -nostartfiles -T AT91SAM7S256.LD */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* The order that the object files are listed in the makefile determines what .text section is */
|
/* The order that the object files are listed in the makefile determines what .text section is */
|
||||||
@@ -128,7 +128,7 @@ SECTIONS
|
|||||||
|
|
||||||
.text : /* collect all sections that should go into FLASH after startup */
|
.text : /* collect all sections that should go into FLASH after startup */
|
||||||
{
|
{
|
||||||
*(.text) /* all .text sections (code) */
|
*(.text*) /* all .text sections (code) */
|
||||||
*(.rodata) /* all .rodata sections (constants, strings, etc.) */
|
*(.rodata) /* all .rodata sections (constants, strings, etc.) */
|
||||||
*(.rodata*) /* all .rodata* sections (constants, strings, etc.) */
|
*(.rodata*) /* all .rodata* sections (constants, strings, etc.) */
|
||||||
*(.glue_7) /* all .glue_7 sections (no idea what these are) */
|
*(.glue_7) /* all .glue_7 sections (no idea what these are) */
|
||||||
@@ -139,14 +139,14 @@ SECTIONS
|
|||||||
.data : /* collect all initialized .data sections that go into RAM */
|
.data : /* collect all initialized .data sections that go into RAM */
|
||||||
{
|
{
|
||||||
_data = .; /* create a global symbol marking the start of the .data section */
|
_data = .; /* create a global symbol marking the start of the .data section */
|
||||||
*(.data) /* all .data sections */
|
*(.data*) /* all .data sections */
|
||||||
_edata = .; /* define a global symbol marking the end of the .data section */
|
_edata = .; /* define a global symbol marking the end of the .data section */
|
||||||
} >ram AT >flash /* put all the above into RAM (but load the LMA initializer copy into FLASH) */
|
} >ram AT >flash /* put all the above into RAM (but load the LMA initializer copy into FLASH) */
|
||||||
|
|
||||||
.bss : /* collect all uninitialized .bss sections that go into RAM */
|
.bss : /* collect all uninitialized .bss sections that go into RAM */
|
||||||
{
|
{
|
||||||
_bss_start = .; /* define a global symbol marking the start of the .bss section */
|
_bss_start = .; /* define a global symbol marking the start of the .bss section */
|
||||||
*(.bss) /* all .bss sections */
|
*(.bss*) /* all .bss sections */
|
||||||
} >ram /* put all the above in RAM (it will be cleared in the startup code */
|
} >ram /* put all the above in RAM (it will be cleared in the startup code */
|
||||||
|
|
||||||
. = ALIGN(4); /* advance location counter to the next 32-bit boundary */
|
. = ALIGN(4); /* advance location counter to the next 32-bit boundary */
|
||||||
|
|||||||
@@ -27,12 +27,16 @@ INCLUDES += -I$(BACNET_INCLUDE)
|
|||||||
#OPTIMIZATION = -O0
|
#OPTIMIZATION = -O0
|
||||||
OPTIMIZATION = -Os
|
OPTIMIZATION = -Os
|
||||||
CFLAGS = -fno-common $(INCLUDES) $(BACNET_FLAGS) -Wall -g
|
CFLAGS = -fno-common $(INCLUDES) $(BACNET_FLAGS) -Wall -g
|
||||||
|
# dead code removal
|
||||||
|
CFLAGS += -fdata-sections -ffunction-sections
|
||||||
LIBRARY = lib$(TARGET).a
|
LIBRARY = lib$(TARGET).a
|
||||||
# -Wa,<options> Pass comma-separated <options> on to the assembler
|
# -Wa,<options> Pass comma-separated <options> on to the assembler
|
||||||
AFLAGS = -Wa,-ahls,-mapcs-32,-adhlns=$(<:.s=.lst)
|
AFLAGS = -Wa,-ahls,-mapcs-32,-adhlns=$(<:.s=.lst)
|
||||||
# -Wl,<options> Pass comma-separated <options> on to the linker
|
# -Wl,<options> Pass comma-separated <options> on to the linker
|
||||||
LIBRARIES=-lc,-lgcc,-lm,-L=.,-l$(TARGET)
|
LIBRARIES=-lc,-lgcc,-lm,-L=.,-l$(TARGET)
|
||||||
LDFLAGS = -nostartfiles -Wl,-nostdlib,-Map=$(TARGET).map,$(LIBRARIES),-T$(LDSCRIPT)
|
LDFLAGS = -nostartfiles -Wl,-nostdlib,-Map=$(TARGET).map,$(LIBRARIES),-T$(LDSCRIPT)
|
||||||
|
# dead code removal
|
||||||
|
LDFLAGS += -Wl,--gc-sections,-static
|
||||||
CPFLAGS = --output-target=binary
|
CPFLAGS = --output-target=binary
|
||||||
ODFLAGS = -x --syms
|
ODFLAGS = -x --syms
|
||||||
|
|
||||||
|
|||||||
@@ -97,7 +97,9 @@ BFLAGS += -DMAX_TSM_TRANSACTIONS=0
|
|||||||
#BFLAGS += -DCRC_USE_TABLE
|
#BFLAGS += -DCRC_USE_TABLE
|
||||||
BFLAGS += -DTEST_MSTP
|
BFLAGS += -DTEST_MSTP
|
||||||
CFLAGS = $(COMMON)
|
CFLAGS = $(COMMON)
|
||||||
CFLAGS += -Wall -gdwarf-2 $(BFLAGS) $(OPTIMIZATION) -fsigned-char
|
# dead code removal
|
||||||
|
CFLAGS += -ffunction-sections -fdata-sections
|
||||||
|
CFLAGS += -Wall -gdwarf-2 $(BFLAGS) $(OPTIMIZATION) -fsigned-char
|
||||||
CFLAGS += -MD -MP -MT $(*F).o -MF dep/$(@F).d
|
CFLAGS += -MD -MP -MT $(*F).o -MF dep/$(@F).d
|
||||||
|
|
||||||
## Assembly specific flags
|
## Assembly specific flags
|
||||||
@@ -107,6 +109,8 @@ ASMFLAGS += -x assembler-with-cpp -Wa,-gdwarf2
|
|||||||
|
|
||||||
## Linker flags
|
## Linker flags
|
||||||
LDFLAGS = $(COMMON)
|
LDFLAGS = $(COMMON)
|
||||||
|
#dead code removal
|
||||||
|
LDFLAGS += -Wl,--gc-sections,-static
|
||||||
LDFLAGS += -Wl,-Map=$(TARGET).map,-L=.,-l$(TARGET)
|
LDFLAGS += -Wl,-Map=$(TARGET).map,-L=.,-l$(TARGET)
|
||||||
#LDFLAGS += -Wl,-Map=$(TARGET).map
|
#LDFLAGS += -Wl,-Map=$(TARGET).map
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user