From 935a55d69119650fde007caa494ee2a1c534fc52 Mon Sep 17 00:00:00 2001 From: Avi Date: Sat, 12 Nov 2022 11:57:49 +1000 Subject: [PATCH 1/5] Fix #86, Check return from chmod --- elf2cfetbl.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/elf2cfetbl.c b/elf2cfetbl.c index 5e8d813..ce3a81c 100644 --- a/elf2cfetbl.c +++ b/elf2cfetbl.c @@ -1436,6 +1436,7 @@ int32 OpenSrcFile(void) int32 OpenDstFile(void) { struct stat dststat; + int32 Status = SUCCESS; /* Check to see if output file can be opened and written */ DstFileDesc = fopen(DstFilename, "w"); @@ -1451,7 +1452,15 @@ int32 OpenDstFile(void) { if (Verbose) printf("%s: Destination file permissions after open = 0x%X\n", DstFilename, dststat.st_mode); - chmod(DstFilename, dststat.st_mode & ~(S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH)); + + Status = chmod(DstFilename, dststat.st_mode & ~(S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH)); + + if (Status != 0) + { + printf("%s: Error while attempting to modify file permissions\n", DstFilename); + return FAILED; + } + stat(DstFilename, &dststat); if (Verbose) printf("%s: Destination file permissions after chmod = 0x%X\n", DstFilename, dststat.st_mode); From 836486f40e32b63fb52c50a0c117b44d66728f1b Mon Sep 17 00:00:00 2001 From: Avi Date: Sat, 12 Nov 2022 19:38:42 +1000 Subject: [PATCH 2/5] Fix #87, Check return value of stat --- elf2cfetbl.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/elf2cfetbl.c b/elf2cfetbl.c index 5e8d813..3fa13f7 100644 --- a/elf2cfetbl.c +++ b/elf2cfetbl.c @@ -1452,7 +1452,12 @@ int32 OpenDstFile(void) if (Verbose) printf("%s: Destination file permissions after open = 0x%X\n", DstFilename, dststat.st_mode); chmod(DstFilename, dststat.st_mode & ~(S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH)); - stat(DstFilename, &dststat); + + if (stat(DstFilename, &dststat) != 0) + { + printf("%s: Error retrieving file status after chmod\n", DstFilename); + } + if (Verbose) printf("%s: Destination file permissions after chmod = 0x%X\n", DstFilename, dststat.st_mode); } From 8e1df145129752f96e81dc657f32d2a059939c7f Mon Sep 17 00:00:00 2001 From: Avi Date: Tue, 15 Nov 2022 16:16:49 +1000 Subject: [PATCH 3/5] Fix #126, Move variables declared mid-function to the top --- elf2cfetbl.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/elf2cfetbl.c b/elf2cfetbl.c index 5e8d813..51d1408 100644 --- a/elf2cfetbl.c +++ b/elf2cfetbl.c @@ -2256,9 +2256,10 @@ int32 GetStringFromMap(char *Result, ElfStrMap *Map, int32 Key) int32 GetTblDefInfo(void) { - int32 Status = SUCCESS; - uint32 SeekOffset = 0; - int32 NumDefsRead = 0; + int32 Status = SUCCESS; + uint32 SeekOffset = 0; + int32 NumDefsRead = 0; + uint64_t calculated_offset; /* Read the data to be used to format the CFE File and Table Headers */ if ((get_st_size(SymbolPtrs[TblDefSymbolIndex]) != sizeof(CFE_TBL_FileDef_t)) && @@ -2271,8 +2272,8 @@ int32 GetTblDefInfo(void) else { /* fseek expects a long int, sh_offset and st_value are uint64 for elf64 */ - uint64_t calculated_offset = get_sh_offset(SectionHeaderPtrs[get_st_shndx(SymbolPtrs[TblDefSymbolIndex])]) + - get_st_value(SymbolPtrs[TblDefSymbolIndex]); + calculated_offset = get_sh_offset(SectionHeaderPtrs[get_st_shndx(SymbolPtrs[TblDefSymbolIndex])]) + + get_st_value(SymbolPtrs[TblDefSymbolIndex]); SeekOffset = (uint32_t)(calculated_offset); if (SeekOffset != calculated_offset) { @@ -2327,11 +2328,12 @@ int32 GetTblDefInfo(void) int32 LocateAndReadUserObject(void) { - int32 Status = SUCCESS; - int32 i = 0; - int32 j = 0; - uint32 SeekOffset = 0; - uint8 AByte; + int32 Status = SUCCESS; + int32 i = 0; + int32 j = 0; + uint32 SeekOffset = 0; + uint8 AByte; + uint64_t calculated_offset; /* Search the symbol table for the user defined object */ if (Verbose) @@ -2424,9 +2426,8 @@ int32 LocateAndReadUserObject(void) else { /* Locate data associated with symbol */ - uint64_t calculated_offset = - get_sh_offset(SectionHeaderPtrs[get_st_shndx(SymbolPtrs[UserObjSymbolIndex])]) + - get_st_value(SymbolPtrs[UserObjSymbolIndex]); + calculated_offset = get_sh_offset(SectionHeaderPtrs[get_st_shndx(SymbolPtrs[UserObjSymbolIndex])]) + + get_st_value(SymbolPtrs[UserObjSymbolIndex]); SeekOffset = (uint32_t)(calculated_offset); if (SeekOffset != calculated_offset) { From b8a3219509f6e8a3dd227d04b4d03abd027b1b94 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Wed, 8 May 2024 10:58:27 -0400 Subject: [PATCH 4/5] Fix #146, Include PRID and SCID in table files Propagate the value from the CMake scripts into the generated tbl files. This utilizes existing command line options on elf2cfetbl, just passing the values through via the scripts. --- scripts/add_cfe_tables_impl.cmake | 16 ++++++++++++++++ scripts/table_rule_template.d.in | 2 ++ scripts/tabletool_rule.mk | 2 +- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/scripts/add_cfe_tables_impl.cmake b/scripts/add_cfe_tables_impl.cmake index 845e203..713bd14 100644 --- a/scripts/add_cfe_tables_impl.cmake +++ b/scripts/add_cfe_tables_impl.cmake @@ -32,8 +32,24 @@ function(do_add_cfe_tables_impl TABLE_FQNAME) set(TABLE_GENSCRIPT "${CFS_TABLETOOL_SCRIPT_DIR}/generate_elf_table_rules.cmake") set(TABLE_LIBNAME "tblobj_${ADDTBL_ARG_TARGET_NAME}_${TABLE_FQNAME}") + # determine processor ID and spacecraft ID to use for table. + # If these are not defined, pass 0 instead of a blank (elf2cfetbl will error on non-integer) + if (DEFINED ${ADDTBL_ARG_TARGET_NAME}_PROCESSORID) + set(TABLE_PRID ${${ADDTBL_ARG_TARGET_NAME}_PROCESSORID}) + else() + set(TABLE_PRID 0) + endif() + + if (DEFINED SPACECRAFT_ID) + set(TABLE_SCID ${SPACECRAFT_ID}) + else() + set(TABLE_SCID 0) + endif() + set(TABLE_CMD_OPTS -DTEMPLATE_FILE="${TEMPLATE_FILE}" + -DTARGET_SCID="${TABLE_SCID}" + -DTARGET_PRID="${TABLE_PRID}" -DAPP_NAME="${ADDTBL_ARG_APP_NAME}" -DTARGET_NAME="${ADDTBL_ARG_TARGET_NAME}" -DARCHIVE_FILE="\"$\"" diff --git a/scripts/table_rule_template.d.in b/scripts/table_rule_template.d.in index 4fa6648..e3c70af 100644 --- a/scripts/table_rule_template.d.in +++ b/scripts/table_rule_template.d.in @@ -2,6 +2,8 @@ cfetables: ${TABLE_BINARY} +${TABLE_BINARY}: CFE_TABLE_SCID := ${TARGET_SCID} +${TABLE_BINARY}: CFE_TABLE_PRID := ${TARGET_PRID} ${TABLE_BINARY}: CFE_TABLE_CPUNAME := ${TARGET_NAME} ${TABLE_BINARY}: CFE_TABLE_APPNAME := ${APP_NAME} ${TABLE_BINARY}: CFE_TABLE_BASENAME := ${TABLE_NAME} diff --git a/scripts/tabletool_rule.mk b/scripts/tabletool_rule.mk index 6b34c75..691b985 100644 --- a/scripts/tabletool_rule.mk +++ b/scripts/tabletool_rule.mk @@ -12,4 +12,4 @@ cfetables: # As a workaround, $CURDIR is used. staging/%.tbl: @mkdir -pv "$(dir $(@))" - cd "$(dir $(@))" && $(TBLTOOL) $(TBLTOOL_FLAGS) "$(CURDIR)/$(<)" + cd "$(dir $(@))" && $(TBLTOOL) -p$(CFE_TABLE_PRID) -s$(CFE_TABLE_SCID) "$(CURDIR)/$(<)" From 355c619c7abefade1f85dc332c23118d0e948e91 Mon Sep 17 00:00:00 2001 From: Dylan Date: Tue, 2 Jul 2024 08:53:12 -0400 Subject: [PATCH 5/5] Updating documentation and version numbers for equuleus-rc1+dev22 --- CHANGELOG.md | 7 +++++++ elf2cfetbl_version.h | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5cab31c..79ddf8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## Development Build: equuleus-rc1+dev22 +- Include PRID and SCID in table files +- Check return from chmod +- Check return value of stat() +- Move variables declared mid-function to the top +- See , , , and + ## Development Build: equuleus-rc1+dev10 - updating ELF2CFETBL to use new versioning system - move scripts for table building to elf2cfetbl tool diff --git a/elf2cfetbl_version.h b/elf2cfetbl_version.h index fa0dca3..5e2b90e 100644 --- a/elf2cfetbl_version.h +++ b/elf2cfetbl_version.h @@ -28,7 +28,7 @@ /* * Development Build Macro Definitions */ -#define ELF2CFETBL_BUILD_NUMBER 10 /*!< @brief Number of commits since baseline */ +#define ELF2CFETBL_BUILD_NUMBER 22 /*!< @brief Number of commits since baseline */ #define ELF2CFETBL_BUILD_BASELINE "equuleues-rc1" /*!< @brief Development Build: git tag that is the base for the current */ #define ELF2CFETBL_BUILD_DEV_CYCLE "equuleus-rc2" /**< @brief Development: Release name for current development cycle */ #define ELF2CFETBL_BUILD_CODENAME "Equuleus" /**< @brief: Development: Code name for the current build */