}
- /* Generate a memory model of the file */
- if (opts.model) {
+ /* Copy the input ELF to the output file if the latter is specified */
+ if (opts.fnOutput) {
ElfuElf *me;
- me = elfu_modelFromElf(hIn.e);
+ me = elfu_mFromElf(hIn.e);
if (me) {
printf("Model successfully loaded.\n");
+ elfu_mCheck(me);
+ printf("Input model checked.\n");
+
+ if (opts.expandNobitsOffs) {
+ elfu_mExpandNobits(me, opts.expandNobitsOffs);
+ }
+
+ if (opts.insertBeforeSz) {
+ elfu_mInsertBefore(me, opts.insertBeforeOffs, opts.insertBeforeSz);
+ }
+
+ if (opts.insertAfterSz) {
+ elfu_mInsertAfter(me, opts.insertAfterOffs, opts.insertAfterSz);
+ }
+
+ elfu_mCheck(me);
+ printf("Output model checked.\n");
+ elfu_mToElf(me, hOut.e);
+ printf("Model converted to ELF, ready to be written.\n");
+ } else {
+ printf("Failed to load model.\n");
}
}