Commit Graph

891 Commits

Author SHA1 Message Date
Xiang Xiao
dde25b0f80 tools/nxstyle: Fix AddressSanitizer error
=================================================================
==2474==ERROR: AddressSanitizer: stack-buffer-underflow on address 0x7fffb7e59b5f at pc 0x561fffec79f6 bp 0x7fffb7e59ac0 sp 0x7fffb7e59ab0
READ of size 1 at 0x7fffb7e59b5f thread T0
    #0 0x561fffec79f5 in block_comment_width /home/xiaoxiang/mirtos/nuttx/tools/nxstyle.c:355

Address 0x7fffb7e59b5f is located in stack of thread T0 at offset 31 in frame
    #0 0x561fffec7b90 in get_line_width /home/xiaoxiang/mirtos/nuttx/tools/nxstyle.c:419

  This frame has 1 object(s):
    [32, 544) 'line' (line 420) <== Memory access at offset 31 underflows this variable
HINT: this may be a false positive if your program uses some custom stack unwind mechanism, swapcontext or vfork
      (longjmp and C++ exceptions *are* supported)
SUMMARY: AddressSanitizer: stack-buffer-underflow /home/xiaoxiang/mirtos/nuttx/tools/nxstyle.c:355 in block_comment_width
Shadow bytes around the buggy address:
  0x100076fc3310: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x100076fc3320: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x100076fc3330: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x100076fc3340: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x100076fc3350: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x100076fc3360: 00 00 00 00 00 00 00 00 f1 f1 f1[f1]00 00 00 00
  0x100076fc3370: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x100076fc3380: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x100076fc3390: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x100076fc33a0: 00 00 00 00 00 00 00 00 00 00 00 00 f3 f3 f3 f3
  0x100076fc33b0: f3 f3 f3 f3 00 00 00 00 00 00 00 00 00 00 00 00
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
  Shadow gap:              cc
==2474==ABORTING

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Ie7dee3cdfdbbd04ea9cdb58e227afef07073cecd
2020-06-16 09:56:22 -06:00
Brennan Ashton
0430c6ccc8 Add problem matching for gcc and nxstyle to github actions 2020-06-11 00:52:55 +08:00
YAMAMOTO Takashi
44585eeaf8 mkdeps: Use %zu/%zd printf format instead of casts 2020-06-03 18:30:36 +08:00
YAMAMOTO Takashi
16884407eb mkdeps: Quote CFLAGS to be safe with the shell
mkdeps uses system() thus a shell to execute cc.
it doesn't work if you have something like

    CFLAGS   += -DMBEDTLS_USER_CONFIG_FILE="<mbedtls/user_config.h>"

because the shell interprets "<" as a redirect.

to fix it, we should do either

    * make it shell-quote arguments

    * or, stop using system()

this commit implements the former.

some platforms provide easy ways to do the former.
eg. https://netbsd.gw.com/cgi-bin/man-cgi?shquote++NetBSD-current
but unfortunately none of them seems available widely.

i guess the latter approach is more common.
eg. 4464250282/usr.bin/mkdep/mkdep.c (L137-L154)
but i might be a burden for windows. (i don't know)
2020-06-03 18:30:36 +08:00
Gregory Nutt
0da3400009 ez80: Fix ez80 build problems.
arch/z80/src/Makefile:  Correct inclusion of non-existent file.  This was not a problem before because there was '-' before the include.  Problem revealed with '-' removed.

arch/z80/src/ez80/Toolchain.defs:  Apparently there are not too many '"' in path definition.

tools/incdir.c:  No space between -usrinc:  or -sysinc:  and the list of paths.
2020-06-02 13:20:51 -03:00
Gregory Nutt
18e4ab99cb Makefile: Build the tools/incdir binary immediately.
Before any other Make logic can be used, we must immediately build the tools/incdir binary.  It will be used as soon as Make.defs is included and will generate errors otherwise.

Remove the other locations in the tools/incdir binary was being build from tools/Makefile.unix and tools/Makefile.win
2020-05-31 15:05:23 +01:00
Ouss4
e018309e47 tools/Makefile*: Clean tools binaries at the end of distclean. 2020-05-31 15:05:23 +01:00
Gregory Nutt
e92c91cf09 tools/incdir.c: Various fixes to get a clean build
1. If config.c is compiled on any platform other than Cygwin, then the variable wintools is not used.
2. Add more debug output so we can see what is going on in the PR checks.
2020-05-30 01:05:34 +01:00
Gregory Nutt
5555070fc3 tools/: Hook incdir.c into build system.
incdir.c was added in PR 1148.  This PR hooks it into the build system.
2020-05-30 01:05:34 +01:00
Gregory Nutt
981734e577 tools/Makefile.host: Add incdir binary to Makefile.host
This was missed in PR 1148
2020-05-30 01:05:34 +01:00
Gregory Nutt
b111e135e0 tools/incdir.c: Add faster, C version of incdir.sh 2020-05-29 17:16:42 -03:00
liuhaitao
102c4c25e2 tools/testbuild.sh: Call makefunc with JOPTION directly
Also call configure.sh with JOPTION to enable parallel build

Change-Id: I32c4e77fb30c40d8d424159cc0871b8c3e3f10b6
Signed-off-by: liuhaitao <liuhaitao@xiaomi.com>
2020-05-28 20:01:45 +08:00
liuhaitao
b5dc83748c build: Update make dependency to enable 'configure.sh config' parallel build
Note that 'configure.sh config -jn' with parallel build could reduce configure stage
time.

Change-Id: I3d63f1e316a7bc3437fc6c6c2da13c5313e69694
Signed-off-by: liuhaitao <liuhaitao@xiaomi.com>
2020-05-28 20:01:45 +08:00
liuhaitao
954d251dfe build: make sure nuttx bins generated after both pass1 and pass2 built done
Create the final NuttX executables after pass1 user libs and pass2 nuttx
libs built finished.

Signed-off-by: liuhaitao <liuhaitao@xiaomi.com>
2020-05-27 06:28:05 -06:00
liuhaitao
6a9b3de0bb tools/testbuild.sh: fix testbuild.sh called without -e option fail issue
As in https://github.com/apache/incubator-nuttx/issues/1114 discuss, let
EXTRA_FLAGS="EXTRAFLAGS=" defaultly to avoid testbuild.sh called without
-e option fail issue. It also works well with -e "-Wno-cpp -Werror".

Signed-off-by: liuhaitao <liuhaitao@xiaomi.com>
2020-05-26 07:03:21 -06:00
liuhaitao
56e7a906e5 build: exit normaly once catch 'make depend' and 'make context' failure case
To be strict in check build, once any 'make depend' or 'make context' fails, exit normally.

Signed-off-by: liuhaitao <liuhaitao@xiaomi.com>
2020-05-26 15:39:34 +08:00
Xiang Xiao
8b20b97d26 build: Remove the dummy drivers folder under boards
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-05-24 20:20:12 +01:00
Xiang Xiao
e83c1400b6 build: Move BOARD_DIR definition to common place
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-05-24 20:20:12 +01:00
Xiang Xiao
7e5b0f81e9 build: Replace -I with INCDIR
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-05-24 20:20:12 +01:00
Xiang Xiao
dd61d3d9f9 build: Remve the unnecessary .gitignore
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-05-23 18:00:40 +01:00
Xiang Xiao
02e028a595 tools/mkdeps: Fix the nxstyle problem
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-05-23 09:27:36 -06:00
Xiang Xiao
d2bb9bf2b4 tools/mkdeps: Always look in the current directory
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-05-23 09:27:36 -06:00
Xiang Xiao
2a2ffe41dd build: incdir.sh shouldn't check whether the path exist
since compiler never complain that the path(by -I) doesn't exist

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-05-23 09:27:15 -06:00
liuhaitao
adc0c3e459 build: parallel clean and distclean subdir build
Use absolute path for APPDIR which could be used by apps clean
and distclean subdir build. Parallel clean and distclean subdir
could save more build time.

Signed-off-by: liuhaitao <liuhaitao@xiaomi.com>
2020-05-22 12:35:46 +01:00
Xiang Xiao
1a95cce1a3 build: Move .config check to the top Makefile
remove the workaround to handle the inexistence of .config/Make.defs

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-05-20 17:57:34 +01:00
Gregory Nutt
3b62765edd nxstyle: Fix distinction be source and header file for long lines.
For some unknow reason, long lines were reported as WARNING is header files, but as ERRORS in C source file.  There are errors where ever they occur.
2020-05-19 20:09:57 -04:00
YAMAMOTO Takashi
48da64f9c2 Redo "Fix make target dependencies"
Change-Id: I7180145d90913fd3acc94487b9f7b9753dcdc8da
Signed-off-by: liuhaitao <liuhaitao@xiaomi.com>
2020-05-19 19:23:54 +01:00
Xiang Xiao
7faf3c0254 build: replace ${TOPDIR} with $(TOPDIR) in Makefile
make the usage consistence

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-05-19 19:23:18 +01:00
Xiang Xiao
567962bd62 build: Move the extension definition to common place
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-05-19 19:23:18 +01:00
Xiang Xiao
5e7342bcf4 build: Move V definition to common place
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-05-19 19:23:18 +01:00
Xiang Xiao
8b42ee421a build: Move MKDEP definition to common place
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-05-19 19:23:18 +01:00
Xiang Xiao
9ec9431706 build: Move DIRLINK/DIRUNLINK definition to common place
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-05-19 19:23:18 +01:00
Xiang Xiao
6e94effeed build: Make all variables inside Configs.mk overwritable
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-05-19 19:23:18 +01:00
Xiang Xiao
6c4ef7b1db build: mkexport.sh copy Config.mk to tools folder too
to avoid the duplication in apps/imports/Make.defs

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-05-18 21:36:58 -06:00
Nathan Hartman
3334b40aef nxstyle: Allow Hz, KHz, GHz in identifiers
Per the coding standard, we allow MHz as one of the few allowed
exceptions to the identifier case rules.

However, because this exception specifically looked for "MHz" we
would generate undeserved nxstyle errors for Hz, KHz, GHz.

This change adds recognition of any Hz value by eliminating the
requirement for Hz to be preceded by M.

tools/nxstyle.c:

    * main(): Eliminate requirement for Hz to be preceded by M to
      match the rule for allowed mixed case identifier. Update
      relevant comments.

See:
https://cwiki.apache.org/confluence/display/NUTTX/Coding+Standard#macros

Mailing list discussion archived at:
https://lists.apache.org/thread.html/r481b9d145f439c24c8d70992081bf670bc0e893167149e0017519439%40%3Cdev.nuttx.apache.org%3E
2020-05-18 18:00:10 -06:00
Xiang Xiao
5eae32577e build: Move INCDIROPT to common place
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-05-18 15:02:55 -06:00
Xiang Xiao
bd656888f2 build: Replace WINTOOL with CYGWIN_WINTOOL Kconfig
so the correct value can be determinated by Kconfig system automatically

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-05-18 15:02:55 -06:00
Xiang Xiao
3f83d2da30 tools/refresh.sh: replace cmpconfig with diff
since we want to catch the order difference too

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-05-11 12:24:58 -06:00
Xiang Xiao
b4dceaa88c tools/refresh.sh: shouldn't redirect "make oldconfig" to /dev/null
since kconfig need interact with user to make the selection

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-05-11 12:24:58 -06:00
Xiang Xiao
a6c82a27db tools/mksyscall: Unify the fixed and variable arguments process
Signed-off-by: Xiang Xiao <iaoxiang@xiaomi.com>
2020-05-08 10:38:05 -06:00
Xiang Xiao
e7e81dd74d tools/LibTargets.mk: Remove # from the action of syscall
this typo error make libstub.a is compiled without __KERNEL__

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-05-08 10:38:05 -06:00
liuhaitao
2c9f91205f tools/pic32: update pic32 scripts to fix jobserver unavailable warning
Always build mkpichex to make sure it newest, also correct target name.

Signed-off-by: liuhaitao <liuhaitao@xiaomi.com>
2020-05-07 11:19:25 -03:00
Gregory Nutt
6906853f8e Improve proxy/stub parameter passing for variadic OS interfaces.
In the past a very low effort interface was used:

- All parmeters were treated as though they were type uinptr_t, and
- The maximum number of parmeters (6) was passed in all cases.

The first is potentially wrong and the second is very inefficient.  This commit improves this by:

- Making tools/mksyscall.c more intelligent, and
- Extending the syntax for variadic functions.

For example, in syscall.cvs, the open() API was represened like this:

    "open","fcntl.h","","int","const char*","int","..."

In reality, open may take only a single optional argument of type mode_t which is not the same size as uintptr_t.  And there is not reason to pass 6 parameters in that case.

And this has been extended to:

    "open","fcntl.h","","int","const char*","int","...","mode_t"

The existence of the "mode_t" tells tools/mksyscall that there is at most one optional parameter and, if present, it is of type mode_t.
2020-05-06 01:00:43 +01:00
YAMAMOTO Takashi
19cc84ed4a sim: Suppress no symbol warnings for macOS 2020-05-05 21:40:16 +08:00
Xiang Xiao
a2f657e4cb build: Move KDEFINE to a common place(tools/Config.mk)
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-05-01 15:56:55 -06:00
Xiang Xiao
4b1dab84d1 tools/LibTargets.mk: Pass EXTRAFLAGS to all sub make
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-05-01 15:56:55 -06:00
Xiang Xiao
f2aba8d9b7 build: Remove 'u' prefix from userspace library
so user needn't link the different library because the build type change

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-05-01 15:56:55 -06:00
Xiang Xiao
eca7059785 Refine __KERNEL__ and CONFIG_BUILD_xxx usage in the code base
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-05-01 10:43:47 -03:00
liuhaitao
6b4cc3011c Remove the residual files in distclean
Signed-off-by: liuhaitao <liuhaitao@xiaomi.com>
2020-05-01 04:43:15 +01:00
liuhaitao
97afe1c402 tools/refresh.sh: restore BOARD_DIR when refresh with a different host
There is case as below:
When do testbuild under Linux host, such as './tools/configure.sh stmf4discovery:nsh',
arch/arm/src/board is a symlink to boards/arm/stm32/stm32f3discovery/src. Then do
'./tools/refresh.sh --silent stmf4discovery:nsh' after build, it would break the board
symlink with copydir.sh instead of link.sh since defconfig with Windows host config.
So call sethost.sh to restore BOARD_DIR. Or it results in 'make distclean' not correctly.

Signed-off-by: liuhaitao <liuhaitao@xiaomi.com>
2020-04-28 21:28:15 -07:00