Commit Graph

374 Commits

Author SHA1 Message Date
Xiang Xiao cd516bd09d Fix libelf/libelf_coredump.c:234:7: warning: 'strncpy' output may be truncated copying 16 bytes from a string of length 31
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-03-22 08:37:33 +02:00
Ville Juven 75afe491ad RISC-V: Prepare for CONFIG_BUILD_KERNEL
- Thread context prior to system call needs to be preserved
- Allocate a kernel heap
2022-03-18 18:20:12 +08:00
Masayuki Ishikawa a44a0a08cd binfmt: Call umm_initialize() for BUILD_KERNEL & ADDRENV
Summary:
- I noticed that the user heap is not initialized correctly
  if BUILD_KERNEL=y and ADDRENV=y
- This commit fixes this issue

Impact:
- None

Testing:
- Tested with sabre-6quad:netknsh (not merged yet)

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2022-02-17 11:31:01 +01:00
Xiang Xiao 47e38eb70f binfmt: Decouple builtin from binfs file system
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-02-14 09:35:35 -03:00
YAMAMOTO Takashi e596d5bd5e binfmt/libelf: Implement sh_addralign handling
Basically, mirror the following two commits from modlib.
It's shame we have two copies of elf loaders.

```
commit 51490bad55
Author: YAMAMOTO Takashi <yamamoto@midokura.com>
Date:   Wed Apr 14 17:07:39 2021 +0900

    modlib: Implement sh_addralign handling

    I've seen a module with 16 bytes .rodata alignment for xmm operations.
    It was getting SEGV on sim/Linux because of the alignment issue.
    The same module binary seems working fine after applying this patch.

    Also, tested on sim/macOS and esp32 on qemu,
    using a module with an artificially large alignment. (64 bytes)
```

```
commit 418e11b8b3
Author: YAMAMOTO Takashi <yamamoto@midokura.com>
Date:   Thu Apr 15 11:33:48 2021 +0900

    modlib: Always use separate allocation for text and data

    Pros:

    * Reduce code differences
    * Smaller allocations for !CONFIG_ARCH_USE_MODULE_TEXT

    Cons:

    * Likely to use more memory for !CONFIG_ARCH_USE_MODULE_TEXT in total

    Tested with:

    * sim:module on macOS
    * esp32-devkit:nsh + CONFIG_MODULE on qemu
    * lm3s6965-ek:qemu-protected + CONFIG_EXAMPLES_SOTEST on qemu
```
2022-01-28 16:23:23 +08:00
Xiang Xiao f903a55102 sched/tcbinfo: Fix the compile warning
Update tcbinfo struct

armv8-m/arm_tcbinfo.c:109:3: warning: excess elements in struct initializer
  109 |   TCB_REG_OFF(REG_S31),
      |   ^~~~~~~~~~~
armv8-m/arm_tcbinfo.c:109:3: note: (near initialization for 'g_tcbinfo')
armv8-m/arm_tcbinfo.c:110:3: warning: excess elements in struct initializer
  110 |   0,
      |   ^
armv8-m/arm_tcbinfo.c:110:3: note: (near initialization for 'g_tcbinfo')
armv8-m/arm_tcbinfo.c:111:3: warning: excess elements in struct initializer
  111 |   TCB_REG_OFF(REG_FPSCR),
      |   ^~~~~~~~~~~
armv8-m/arm_tcbinfo.c:111:3: note: (near initialization for 'g_tcbinfo')
armv8-m/arm_tcbinfo.c:112:3: warning: excess elements in struct initializer
  112 |   0,
      |   ^
armv8-m/arm_tcbinfo.c:112:3: note: (near initialization for 'g_tcbinfo')
armv8-m/arm_tcbinfo.c:37:1: warning: missing braces around initializer [-Wmissing-braces]
   37 | {

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Signed-off-by: zhuyanlin <zhuyanlin1@xiaomi.com>
2022-01-27 17:36:27 +08:00
YAMAMOTO Takashi fd58398918 binfmt/elf.c: Fix syslog formats for ELF64
Loosely followed the copy in mod_insmod.c.
2022-01-27 10:57:48 +08:00
Petro Karashchenko 9551de7115 net: use HTONS, NTOHS, HTONL, NTOHL macro in kernel code
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-01-18 10:59:47 +01:00
chao.an 47f9ec9c45 binfmt/coredump: remove the block fragmentation
Hide the segmentation details to backend implementation

Signed-off-by: chao.an <anchao@xiaomi.com>
2022-01-14 23:07:05 +08:00
chao.an 7cbb8da692 binfmt/elf: add bare metal coredump support
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-11-23 20:48:00 -06:00
Xiang Xiao 9e60c33d4d binfmt: Remove umm_initialize from elf_load
since umm_try_initialize will do it automatically

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-10-18 22:51:18 -03:00
chao.an 5ff4e33e3f binfmt/Makefile: remove the specified prefix from target variables
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-10-19 00:35:35 +02:00
Jiuzhu Dong 2cfda2bffd binfmt: remove file_ioctl and get filename by strrchr
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2021-09-13 08:56:10 +08:00
Xiang Xiao 5025fbef8d Rename LIB_ to LIBC_ for all libc Kconfig
follow other libc component naming convention

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-08-05 19:45:24 +02:00
jordi f3af6edf93 Kconfig: add quotes in source to clean warnings from setconfig
To avoid the setconfig warning "style: quotes recommended around xxx in
source xxx"
2021-07-23 02:32:19 -07:00
Xiang Xiao 841a4922aa binfmt: Replace all nx_ API with file_ API
since binfmt is a kernel component

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-07-06 11:18:13 +09:00
Abdelatif Guettouche af5e0c620f Rename MODULE_TEXT to TEXT_HEAP as the latter is more generic.
Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>
2021-06-18 07:14:17 -05:00
Xiang Xiao 34f31ff3f8 binfmt: Handle argv/argv[0] == NULL correctly in exec_module
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-06-15 13:55:01 -06:00
Xiang Xiao bec68ad8ea sched/posix_spawn: Don't insert name at the begin of argv
since the standard require the caller pass the name explicitly
https://pubs.opengroup.org/onlinepubs/009695399/functions/posix_spawn.html:
The argument argv is an array of character pointers to null-terminated strings.
The last member of this array shall be a null pointer and is not counted in argc.
These strings constitute the argument list available to the new process image.
The value in argv[0] should point to a filename that is associated with the
process image being started by the posix_spawn() or posix_spawnp() function.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-06-15 07:32:33 -06:00
Xiang Xiao 90f71bd017 Revert "sched/posix_spawn: Don't insert name at the begin of argv"
This reverts commit 032086870d.
2021-06-15 07:32:33 -06:00
Xiang Xiao 032086870d sched/posix_spawn: Don't insert name at the begin of argv
since the standard require the caller pass the name explicitly
https://pubs.opengroup.org/onlinepubs/009695399/functions/posix_spawn.html:
The argument argv is an array of character pointers to null-terminated strings.
The last member of this array shall be a null pointer and is not counted in argc.
These strings constitute the argument list available to the new process image.
The value in argv[0] should point to a filename that is associated with the
process image being started by the posix_spawn() or posix_spawnp() function.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Id79ffcc501ae9552dc4e908418ff555f498be7f1
2021-06-14 07:11:53 -06:00
Masayuki Ishikawa 304d72ed00 binfmt: Call up_module_text_free() in unload_module()
Summary:
- I noticed that up_module_text_free() is not called
  if CONFIG_ARCH_USE_MODULE_TEXT=y
- This commit fixes this issue

Impact:
- None

Testing:
- Tested with spresense

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2021-06-04 01:40:37 -05:00
Xiang Xiao 2e54df0f35 Don't include assert.h from public header file
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-06-03 08:36:03 -07:00
Masayuki Ishikawa 4d492104a7 binfmt: Introduce a separate text memory for ELF
Summary:
- This commit introduces a separate text memory for ELF
- The logic is similar to modlib

Impact:
- None

Testing:
- Tested with spresense:elf
- NOTE: needs separate commits

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2021-06-02 02:27:04 -05:00
Xiang Xiao bebdbc5c87 binfmt: Remove filename/exports/nexports from binary_s
to simplify the life cycle management

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-06-02 15:20:38 +09:00
Xiang Xiao cf78a5b6cf binfmt: Move argv copy into exec_module
and remove the related fields from struct binary_s

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-06-02 15:20:38 +09:00
Xiang Xiao d7f96003cf Don't include debug.h from public header file
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-06-01 06:42:02 +09:00
Xiang Xiao 8a14a13819 binfmt: Rename dump_module to binfmt_dumpmodule
follow other binfmt function naming convention

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-05-24 12:16:06 +09:00
Alexander Lunev 4018cc186c libelf: fix "nsh: nsh_session: readline failed: 13" error
Resolves issue #3751
2021-05-21 02:12:31 -07:00
Xiang Xiao 85c1354043 binfmt/elf: Don't close filfd in the fail path
to avoid close the same handle twice because
the caller also call elf_uninit in this case

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Iddcbae9587d11d3b5b06e876d4a037ac0d11992e
2021-05-12 21:09:29 -07:00
Liio Chen 468e08c1b4 binnfmt:Fix return before close ELF fd
elf_init open a elf file , if both enabled
   CONFIG_NSH_BUIlTAPPS and CONFIG_NSH_FILE_APPS ,
   elf_init will read elf file in /bin directory, but
   that length is zero , elf_read failed return and NOT
   close elf fd, so this line MUST be return to errout_with_init
2021-05-07 06:42:15 -07:00
Byron Ellacott c9db653c8d symtabs: improve handling of symbol lookups
When CONFIG_SYMTAB_ORDEREDBYNAME is selected most code will use
the ordered search function. When it is not selected no code will
use the ordered search function. This change merges the two
functions and varies its behaviour based on the config setting,
such that all callers can simply call the one search function
and get the best behaviour.

An additional configuration option allows leading underscores to
be stripped from symbols being relocated in loaded objects. This
allows toolchains which prefix C symbol with underscores to make
loadable ELF objects.
2021-03-16 10:18:17 -07:00
Abdelatif Guettouche d85c432278 Few typos fixes in binfmt and libc/machine.
Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>
2021-03-11 10:35:40 +08:00
Gustavo Henrique Nihei 330eff36d7 sourcefiles: Fix relative path in file header 2021-03-09 23:18:28 +08:00
Gustavo Henrique Nihei 13535d8725 linkerfiles: Fix relative path in file header 2021-03-09 23:18:28 +08:00
Alin Jerpelea f9fb182809 Author: Gregory Nutt: update licenses to Apache
Update files from Gregory Nutt to Apache 2.0 license.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2021-02-05 12:15:56 -03:00
Alin Jerpelea 789d3751ad binfmt: libnxflat: nxstyle error fix
Fix nxstyle errors to pass CI

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2021-02-05 12:15:56 -03:00
Xiang Xiao 0dc6990166 Fix nxstyle warning
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-01-13 08:57:58 +01:00
Xiang Xiao 0536953ded Kernel module should prefer functions with nx/kmm prefix
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-01-13 08:57:58 +01:00
chao.an c56785bd0d style/Makefile: remove unnecessary trailing whitespace
N/A

Signed-off-by: chao.an <anchao@xiaomi.com>
2020-11-28 12:20:30 +01:00
YAMAMOTO Takashi 85f38b01c1 binfmt/libelf/libelf_dtors.c: Fix a syslog format 2020-11-27 05:18:57 -06:00
YAMAMOTO Takashi 44e61d7fe7 binfmt/libelf/libelf_ctors.c: Fix a syslog format 2020-11-27 05:18:57 -06:00
YAMAMOTO Takashi 78797dc1da binfmt/libnxflat/libnxflat_bind.c: Fix syslog formats 2020-11-25 05:11:26 -08:00
YAMAMOTO Takashi ca2cc5133d binfmt/libnxflat/libnxflat_load.c: Fix syslog formats 2020-11-25 05:11:26 -08:00
YAMAMOTO Takashi b9538bf885 binfmt/libnxflat/libnxflat_load.c: Appease nxstyle 2020-11-25 05:11:26 -08:00
Matias N d5b6ec450f Parallelize depend file generation 2020-11-22 09:02:59 -03:00
YAMAMOTO Takashi d068713738 binfmt/libelf/libelf_symbols.c: Fix syslog formats 2020-11-21 19:38:32 -08:00
YAMAMOTO Takashi 148ee150f0 binfmt/libelf/libelf_bind.c: Fix syslog formats 2020-11-21 19:38:32 -08:00
YAMAMOTO Takashi 48e3e2d390 binfmt/binfmt_dumpmodule.c: Fix syslog format errors 2020-11-20 22:22:53 -08:00
Nathan Hartman 80ce7800a9 Sources and Docs: Fix typos and nxstyle issues
Documentation/contributing/coding_style.rst:

    * Fix repeated words: ("this this").
    * Remove trailing spaces.

boards/z80/z80/z80sim/README.txt:

    * Fix repeated words: ("this this") and rewrap lines.

graphics/Kconfig,
libs/libc/math/Kconfig:

    * Fix repeated words: ("this this").

arch/arm/src/armv7-a/arm_assert.c,
arch/arm/src/armv7-r/arm_assert.c,
arch/arm/src/imxrt/imxrt_enet.c,
arch/arm/src/kinetis/kinetis_enet.c,
arch/arm/src/kinetis/kinetis_flexcan.c,
arch/arm/src/s32k1xx/s32k1xx_enet.c,
arch/arm/src/s32k1xx/s32k1xx_flexcan.c,
arch/arm/src/stm32/stm32_pwm.c,
arch/arm/src/stm32h7/stm32_pwm.c,
arch/arm/src/stm32l4/stm32l4_pwm.c,
arch/renesas/src/rx65n/rx65n_usbdev.c,
binfmt/libnxflat/libnxflat_bind.c,
drivers/pipes/pipe_common.c,
net/igmp/igmp_input.c,
net/tcp/tcp_conn.c,
sched/sched/sched_roundrobin.c:

    * Fix typo in comment ("this this").

arch/arm/src/cxd56xx/cxd56_usbdev.c,
arch/arm/src/lc823450/lc823450_usbdev.c:

    * Fix typo in comment and rewrap lines.

arch/arm/src/imxrt/imxrt_usbdev.c,
arch/arm/src/stm32/stm32_dac.c,
arch/arm/src/stm32f0l0g0/stm32_pwm.c,
arch/arm/src/stm32f7/stm32_pwm.c,
arch/arm/src/tiva/lm/lm4f_gpio.h,
fs/nxffs/nxffs_write.c,
include/nuttx/analog/pga11x.h,
include/nuttx/usb/usbdev.h,
net/mld/mld_join.c:

    * Fix typo in comment ("this this").
    * Fix nxstyle issues.
2020-10-02 04:54:52 +02:00