Commit Graph

11 Commits

Author SHA1 Message Date
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 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
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 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
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