Merge cloneScn() into reladd.c
authornorly <ny-git@enpas.org>
Thu, 20 Jun 2013 23:41:14 +0000 (00:41 +0100)
committernorly <ny-git@enpas.org>
Thu, 20 Jun 2013 23:42:22 +0000 (00:42 +0100)
It's the only place where we use it, and it's case-specific

include/libelfu/modelops.h
src/libelfu/modelops/clone.c [deleted file]
src/libelfu/modelops/reladd.c

index e5702f759ad1e1f208c5638320e3119cc1934346..3a5d7ead82574db1380ecdefd9d9205f76bacb15 100644 (file)
@@ -52,8 +52,6 @@ void elfu_mRelocate(ElfuElf *metarget, ElfuScn *mstarget, ElfuScn *msrt);
 
 int elfu_mCheck(ElfuElf *me);
 
-ElfuScn* elfu_mCloneScn(ElfuScn *ms);
-
 
 void elfu_mDumpPhdr(ElfuElf *me, ElfuPhdr *mp);
 void elfu_mDumpScn(ElfuElf *me, ElfuScn *ms);
diff --git a/src/libelfu/modelops/clone.c b/src/libelfu/modelops/clone.c
deleted file mode 100644 (file)
index 8b9b0bc..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-#include <assert.h>
-#include <stdlib.h>
-#include <string.h>
-#include <libelfu/libelfu.h>
-
-ElfuScn* elfu_mCloneScn(ElfuScn *ms)
-{
-  ElfuScn *newscn;
-
-  assert(ms);
-
-  newscn = elfu_mScnAlloc();
-  if (!newscn) {
-    ELFU_WARN("elfu_nCloneScn: Could not allocate memory for new ElfuScn.\n");
-    return NULL;
-  }
-
-  newscn->shdr = ms->shdr;
-
-  if (ms->databuf) {
-    void *newbuf = malloc(ms->shdr.sh_size);
-    if (!newbuf) {
-      ELFU_WARN("elfu_nCloneScn: Could not allocate memory for new data buffer.\n");
-      free(newscn);
-      return NULL;
-    }
-
-    memcpy(newbuf, ms->databuf, ms->shdr.sh_size);
-    newscn->databuf = newbuf;
-  }
-
-  newscn->oldptr = ms;
-
-  return newscn;
-}
index 8c56d4ff7faa2af178b047598c7c74f46ae8e5db..6ab54e06096c24ae18e82f9c013b5ffd0a44d54b 100644 (file)
@@ -5,6 +5,37 @@
 #include <libelfu/libelfu.h>
 
 
+static ElfuScn* cloneScn(ElfuScn *ms)
+{
+  ElfuScn *newscn;
+
+  assert(ms);
+
+  newscn = elfu_mScnAlloc();
+  if (!newscn) {
+    return NULL;
+  }
+
+  newscn->shdr = ms->shdr;
+
+  if (ms->databuf) {
+    void *newbuf = malloc(ms->shdr.sh_size);
+    if (!newbuf) {
+      ELFU_WARN("cloneScn: Could not allocate memory for new data buffer.\n");
+      free(newscn);
+      return NULL;
+    }
+
+    memcpy(newbuf, ms->databuf, ms->shdr.sh_size);
+    newscn->databuf = newbuf;
+  }
+
+  newscn->oldptr = ms;
+
+  return newscn;
+}
+
+
 static int appendData(ElfuScn *ms, void *buf, size_t len)
 {
   char *newbuf;
@@ -36,7 +67,7 @@ static ElfuScn* insertSection(ElfuElf *me, ElfuElf *mrel, ElfuScn *oldscn)
   ElfuPhdr *injPhdr;
 
   if (oldscn->shdr.sh_flags & SHF_ALLOC) {
-    newscn = elfu_mCloneScn(oldscn);
+    newscn = cloneScn(oldscn);
     if (!newscn) {
       return NULL;
     }