NOBITS expansion, for .bss etc
[centaur.git] / src / main.c
index 87b47efc4ebe92b49c9db535ef627b711878676a..34e757010e7d26c43fba6aac2c8076374805d073 100644 (file)
@@ -59,14 +59,35 @@ int main(int argc, char **argv)
   }
 
 
-  /* 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");
     }
   }