-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
1,495 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,7 +67,7 @@ popd > /dev/null # ${MY_DIR} | |
# Therefore in that case it warns you but doesnt' chnage to that version, which could cause your tests to break. | ||
# Change this to upgrade your ut-control Major versions. Non ABI Changes 1.x.x are supported, between major revisions | ||
|
||
UT_CONTROL_PROJECT_VERSION="1.6.1" # Fixed version | ||
UT_CONTROL_PROJECT_VERSION="1.6.2" # Fixed version | ||
|
||
# Clone the Unit Test Requirements | ||
[email protected]:rdkcentral/ut-control.git | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# * | ||
# * If not stated otherwise in this file or this component's LICENSE file the | ||
# * following copyright and licenses apply: | ||
# * | ||
# * Copyright 2023 RDK Management | ||
# * | ||
# * Licensed under the Apache License, Version 2.0 (the "License"); | ||
# * you may not use this file except in compliance with the License. | ||
# * You may obtain a copy of the License at | ||
# * | ||
# * http://www.apache.org/licenses/LICENSE-2.0 | ||
# * | ||
# * Unless required by applicable law or agreed to in writing, software | ||
# * distributed under the License is distributed on an "AS IS" BASIS, | ||
# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# * See the License for the specific language governing permissions and | ||
# * limitations under the License. | ||
# * | ||
|
||
# Makefile for demonstrating weak vs strong symbols using dlopen | ||
|
||
ifeq ($(TARGET),) | ||
CC = gcc | ||
else | ||
#CC = rm-rdk-linux-gnueabi-gcc -mthumb -mfpu=vfp -mcpu=cortex-a9 -mfloat-abi=soft -mabi=aapcs-linux -mno-thumb-interwork -ffixed-r8 -fomit-frame-pointer | ||
endif | ||
CFLAGS = -Wall -fPIC | ||
LDFLAGS = -ldl | ||
|
||
# Targets | ||
EXECUTABLE = main | ||
SHARED_LIB = libplugin.so | ||
|
||
# Source files | ||
MAIN_SRC = main.c | ||
PLUGIN_SRC = plugin.c | ||
|
||
.PHONY: all clean | ||
|
||
all: $(EXECUTABLE) $(SHARED_LIB) | ||
|
||
$(EXECUTABLE): $(MAIN_SRC) | ||
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) | ||
|
||
$(SHARED_LIB): $(PLUGIN_SRC) | ||
$(CC) $(CFLAGS) -shared -o $@ $^ | ||
|
||
clean: | ||
rm -f $(EXECUTABLE) $(SHARED_LIB) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# Plugin Loader Project using dlopen | ||
|
||
## Overview | ||
This project demonstrates how to create a simple C program that dynamically loads a shared library (plugin) and executes its functions. The project consists of : | ||
- a main program (`main.c`) that loads the plugin at runtime | ||
- and interacts with it through an interface defined in `plugin.h`. | ||
- The plugin itself is implemented in `plugin.c`. | ||
|
||
## Prerequisites | ||
|
||
To build and run this project, you need: | ||
|
||
- A C compiler (e.g., `gcc`) | ||
- The `dl` library for dynamic linking (commonly available on Linux) | ||
- GNU `make` | ||
|
||
## Compilation Instructions | ||
|
||
1. Build the project for the native architecture: | ||
```bash | ||
make | ||
``` | ||
|
||
2. Build the project for an ARM target: | ||
```bash | ||
make TARGET=arm | ||
``` | ||
Ensure you have the appropriate cross-compiler toolchain configured for ARM in the `Makefile`. | ||
|
||
3. Clean up the generated files: | ||
```bash | ||
make clean | ||
``` | ||
|
||
## Usage | ||
|
||
The program dynamically loads the shared library and attempts to use the strong implementations. If a strong implementation is not found, the weak implementation is used instead. | ||
|
||
1. Example Output for linux | ||
```bash | ||
./main | ||
Plugin initialized. | ||
Plugin action performed. | ||
Plugin cleaned up. | ||
``` | ||
|
||
2. Example Output for arm | ||
```bash | ||
root@xione-uk:/opt/jyo# ./main | ||
Plugin initialized. | ||
Plugin action performed. | ||
Plugin cleaned up. | ||
``` | ||
|
||
3. Example when plugin not found: | ||
```bash | ||
Plugin not found. Running without plugin. | ||
``` | ||
|
||
## Project Details | ||
|
||
**main.c:** | ||
|
||
This file contains the main program that dynamically loads the libplugin.so shared library and uses the PluginInterface to call the plugin’s functions. | ||
|
||
**plugin.c:** | ||
|
||
This file defines the implementation of the functions specified in the PluginInterface. The functions include plugin_initialize(), plugin_perform_action(), and plugin_cleanup(). | ||
|
||
**plugin.h:** | ||
|
||
The header file that defines the PluginInterface structure, which declares the function pointers used by the plugin. | ||
|
||
|
||
## Dependencies | ||
|
||
- GCC for compilation. | ||
- `libdl` (part of the standard library) for dynamic linking. | ||
|
||
## Notes | ||
|
||
- Ensure the shared library (`libplugin.so`) is located in the same directory as the `main` executable, or adjust the `LD_LIBRARY_PATH` environment variable to include its location. | ||
- This example is designed for educational purposes and demonstrates basic concepts of dynamic linking and symbol resolution in C. |
Oops, something went wrong.