* binfmt/binfmt_execsymtab.c
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you 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.
*
****************************************************************************/
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <assert.h>
#include <nuttx/irq.h>
#include <nuttx/symtab.h>
#include <nuttx/binfmt/symtab.h>
#include <nuttx/spinlock.h>
#ifdef CONFIG_LIBC_EXECFUNCS
* Pre-processor Definitions
****************************************************************************/
* following must also be defined:
*/
#ifdef CONFIG_EXECFUNCS_HAVE_SYMTAB
# ifndef CONFIG_EXECFUNCS_SYMTAB_ARRAY
# error "CONFIG_EXECFUNCS_SYMTAB_ARRAY must be defined"
# endif
# ifndef CONFIG_EXECFUNCS_NSYMBOLS_VAR
# error "CONFIG_EXECFUNCS_NSYMBOLS_VAR must be defined"
# endif
#endif
* Public Data
****************************************************************************/
#ifdef CONFIG_EXECFUNCS_HAVE_SYMTAB
extern const struct symtab_s CONFIG_EXECFUNCS_SYMTAB_ARRAY[];
extern int CONFIG_EXECFUNCS_NSYMBOLS_VAR;
#endif
* Private Data
****************************************************************************/
static FAR const struct symtab_s *g_exec_symtab;
static int g_exec_nsymbols;
static spinlock_t g_exec_lock = SP_UNLOCKED;
* Public Functions
****************************************************************************/
* Name: exec_getsymtab
*
* Description:
* Get the current symbol table selection as an atomic operation.
*
* Input Parameters:
* symtab - The location to store the symbol table.
* nsymbols - The location to store the number of symbols in the symbol
* table.
*
* Returned Value:
* None
*
****************************************************************************/
void exec_getsymtab(FAR const struct symtab_s **symtab, FAR int *nsymbols)
{
irqstate_t flags;
DEBUGASSERT(symtab != NULL && nsymbols != NULL);
* size are returned as a single atomic operation.
*/
flags = spin_lock_irqsave(&g_exec_lock);
#ifdef CONFIG_EXECFUNCS_HAVE_SYMTAB
* table has not yet been initialized, then use the provided start-up
* symbol table.
*/
if (g_exec_symtab == NULL)
{
g_exec_symtab = CONFIG_EXECFUNCS_SYMTAB_ARRAY;
g_exec_nsymbols = CONFIG_EXECFUNCS_NSYMBOLS_VAR;
}
#endif
*symtab = g_exec_symtab;
*nsymbols = g_exec_nsymbols;
spin_unlock_irqrestore(&g_exec_lock, flags);
}
* Name: exec_setsymtab
*
* Description:
* Select a new symbol table selection as an atomic operation.
*
* Input Parameters:
* symtab - The new symbol table.
* nsymbols - The number of symbols in the symbol table.
*
* Returned Value:
* None
*
****************************************************************************/
void exec_setsymtab(FAR const struct symtab_s *symtab, int nsymbols)
{
irqstate_t flags;
DEBUGASSERT(symtab != NULL);
* size are set as a single atomic operation.
*/
flags = spin_lock_irqsave(&g_exec_lock);
g_exec_symtab = symtab;
g_exec_nsymbols = nsymbols;
spin_unlock_irqrestore(&g_exec_lock, flags);
}
#endif