Skip to content

Commit

Permalink
Merge pull request #608 from uyjulian/break_replace
Browse files Browse the repository at this point in the history
refactor: replace occurances of inline asm break with __builtin_trap
  • Loading branch information
fjtrujy authored May 6, 2024
2 parents e9515bf + 80b5b3e commit b6fdbd4
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion ee/elf-loader/src/elf.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ int LoadELFFromFileWithPartition(const char *filename, const char *partition, in
boot_elf = (u8 *)loader_elf;
eh = (elf_header_t *)boot_elf;
if (_lw((u32)&eh->ident) != ELF_MAGIC)
asm volatile("break\n");
__builtin_trap();

eph = (elf_pheader_t *)(boot_elf + eh->phoff);

Expand Down
2 changes: 1 addition & 1 deletion iop/system/loadcore/src/loadcore.c
Original file line number Diff line number Diff line change
Expand Up @@ -1313,7 +1313,7 @@ static void loadrelelf(const void *module, FileInfo_t *ModuleInfo)
u32 entsize;
entsize = CurrentELF_shdr->entsize;
if ( !entsize )
__asm__ __volatile__("\tbreak\n");
__builtin_trap();
NumRelocs = CurrentELF_shdr->size / entsize;
ApplyElfRelSection(ModuleInfo->text_start, (const elf_rel *)((u8 *)module + CurrentELF_shdr->offset), NumRelocs);
}
Expand Down
6 changes: 3 additions & 3 deletions iop/system/modload/src/modload.c
Original file line number Diff line number Diff line change
Expand Up @@ -1018,10 +1018,10 @@ static int modload_post_boot_callback(iop_init_entry_t *next, int delayed)
module_result =
((int (*)(int, char **, u32, ModuleInfo_t *))module_info->entry)(updater_argc, updater_argv, 0, module_info);
printf("return from updater '%s' return value = %d\n", updater_argv[0], module_result);
__asm__ __volatile__("\tbreak\n");
__builtin_trap();
}
printf("updater '%s' can't load\n", updater_argv[0]);
__asm__ __volatile__("\tbreak\n");
__builtin_trap();
}
printf("Reboot fail! need file name argument\n");
return 0;
Expand Down Expand Up @@ -1404,7 +1404,7 @@ do_load_seek(module_thread_args_t *mltargs, int module_fd, FileInfo_t *fi, int *
break;
entsize = elfshdr[i].entsize;
if ( !entsize )
__asm__ __volatile__("\tbreak\n");
__builtin_trap();
ApplyElfRelSection(fi->text_start, modulearea, elfshdr[i].size / entsize);
}
break;
Expand Down
2 changes: 1 addition & 1 deletion iop/system/sifcmd/src/sifrpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ static void *sif_rpc_get_fpacket(sif_rpc_data_t *rpc_data)
rdata_table_len = rpc_data->rdata_table_len;
index_calc = rdata_table_idx % rdata_table_len;
if ( rdata_table_len == -1 && (u32)rdata_table_idx == 0x80000000 )
__asm__("break\n");
__builtin_trap();
rpc_data->rdata_table_idx = index_calc + 1;
return &rpc_data->rdata_table[64 * index_calc];
}
Expand Down
4 changes: 2 additions & 2 deletions iop/system/threadman/src/thbase.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ int ExitThread()
thread_leave(0, 0, state, 1);

Kprintf("panic ! Thread DORMANT !\n");
asm __volatile__("break 1");
__builtin_trap();

return KE_OK;
}
Expand All @@ -249,7 +249,7 @@ int ExitDeleteThread()
thread_leave(0, 0, state, 1);

Kprintf("panic ! Thread ExitDeleted !\n");
asm __volatile__("break 1");
__builtin_trap();

return KE_OK;
}
Expand Down
2 changes: 1 addition & 1 deletion iop/system/threadman/src/thcommon.c
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ void report_stack_overflow(struct thread *thread)
}
}

asm __volatile__("break 1");
__builtin_trap();
}

void do_delete_thread()
Expand Down
10 changes: 5 additions & 5 deletions iop/system/udnl/src/udnl.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ static void ScanImagesForFile(const struct ImageData *ImageDataBuffer, unsigned
#else
printf("panic ! \'%s\' not found\n", filename);
#endif
__asm("break\n");
__builtin_trap();
}

#ifdef UDNL_T300
Expand Down Expand Up @@ -982,7 +982,7 @@ static void ParseIOPBTCONF(const struct ImageData *ImageDataBuffer, unsigned int
DisplayModuleName(ResetData->NumModules, ptr); // Code for debugging only - not originally present.
#endif
if (SelectModuleFromImages(ImageDataBuffer, NumFiles, ptr, &ModuleFileStat) == NULL) {
__asm("break\n");
__builtin_trap();
}

ModList[NumModules] = ModuleFileStat.data;
Expand Down Expand Up @@ -1102,7 +1102,7 @@ int _start(int argc, char *argv[])
}
#endif
SleepThread();
__asm("break");
__builtin_trap();
}
}
*/
Expand All @@ -1119,7 +1119,7 @@ int _start(int argc, char *argv[])
}
#endif
SleepThread();
__asm("break");
__builtin_trap();
}

file_sz = lseek(fd, 0, SEEK_END);
Expand Down Expand Up @@ -1159,7 +1159,7 @@ int _start(int argc, char *argv[])
}
#endif
SleepThread();
__asm("break");
__builtin_trap();
}

ResetData = buffer;
Expand Down

0 comments on commit b6fdbd4

Please sign in to comment.