Skip to content

Commit 7b9081b

Browse files
author
Bogdan Marinescu
committed
Add support for calling a function before main()
Also added a test for this feature (MBED_A22). Fixes PRMBED-906.
1 parent ad5516f commit 7b9081b

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

workspace_tools/tests.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,12 @@
203203
"dependencies": [MBED_LIBRARIES, TEST_MBED_LIB],
204204
"peripherals": ["digital_loop"]
205205
},
206+
{
207+
"id": "MBED_A22", "description": "Call function before main (mbed_main)",
208+
"source_dir": join(TEST_DIR, "mbed", "call_before_main"),
209+
"dependencies": [MBED_LIBRARIES, TEST_MBED_LIB],
210+
"automated": True,
211+
},
206212

207213
# Size benchmarks
208214
{

workspace_tools/toolchains/gcc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def __init__(self, target, options=None, notify=None, tool_path=""):
6464
self.cc = [join(tool_path, "arm-none-eabi-gcc"), "-std=gnu99"] + common_flags
6565
self.cppc =[join(tool_path, "arm-none-eabi-g++"), "-std=gnu++98"] + common_flags
6666

67-
self.ld = [join(tool_path, "arm-none-eabi-gcc"), "-Wl,--gc-sections"] + self.cpu
67+
self.ld = [join(tool_path, "arm-none-eabi-gcc"), "-Wl,--gc-sections", "-Wl,--wrap,main"] + self.cpu
6868
self.sys_libs = ["stdc++", "supc++", "m", "c", "gcc"]
6969

7070
self.ar = join(tool_path, "arm-none-eabi-ar")

0 commit comments

Comments
 (0)