Skip to content

Commit 220f594

Browse files
committed
Cellular: Fix overriding CellularDevice::get_default_instance failure
With e.g. GCC linker option "--undefined=<LINK_FOO>", pull in the object file implemening CellularDevice::get_default_instance anyway for being able to override weak symbol successfully even though from static library. See: https://stackoverflow.com/questions/42588983/what-does-the-gnu-ld-undefined-option-do
1 parent b0ec424 commit 220f594

File tree

18 files changed

+238
-4
lines changed

18 files changed

+238
-4
lines changed

connectivity/drivers/cellular/Altair/COMPONENT_ALTAIR_ALT1250/PPP/ALT1250_PPP.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,5 +118,19 @@ CellularDevice *CellularDevice::get_default_instance()
118118
static ALT1250_PPP device(&serial, MBED_CONF_ALT1250_PPP_RST, PIN_OUTPUT, OpenDrainNoPull, 1);
119119
return &device;
120120
}
121+
122+
/*
123+
* With e.g. GCC linker option "--undefined=<LINK_FOO>", pull in this
124+
* object file anyway for being able to override weak symbol successfully
125+
* even though from static library. See:
126+
* https://stackoverflow.com/questions/42588983/what-does-the-gnu-ld-undefined-option-do
127+
*
128+
* NOTE: For C++ name mangling, 'extern "C"' is necessary to match the
129+
* <LINK_FOO> symbol correctly.
130+
*/
131+
extern "C"
132+
void LINK_ALT1250_PPP_CPP(void)
133+
{
134+
}
121135
#endif
122136

connectivity/drivers/cellular/Altair/COMPONENT_ALTAIR_ALT1250/PPP/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,15 @@ target_sources(mbed-cellular
1212
ALT1250_PPP_CellularContext.cpp
1313
ALT1250_PPP_CellularNetwork.cpp
1414
)
15+
16+
# Link override object file coming from static library anyway
17+
#
18+
# NOTE: This linker option is to pretend undefined symbol and won't cause
19+
# undefined symbol error even though the override object file actually
20+
# doesn't provide such symbol definition.
21+
if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
22+
target_link_options(mbed-cellular
23+
INTERFACE
24+
LINKER:--undefined=LINK_ALT1250_PPP_CPP
25+
)
26+
endif()

connectivity/drivers/cellular/COMPONENT_STMOD_CELLULAR/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,15 @@ target_sources(mbed-cellular
1010
PRIVATE
1111
STModCellular.cpp
1212
)
13+
14+
# Link override object file coming from static library anyway
15+
#
16+
# NOTE: This linker option is to pretend undefined symbol and won't cause
17+
# undefined symbol error even though the override object file actually
18+
# doesn't provide such symbol definition.
19+
if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
20+
target_link_options(mbed-cellular
21+
INTERFACE
22+
LINKER:--undefined=LINK_STMODCELLULAR_CPP
23+
)
24+
endif()

connectivity/drivers/cellular/COMPONENT_STMOD_CELLULAR/STModCellular.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,5 +179,19 @@ CellularDevice *CellularDevice::get_default_instance()
179179
static STModCellular device(&serial);
180180
return &device;
181181
}
182+
183+
/*
184+
* With e.g. GCC linker option "--undefined=<LINK_FOO>", pull in this
185+
* object file anyway for being able to override weak symbol successfully
186+
* even though from static library. See:
187+
* https://stackoverflow.com/questions/42588983/what-does-the-gnu-ld-undefined-option-do
188+
*
189+
* NOTE: For C++ name mangling, 'extern "C"' is necessary to match the
190+
* <LINK_FOO> symbol correctly.
191+
*/
192+
extern "C"
193+
void LINK_STMODCELLULAR_CPP(void)
194+
{
195+
}
182196
#endif
183197

connectivity/drivers/cellular/GEMALTO/COMPONENT_GEMALTO_CINTERION/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,15 @@ target_sources(mbed-cellular
1313
GEMALTO_CINTERION_CellularInformation.cpp
1414
GEMALTO_CINTERION_CellularStack.cpp
1515
)
16+
17+
# Link override object file coming from static library anyway
18+
#
19+
# NOTE: This linker option is to pretend undefined symbol and won't cause
20+
# undefined symbol error even though the override object file actually
21+
# doesn't provide such symbol definition.
22+
if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
23+
target_link_options(mbed-cellular
24+
INTERFACE
25+
LINKER:--undefined=LINK_GEMALTO_CINTERION_CPP
26+
)
27+
endif()

connectivity/drivers/cellular/GEMALTO/COMPONENT_GEMALTO_CINTERION/GEMALTO_CINTERION.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,4 +214,18 @@ CellularDevice *CellularDevice::get_default_instance()
214214
static GEMALTO_CINTERION device(&serial);
215215
return &device;
216216
}
217+
218+
/*
219+
* With e.g. GCC linker option "--undefined=<LINK_FOO>", pull in this
220+
* object file anyway for being able to override weak symbol successfully
221+
* even though from static library. See:
222+
* https://stackoverflow.com/questions/42588983/what-does-the-gnu-ld-undefined-option-do
223+
*
224+
* NOTE: For C++ name mangling, 'extern "C"' is necessary to match the
225+
* <LINK_FOO> symbol correctly.
226+
*/
227+
extern "C"
228+
void LINK_GEMALTO_CINTERION_CPP(void)
229+
{
230+
}
217231
#endif

connectivity/drivers/cellular/GENERIC/COMPONENT_GENERIC_AT3GPP/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,15 @@ target_sources(mbed-cellular
1010
PRIVATE
1111
GENERIC_AT3GPP.cpp
1212
)
13+
14+
# Link override object file coming from static library anyway
15+
#
16+
# NOTE: This linker option is to pretend undefined symbol and won't cause
17+
# undefined symbol error even though the override object file actually
18+
# doesn't provide such symbol definition.
19+
if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
20+
target_link_options(mbed-cellular
21+
INTERFACE
22+
LINKER:--undefined=LINK_GENERIC_AT3GPP_CPP
23+
)
24+
endif()

connectivity/drivers/cellular/GENERIC/COMPONENT_GENERIC_AT3GPP/GENERIC_AT3GPP.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,18 @@ CellularDevice *CellularDevice::get_default_instance()
6161
static GENERIC_AT3GPP device(&serial);
6262
return &device;
6363
}
64+
65+
/*
66+
* With e.g. GCC linker option "--undefined=<LINK_FOO>", pull in this
67+
* object file anyway for being able to override weak symbol successfully
68+
* even though from static library. See:
69+
* https://stackoverflow.com/questions/42588983/what-does-the-gnu-ld-undefined-option-do
70+
*
71+
* NOTE: For C++ name mangling, 'extern "C"' is necessary to match the
72+
* <LINK_FOO> symbol correctly.
73+
*/
74+
extern "C"
75+
void LINK_GENERIC_AT3GPP_CPP(void)
76+
{
77+
}
6478
#endif

connectivity/drivers/cellular/MultiTech/DragonflyNano/COMPONENT_MULTITECH_DRAGONFLY_NANO_CELLULAR/CMakeLists.txt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,16 @@ target_sources(mbed-cellular
1414

1515
if("MTS_DRAGONFLY_L471QG" IN_LIST MBED_TARGET_LABELS)
1616
add_subdirectory(TARGET_MTS_DRAGONFLY_L471QG)
17-
endif()
17+
endif()
18+
19+
# Link override object file coming from static library anyway
20+
#
21+
# NOTE: This linker option is to pretend undefined symbol and won't cause
22+
# undefined symbol error even though the override object file actually
23+
# doesn't provide such symbol definition.
24+
if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
25+
target_link_options(mbed-cellular
26+
INTERFACE
27+
LINKER:--undefined=LINK_SARA4_PPP_CPP
28+
)
29+
endif()

connectivity/drivers/cellular/MultiTech/DragonflyNano/COMPONENT_MULTITECH_DRAGONFLY_NANO_CELLULAR/SARA4_PPP.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,4 +185,18 @@ CellularDevice *CellularDevice::get_default_instance()
185185
static SARA4_PPP device(&serial);
186186
return &device;
187187
}
188+
189+
/*
190+
* With e.g. GCC linker option "--undefined=<LINK_FOO>", pull in this
191+
* object file anyway for being able to override weak symbol successfully
192+
* even though from static library. See:
193+
* https://stackoverflow.com/questions/42588983/what-does-the-gnu-ld-undefined-option-do
194+
*
195+
* NOTE: For C++ name mangling, 'extern "C"' is necessary to match the
196+
* <LINK_FOO> symbol correctly.
197+
*/
198+
extern "C"
199+
void LINK_SARA4_PPP_CPP(void)
200+
{
201+
}
188202
#endif

0 commit comments

Comments
 (0)