Commit Graph

8 Commits

Author SHA1 Message Date
Alin Jerpelea c9eef2d697 tools: migrate to SPDX identifier
Most tools used for compliance and SBOM generation use SPDX identifiers
This change brings us a step closer to an easy SBOM generation.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2024-09-10 23:11:11 +08:00
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
yinshengkai 9d436b624b tools: support sorting symbol tables by name
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-01-04 09:22:57 -08:00
chao an fb9b41221d semantic/parser: fix compile warning found by sparse
Reference:
https://linux.die.net/man/1/sparse

Signed-off-by: chao an <anchao@xiaomi.com>
2023-05-30 23:00:00 +08:00
yinshengkai 416cd2da35 tools/mkallsyms: add exception handle
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-05-19 20:22:55 +08:00
yinshengkai 6b10d8ed19 tools: make the symbol table generated by mkallsyms.py two-byte aligned
When using stm32, the starting address of the function parsed by mkallsyms.py is an odd number, one large than the actual address

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-02-23 00:57:32 +08:00
Tomasz 'CeDeROM' CEDRO 833f7a5a3e Updated python scripts interpreter invocation in `tools/`.
* Using call to portable `#!/usr/bin/env python3` syntax.
* Updated python interpreter call in `tools/ci/testrun` (please verify).

Signed-off-by: Tomasz 'CeDeROM' CEDRO <tomek@cedro.info>
2023-02-19 14:15:27 +08:00
yinshengkai 3c8773a854 tools: Optimizing mkallsyms scripts with python
When compiling my project, the time to generate allsyms decreased from tens of seconds to 2 seconds

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2022-09-29 08:33:04 +08:00