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

Fix #126, Move variables declared mid-function to the top #127

Merged
Merged
Changes from all commits
Commits
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
27 changes: 14 additions & 13 deletions elf2cfetbl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) &&
Expand All @@ -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)
{
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
{
Expand Down