Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TEST DNM] Test 8216 #8234

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
1bd9e95
logger: open /sys/debug/fw_version _after_ /sys/debug/[e]trace
marc-hb Nov 25, 2021
34be370
logger: allow starting before the driver is loaded
marc-hb Nov 25, 2021
78f24c0
sof-logger: make inotify optional
marc-hb Aug 25, 2022
bbe1dca
sof-logger: exit with error if malloc fails
kv2019i Dec 19, 2022
f9a1aae
logger: exit with error if calloc fails
kv2019i Dec 19, 2022
c82d7db
sof-logger: print error if -u uart option is given with no infile
kv2019i Dec 19, 2022
3671e6a
logger: make "global_config" truly global
marc-hb Dec 20, 2022
8ac1e15
logger: convert.c: move global_config->logs_header to the heap
marc-hb Dec 20, 2022
8b5def3
logger: check localtime() return value
lyakh Dec 20, 2022
ace183c
sof-logger: ensure NULL string is not passed to printf/fprintf
kv2019i Dec 21, 2022
9aad8bc
smex: elf: Removed unnecessary initialization of local variables
softwarecki Sep 18, 2023
b9911e6
smex: elf: Added checking of value returned by file operation function
softwarecki Sep 18, 2023
d93e32f
smex: elf: elf_find_section: Check function input data
softwarecki Sep 18, 2023
f4f4325
logger: convert: Fixed handling of an error reported by clock_gettime
softwarecki Sep 18, 2023
e2fcd55
logger: convert: Added error handling for file operation functions.
softwarecki Sep 18, 2023
b024938
logger: convert: Simplified printing of a timestamp
softwarecki Sep 18, 2023
0f95a39
logger: convert: read_entry_from_ldc_file: Make sure string null term…
softwarecki Sep 18, 2023
db43d77
logger: convert: Code quality improvements
softwarecki Sep 18, 2023
b36b94e
tools: logger: Use a safe variant of the string manipulation functions
softwarecki Sep 18, 2023
fbb4eed
tools: logger: Fix resources release
softwarecki Sep 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 27 additions & 12 deletions smex/elf.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
static int elf_read_sections(struct elf_module *module, bool verbose)
{
Elf32_Ehdr *hdr = &module->hdr;
Elf32_Shdr *section = module->section;
Elf32_Shdr *section;
size_t count;
int i, ret;
uint32_t valid = (SHF_WRITE | SHF_ALLOC | SHF_EXECINSTR);
Expand Down Expand Up @@ -128,7 +128,7 @@ static int elf_read_sections(struct elf_module *module, bool verbose)
static int elf_read_programs(struct elf_module *module, bool verbose)
{
Elf32_Ehdr *hdr = &module->hdr;
Elf32_Phdr *prg = module->prg;
Elf32_Phdr *prg;
size_t count;
int i, ret;

Expand Down Expand Up @@ -408,10 +408,17 @@ int elf_find_section(const struct elf_module *module, const char *name)
ret = -errno;
goto out;
}
buffer[section->size - 1] = '\0';

/* find section with name */
for (i = 0; i < hdr->shnum; i++) {
s = &module->section[i];
if (s->name >= section->size) {
fprintf(stderr, "error: invalid section name string index %d\n", s->name);
ret = -EINVAL;
goto out;
}

if (!strcmp(name, buffer + s->name)) {
ret = i;
goto out;
Expand All @@ -431,8 +438,8 @@ int elf_read_section(const struct elf_module *module, const char *section_name,
const Elf32_Shdr **dst_section, void **dst_buff)
{
const Elf32_Shdr *section;
int section_index = -1;
int read;
int section_index;
int ret;

section_index = elf_find_section(module, section_name);
if (section_index < 0) {
Expand All @@ -451,17 +458,25 @@ int elf_read_section(const struct elf_module *module, const char *section_name,
return -ENOMEM;

/* fill buffer with section content */
fseek(module->fd, section->off, SEEK_SET);
read = fread(*dst_buff, 1, section->size, module->fd);
if (read != section->size) {
fprintf(stderr,
"error: can't read %s section %d\n", section_name,
-errno);
free(*dst_buff);
return -errno;
ret = fseek(module->fd, section->off, SEEK_SET);
if (ret) {
fprintf(stderr, "error: can't seek to %s section %d\n", section_name, -errno);
ret = -errno;
goto error;
}

ret = fread(*dst_buff, 1, section->size, module->fd);
if (ret != section->size) {
fprintf(stderr, "error: can't read %s section %d\n", section_name, -errno);
ret = -errno;
goto error;
}

return section->size;

error:
free(*dst_buff);
return ret;
}

int elf_read_module(struct elf_module *module, const char *name, bool verbose)
Expand Down
8 changes: 8 additions & 0 deletions tools/logger/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# SPDX-License-Identifier: BSD-3-Clause

# https://gitlab.kitware.com/cmake/community/-/wikis/doc/tutorials/How-To-Write-Platform-Checks
INCLUDE (CheckIncludeFiles)
CHECK_INCLUDE_FILES(sys/inotify.h HAS_INOTIFY)

CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
${CMAKE_CURRENT_BINARY_DIR}/config.h)
include_directories(${CMAKE_CURRENT_BINARY_DIR})

add_executable(sof-logger
logger.c
convert.c
Expand Down
1 change: 1 addition & 0 deletions tools/logger/config.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#cmakedefine01 HAS_INOTIFY
Loading
Loading