usb-gadget: access external symbol using dlsym(), not extern keyword 43/272943/1 accepted/tizen/6.5/unified/20220330.000717 submit/tizen_6.5/20220328.084953
authorYoungjae Cho <y0.cho@samsung.com>
Mon, 28 Mar 2022 05:07:25 +0000 (22:07 -0700)
committerHyotaek Shim <hyotaek.shim@samsung.com>
Mon, 28 Mar 2022 08:33:46 +0000 (08:33 +0000)
commitd52c1e2ba61ad55c7e3d094533a77e656b6344e3
treec22ea4342d4a73fa808bf01f064490d6e5c96e7d
parentaf1edd554a1f8aca8d060620d64877825e0ee5e7
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>
(cherry picked from commit 8634169cbcf0ddbe90adbf7babf0ff37745d72d5)
CMakeLists.txt
src/usb_gadget/usb_gadget.h
src/usb_gadget/usb_gadget_common.c