forked from OP-TEE/optee_os
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
core, ldelf: add support for runtime loading of shared libraries
This commit prepares the introduction of libdl, a dynamic linking library which will allow TAs to load shared libraries at run time, and resolve symbols on demand. It adds the following function to the system PTA, inspired from the POSIX dlopen() and dlsym(): - system_dlopen(): takes a UUID and flags. Performs an upcall into ldelf which then uses the usual system PTA functions to load an map the requested library into the address space of the calling TA. - system_dlsym(): takes a UUID and a symbol name. The symbol is looked up in the library specified by UUID by calling into ldelf. If UUID is all zeros, all the mapped binaries are searched. Signed-off-by: Jerome Forissier <[email protected]> Reviewed-by: Jens Wiklander <[email protected]> Acked-by: Etienne Carriere <[email protected]>
- Loading branch information
1 parent
791ee55
commit ebef121
Showing
13 changed files
with
417 additions
and
49 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// SPDX-License-Identifier: BSD-2-Clause | ||
/* | ||
* Copyright (c) 2019, Linaro Limited | ||
*/ | ||
#include <ldelf.h> | ||
#include <string.h> | ||
|
||
#include "dl.h" | ||
#include "ta_elf.h" | ||
|
||
TEE_Result dlopen_entry(struct dl_entry_arg *arg) | ||
{ | ||
TEE_UUID zero = { }; | ||
|
||
if (arg->dlopen.flags != (RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE)) | ||
return TEE_ERROR_BAD_PARAMETERS; | ||
|
||
if (!memcmp(&arg->dlopen.uuid, &zero, sizeof(zero))) | ||
return TEE_SUCCESS; | ||
|
||
return ta_elf_add_library(&arg->dlopen.uuid); | ||
} | ||
|
||
TEE_Result dlsym_entry(struct dl_entry_arg *arg) | ||
{ | ||
struct ta_elf *elf = NULL; | ||
TEE_UUID zero = { }; | ||
|
||
if (memcmp(&arg->dlsym.uuid, &zero, sizeof(zero))) { | ||
elf = ta_elf_find_elf(&arg->dlsym.uuid); | ||
if (!elf) | ||
return TEE_ERROR_ITEM_NOT_FOUND; | ||
} | ||
|
||
return ta_elf_resolve_sym(arg->dlsym.symbol, &arg->dlsym.val, elf); | ||
} | ||
|
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,16 @@ | ||
/* SPDX-License-Identifier: BSD-2-Clause */ | ||
/* | ||
* Copyright (c) 2019, Linaro Limited | ||
*/ | ||
|
||
#ifndef LDELF_DL_H | ||
#define LDELF_DL_H | ||
|
||
#include <types_ext.h> | ||
#include <ldelf.h> | ||
|
||
TEE_Result dlopen_entry(struct dl_entry_arg *arg); | ||
TEE_Result dlsym_entry(struct dl_entry_arg *arg); | ||
|
||
#endif /*LDELF_DL_H*/ | ||
|
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
Oops, something went wrong.