usb-gadget: access external symbol using dlsym(), not extern keyword 25/272925/4 accepted/tizen/unified/20220331.010053 submit/tizen/20220328.084941
authorYoungjae Cho <y0.cho@samsung.com>
Mon, 28 Mar 2022 05:07:25 +0000 (22:07 -0700)
committerYoungjae Cho <y0.cho@samsung.com>
Mon, 28 Mar 2022 08:18:32 +0000 (01:18 -0700)
commit8634169cbcf0ddbe90adbf7babf0ff37745d72d5
treec22ea4342d4a73fa808bf01f064490d6e5c96e7d
parent2cac696825e5c4a44c9076366e6ce7c2a1debc08
usb-gadget: access external symbol using dlsym(), not extern keyword

The variable declared as extern storage class must be resolved when the
symbol is loaded onto memory regardless of lazy binding. Therefore if
a symbol doesn't exist on being loaded, the whole library loading will
fail. To avoid this, explicitly load a symbol using dlsym(), which is
able to handle undefined symbol error.

This is mainly because the device-common shared library contains both
of udev and usb-gadget, making them always be loaded onto memory
together even if a caller only wants to use udev, not usb-gadget. This
structure should be revamped later.

Change-Id: Ia2bd7801123c812976ce79f0e0b880e6f1e67463
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
CMakeLists.txt
src/usb_gadget/usb_gadget.h
src/usb_gadget/usb_gadget_common.c