This commit is contained in:
liang.huang 2026-08-01 05:26:29 +00:00 committed by GitHub
commit 7f22d9c00b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
24 changed files with 102 additions and 3 deletions

View file

@ -41,6 +41,7 @@
.section .text
.global __start
.type __start, function
__start:

View file

@ -42,6 +42,7 @@
.section .text
.global __start
.type __start, function
__start:

View file

@ -36,6 +36,7 @@
****************************************************************************/
.global __start
.type __start, function
/****************************************************************************
* Section: .text

View file

@ -108,6 +108,8 @@
.global exception_common
.global return_from_exception
.global return_from_syscall
.type exception_common, function
.type return_from_exception, function
.align 8
exception_common:
@ -337,6 +339,7 @@ return_from_exception:
.section EXCEPTION_SECTION
.global riscv_jump_to_user
.type riscv_jump_to_user, function
riscv_jump_to_user:

View file

@ -41,6 +41,7 @@
.section .text
.global __start
.type __start, function
__start:

View file

@ -35,6 +35,7 @@
****************************************************************************/
.global __start
.type __start, function
/****************************************************************************
* Section: .text

View file

@ -41,6 +41,7 @@
.section .text
.global __start
.type __start, function
__start:

View file

@ -41,6 +41,7 @@
.section .text
.global __start
.type __start, function
__start:

View file

@ -41,6 +41,7 @@
.section .text
.global __start
.type __start, function
__start:
/* reset mstatus to 0*/

View file

@ -41,6 +41,7 @@
.section .text
.global __start
.type __start, function
__start:
/* reset mstatus to 0*/

View file

@ -41,6 +41,7 @@
.section .text
.global __start
.type __start, function
__start:

View file

@ -42,6 +42,7 @@
.section .text
.global __start
.type __start, function
__start:

View file

@ -48,12 +48,14 @@
#ifdef CONFIG_NUTTSBI
.global __start_s
.type __start_s, function
__start_s:
#else
.global __start
.type __start, function
__start:

View file

@ -39,6 +39,7 @@
.section .text
.global __start
.type __start, function
__start:

View file

@ -43,6 +43,7 @@
.section .text
.global __start
.type __start, function
/****************************************************************************
* Name: __start

View file

@ -44,6 +44,7 @@
.section .start, "ax"
.global __start
.type __start, function
__start:

View file

@ -44,8 +44,10 @@
.section .start, "ax"
#ifdef CONFIG_NUTTSBI
.global __start_s
.type __start_s, function
#else
.global __start
.type __start, function
#endif
/****************************************************************************

View file

@ -39,6 +39,7 @@
.section .text
.global __start
.type __start, function
__start:

View file

@ -42,10 +42,12 @@
.section .text
#ifndef CONFIG_NUTTSBI
.global __start
.type __start, function
__start:
#else
.global __start_s
.type __start_s, function
__start_s:
#endif

View file

@ -40,6 +40,7 @@
.section .text
.global __start
.type __start, function
__start:

View file

@ -38,6 +38,7 @@
.global exception_common
.global return_from_exception
.global __start
.type __start, function
.section .text

View file

@ -41,6 +41,7 @@
.section .text
.global __start
.type __start, function
__start:

View file

@ -31,6 +31,8 @@
* Public Data
****************************************************************************/
#if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__)
extern const struct symtab_s g_allsyms[];
extern const int g_nallsyms;
@ -59,9 +61,52 @@ allsyms_lookup(FAR const char *name, FAR void *value,
else if (value)
{
symbol = symtab_findbyvalue(g_allsyms, value, g_nallsyms);
/* g_allsyms[0] and g_allsyms[g_nallsyms - 1] are boundary sentinels,
* not real symbols. A match against either one means 'value' falls
* outside the range covered by real symbols, so treat it as not
* found instead of reporting a bogus name/offset.
*/
if (symbol == &g_allsyms[0] ||
symbol == &g_allsyms[g_nallsyms - 1])
{
symbol = NULL;
}
}
if (symbol && symbol != &g_allsyms[g_nallsyms - 1])
if (symbol == NULL)
{
*size = 0;
return NULL;
}
#ifdef CONFIG_SYMTAB_ORDEREDBYNAME
/* g_allsyms is sorted by name here, not by value, so the physically
* next table entry is not necessarily the next symbol by address.
* Scan the real symbols (index 1..g_nallsyms - 2; 0 and g_nallsyms - 1
* are the boundary sentinels) for the smallest address greater than
* this symbol's, falling back to the high sentinel's now-meaningful
* value if none is closer.
*/
{
FAR const struct symtab_s *next = &g_allsyms[g_nallsyms - 1];
int i;
for (i = 1; i < g_nallsyms - 1; i++)
{
if (g_allsyms[i].sym_value > symbol->sym_value &&
g_allsyms[i].sym_value < next->sym_value)
{
next = &g_allsyms[i];
}
}
*size = next->sym_value - symbol->sym_value;
}
#else
if (symbol != &g_allsyms[g_nallsyms - 1])
{
*size = (symbol + 1)->sym_value - symbol->sym_value;
}
@ -69,6 +114,7 @@ allsyms_lookup(FAR const char *name, FAR void *value,
{
*size = 0;
}
#endif
return symbol;
}
@ -115,3 +161,21 @@ FAR const struct symtab_s *allsyms_findbyvalue(FAR void *value,
{
return allsyms_lookup(NULL, value, size);
}
#else
FAR const struct symtab_s *allsyms_findbyname(FAR const char *name,
FAR size_t *size)
{
*size = 0;
return NULL;
}
FAR const struct symtab_s *allsyms_findbyvalue(FAR void *value,
FAR size_t *size)
{
*size = 0;
return NULL;
}
#endif /* CONFIG_BUILD_FLAT || __KERNEL__ */

View file

@ -47,6 +47,7 @@ class SymbolTables(object):
self.elffile = None
self.output = output
self.symbol_list = []
self.max_address = 0
def symbol_filter(self, symbol):
if symbol["st_info"]["type"] != "STT_FUNC":
@ -78,7 +79,9 @@ class SymbolTables(object):
self.emitline(
' { "%s", (FAR %s void *)%s },' % (symbol[1], noconst, hex(symbol[0]))
)
self.emitline(' { "Unknown", (FAR %s void *)0xffffffff }\n};' % (noconst))
self.emitline(
' { "Unknown", (FAR %s void *)%s }\n};' % (noconst, hex(self.max_address))
)
def get_symtable(self):
symbol_tables = [
@ -111,7 +114,12 @@ class SymbolTables(object):
func_name = re.sub(r"\(.*$", "", symbol_name)
except cxxfilt.InvalidName:
symbol_name = symbol.name
self.symbol_list.append((symbol["st_value"], func_name))
self.symbol_list.append(
(symbol["st_value"], func_name, symbol["st_size"])
)
end = symbol["st_value"] + symbol["st_size"]
if end > self.max_address:
self.max_address = end
if orderbyname:
self.symbol_list = sorted(self.symbol_list, key=lambda item: item[1])
else: