incubator-nuttx/libs/libc
yinshengkai 97096bed83 libs: fix the problem that the address obtained in thumb mode cannot be executed.
The lowest bit of the thumb instruction is 1 by default, which is used to distinguish arm instructions and thumb instructions.
Fixed the problem of misalignment of symbol table when performing binary search

In arm, the lowest bit of the instruction is 1, which is a thumb instruction, and 0, which is an arm instruction.
The nm command was used in mkallsym.sh before, and the result it will return will set the lowest bit of the thumb instruction to 0. There will be a one-byte deviation during binary search, so mkallsyms.py will also set the lowest bit to 0 according to the previous format.
```sh
arm-none-eabi-nm -Cn nuttx | grep hello
0801c384 T hello_main
arm-none-eabi-objdump nuttx -t |grep hello
0801c384 g F .text 0000004c hello_main
arm-none-eabi-readelf nuttx -s |grep hello
4558: 0801c385 76 FUNC GLOBAL DEFAULT 1 hello_main
```

However, in the following case, when you need to find the function address according to the symbol name and execute the corresponding function, the lowest address obtained is 0. It will follow the arm instruction, causing an exception.
```c
void sym_test(void)
{
   printf("call sym_test\n");
}

int main(int argc, FAR char *argv[])
{
   FAR void *addr = sym_test;
   printf("sym_test:%p %pS\n",addr, addr);
   printf("sym_test - 1: %pS\n", (char *)addr - 1);
   printf("sym_test + 1: %pS\n", (char *)addr + 1);

   size_t size;
   void (*func)(void);
   const struct symtab_s *sym = allsyms_findbyname("sym_test", &size);
   printf("sym_test:%p %pS\n",sym, sym);
   func = sym->sym_value;
   func();

   return 0;
}
```

Therefore, you need to change mkallsyms.py back to the correct result and correct the binary search.

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-01-04 09:22:57 -08:00
..
aio libc: Change errno to set_errno and get_errno 2023-10-29 17:16:09 +02:00
assert
audio libsrc: update version in CMakeLists.txt 2023-09-07 22:15:48 +08:00
bin
builtin libs/libc: adapt the cmake script from the makefile 2023-11-07 17:39:03 +01:00
ctype libs/ctype/toupper_l: Implement function toupper_l instead of macro 2023-08-22 00:07:16 +08:00
dirent
dlfcn Fix loading of ET_DYN type of shared objects 2023-09-20 09:35:28 -04:00
errno
eventfd
fdt CMake:init arm64 CMake qemu-armv8a build 2023-12-27 07:27:17 -08:00
fixedmath
gdbstub support gdbstub use serial. 2023-12-11 08:43:26 -08:00
gpsutils libs/libc: adapt the cmake script from the makefile 2023-11-07 17:39:03 +01:00
grp
hex2bin c++ compatibility: rename reserved c++ keywords 'public' and 'this' 2023-09-16 19:45:02 +08:00
inttypes
kbin
libgen
locale libc: Change errno to set_errno and get_errno 2023-10-29 17:16:09 +02:00
lzf
machine armv7-m: Expose section name to allow relocation 2024-01-04 15:07:18 +01:00
misc libs/log2ceil: Move implementation of log2ceil to a common place 2023-12-14 08:46:12 -08:00
modlib riscv/arch_elf.c: Handle PCREL_HI20/LO12_I/S relocations correctly 2023-12-12 17:32:36 -08:00
net
netdb netdb: When set a dns nameserver, if the nameserver already exists, retrun OK. 2023-10-12 12:22:16 +08:00
obstack c++ compatibility: rename reserved c++ keywords 'public' and 'this' 2023-09-16 19:45:02 +08:00
pthread sched/tls_info: Add tl_ prefix to pthread cleanup stack / tos 2023-11-15 08:52:04 -08:00
pwd pwd: fix syntax error 2023-09-04 23:19:46 +08:00
queue
regex
sched task/pthread_cancelpt: Move cancel point handling to libc, data to TLS 2023-11-15 08:52:04 -08:00
semaphore sched/semaphore: Move named semaphores to user space 2023-11-27 04:52:54 -08:00
signal signal: add siginterrupt implementation 2023-08-29 09:43:42 +08:00
spawn libs/libc/spawn: Add minimal implementation for posix_spawnattr_destory. 2023-10-31 13:42:00 +08:00
stdio libs/libc/wchar: add ungetwc implementation 2023-12-17 01:39:06 -08:00
stdlib libc/realpath: allocate link buffer of pseudofs to save stack 2023-11-07 09:05:50 +08:00
stream libc/stream: add file out stream 2023-12-25 16:54:16 -03:00
string Revert "libc/lib_bzero:Add bzero prototype." 2023-11-21 07:56:52 -08:00
symtab libs: fix the problem that the address obtained in thumb mode cannot be executed. 2024-01-04 09:22:57 -08:00
syslog
termios
time libc: Change errno to set_errno and get_errno 2023-10-29 17:16:09 +02:00
tls task/pthread_cancelpt: Fix task_delete from another task group 2023-11-22 08:05:58 -08:00
uio
unistd libc: Change errno to set_errno and get_errno 2023-10-29 17:16:09 +02:00
userfs
uuid libc: Change errno to set_errno and get_errno 2023-10-29 17:16:09 +02:00
wchar libs/libc/wchar: add wcswidth implementation 2023-09-22 08:51:07 +08:00
wctype
wqueue semaphore/_SEM_XX: Remove the _SEM redirection macros as unnecessary 2023-11-27 04:52:54 -08:00
zoneinfo Documentation: remove all migrated READMEs 2023-10-29 21:03:54 -03:00
.gitignore libfdt: modify makefile 2023-08-26 17:07:02 +08:00
CMakeLists.txt
Kconfig
Makefile
libc.csv libs/libc/wchar: add ungetwc implementation 2023-12-17 01:39:06 -08:00
libc.h stdio: Implement [clearerr|putc|fflush]_unlocked 2023-10-29 17:09:18 +02:00