Commit Graph

26 Commits

Author SHA1 Message Date
Marc Herbert dc9058365e smex/CMakeLists.txt: drop bogus, non-portable -Wl,-EL binutils option
This option was added by initial commit 36929ae1b7 ("smex: Create new
tool to build ldc file") without any justification. It has been causing
countless portability issues, see previous commit for examples. It makes
even less sense for a build-time utility. Get rid of it.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2024-08-09 13:03:46 +03:00
Adrian Bonislawski 63f958e90c smex: elf: fixed error handling from file operation
Fixes commit #e5f337ba70a5

Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
2023-12-11 17:03:31 +02:00
Adrian Bonislawski c1bd155f43 smex: ldc: check fwrite status
Check fwrite status for error

Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
2023-12-11 17:03:31 +02:00
Adrian Bonislawski c0092bbf7a smex: elf: find_section: check section ptr
Validate section ptr

Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
2023-12-11 17:03:31 +02:00
Adrian Bonislawski 7501b2e094 smex: elf: remove unnecessary module double free
read module function should only read module,
additional free operation could result in double free scenario

Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
2023-12-11 17:03:31 +02:00
Marc Herbert 157457c127 Switch smex and sof-logger to new sof/tools/rimage location
Switch away from the independent rimage submodule. Long story in
https://github.com/thesofproject/sof/issues/8178 and others.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2023-10-09 13:06:12 -07:00
Adrian Warecki 5c016bc9e7 smex: elf: elf_find_section: Check function input data
String terminator was added to the buffer with a list of section names
in the elf file. Added check to the section name index to make sure it
doesn't go beyond the buffer size.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
2023-09-26 09:20:03 +01:00
Adrian Warecki e5f337ba70 smex: elf: Fixed an error code returned when a file operation fails
If fseek reports an error, the error code set in errno is returned.
Improved handling an error during reading from a file. Now it distinguishes
between an error reported by the fread and insufficient data in a file.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
2023-09-26 09:20:03 +01:00
Adrian Warecki 71418367e7 smex: elf: Added checking of value returned by file operation function
Added checking of the value returned by fseek function and added memory
release when an error is detected.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
2023-09-26 09:20:03 +01:00
Adrian Warecki 877079af47 smex: elf: Removed unnecessary initialization of local variables
The values assigned when declaring variables were overwritten in the code.
Redundant initialization was removed.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
2023-09-26 09:20:03 +01:00
Marc Herbert ee58fef921 smex/cmake: move -Wl,EL option to target_linker_options() for clang
-Wl,EL is a linker option, not a compiler option and clang does not
like it at compilation time; it fails like this:
```
cd smex
cmake -B build -DCMAKE_C_COMPILER=clang
make -C build

clang-15: error: -Wl,-EL: 'linker' input unused
          [-Werror,-Wunused-command-line-argument]
```

Reported by @andyross in https://github.com/google/oss-fuzz/pull/10342

oss-fuzz does not need smex at all but this one-line fix is just
faster and simpler than a bigger CMake re-architecture just for
oss-fuzz.

Also simplify this for clang compatibility:
```
error: unknown warning option '-Wimplicit-fallthrough=3'; did you mean
     '-Wimplicit-fallthrough'? [-Werror,-Wunknown-warning-option]
```

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2023-05-22 15:06:41 +03:00
Liam Girdwood 1629a1f72c header: rtos: decouple headers into rtos specific directories.
No functional runtime change, but changes to rtos partitioning and the
layout of headers .

This patch creates RTOS specifc header paths and updates spinlock.h
and kernel.h to show the new usage. Other headers will incrementally follow.
It reuses the current zephyr topleve directory and creates a new
toplevel xtos directory for xtos specific files.

Due to the mixing of RTOS, driver and library headers at the top level include
directory it was necessary to create rtos specific header directories i.e.

src/include/rtos-xtos
src/include/rtos-zephyr

These RTOS include directories will eventually contain RTOS specific headers
whilst common logic and structures will be placed in non RTOS directories.

This will also mean

"#include <sof/spinlock.h>"

will become

"#include <rtos/spinlock.h>"

and will allow easier visualisation of where and why RTOS headers are being used.
This will help to eliminate cross usage of headers between RTOSes.

Subsequqnt patches will move more headers and rtos specific wrppaer
source files into rtos specific locations.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
2022-08-31 12:01:07 +01:00
Curtis Malainey a0acad3414 CMake: require version 3.13
Without CMP0079 we cannot conditionally include libraries against SOF in
sub directories without seriously restructuring the project. This is
because the old policy requires the link target must be created in the
same folder. This does not work well from a configuration standpoint for
3P audio libraries trying to keep their config in src/audio/*. Rather
than enable the policy, lets simply upgrade since 3.13 is widely
available.

With this upgrade we can also remove the two version dependent checks at
the top of our scripts.

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
2021-09-10 17:19:29 +01:00
Marc Herbert 16817f413e smex/ldc.h: stop including rimage/sof/kernel/fw.h
If the -Werr build does not fail then it's not needed.

The very first `#include fw.h` in `smex/ldc.h` was added in April 2020
in giant commit 36929ae1b7 ("smex: Create new tool to build ldc
file") so there is no trace of why that `fw.h` dependency was ever
needed.

Because `fw.h` was then moved to rimage, this is indirectly making the
entire `tools/` directory depending on `rimage` - fixed in the next
commit.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-08-24 13:22:47 +03:00
Marc Herbert 236dc0d74a smex: change usage() to exit with an error
It is admittedly not an error to use '-h' but who uses '-h' and cares
about the exit code?

Conversely, it is _very_ important to return an error when a bug in a
script passes wrong arguments to smex.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-07-13 15:56:49 +01:00
Marc Herbert ef03e727db smex: un-hardcode "-O2 -g", use CMAKE_BUILD_TYPE, default to Debug
Anyone having a performance issue can use the standard
-DCMAKE_BUILD_TYPE=Release. Crashes seem more common.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-07-06 13:18:46 +01:00
Marc Herbert 46ddb38159 smex: use strerror()
Before:

  error: unable to open sof.elf for reading: 2

After:

  error: unable to open sof.elf for reading: No such file or directory

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-07-06 13:18:46 +01:00
Marc Herbert 53ebd8abd0 smex: fix crash in elf_free_module() when input file not found
fclose() seems to require a valid argument.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-07-06 13:18:46 +01:00
Marc Herbert 964b7afa74 smex: don't corrupt the build with a bogus .ldc output
This made troubleshooting CMake issues more complicated.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-05-18 16:46:44 +01:00
Marc Herbert e3c68211c7 smex: log versions with a dot (3.18.1) instead of a colon (3:18:1)
Logging versions like "3:18:1" deceive Emacs (and maybe others) because
they look like an error location produced by a compiler. When compiling
Emacs wrongly believes this an error location and offers to jump to it.

The colon ':' is also a reserved character in most filesystems and an
unusual version separator.

Before:

fw abi main version:	3:18:1
fw abi main version:	3:18:1

After:

fw abi main version:	3.18.1
fw abi main version:	3.18.1

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-04-13 21:26:24 +01:00
Liam Girdwood 0f2c9d1230 cleanup: remove double blanks lines.
Several files had multiple blank lines even before the removal of
platform_shared_commit(). Fix them with "cat -s"

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
2021-04-12 16:58:51 +01:00
Karol Trzcinski f97e9f0de6 ipc: Remove user_abi_version from mailbox
This information is already provided by extended manifest,
so there is no need to double it in runtime code.
It allows to save 16 bytes from .DATA and 128 bytes from .TEXT
for cnl platform.
`data_structs` library from src/ipc/CMakeLists.txt is no longer
needed. Moreover empty library may lead to cmake fail.
SMEX needs little update, to read DBG_ABI from .fw_metadata section
instead of .fw_ready.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-10-12 11:41:11 +01:00
Karol Trzcinski bebdbca87b rimage: Update to version with changed headers location
In new version of rimage software, headers are located in
rimage/src/include/rimage directory to make it easily accessible
from another source code without include path collision.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-05-29 11:15:22 +01:00
Daniel Leung f6f748b89f cmake: use fw.h and manifest.h from rimage/
Since both fw.h and manifest.h are being used in the main SOF
repo, and also the standalone rimage repo, to prevent them
getting out of sync, use the ones coming from the rimage repo
instead.

Also, git submodule update is being executed when cmake is
run so there is no need to update when building rimage.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2020-05-13 10:16:04 +01:00
Karol Trzcinski 7633c34224 smex: Add elf modules content validation
After find some error in source elf file, ldc file shouldn't
be generated

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-04-03 16:27:04 +01:00
Karol Trzcinski 36929ae1b7 smex: Create new tool to build ldc file
SMEX (*SOF Metadata EXtractor*) is a tool used to extract needed
information from SOF source code and output files and then save
them in convenient form like logs dictionary file (*ldc*).

After full integration of SMEX with SOF build system,
rImage with no sof specific ldc generator code can be moved
outside as a common external tool.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-04-03 16:27:04 +01:00