C90 compliance, except variadic macros and TODOs
authornorly <ny-git@enpas.org>
Mon, 17 Jun 2013 22:34:30 +0000 (23:34 +0100)
committernorly <ny-git@enpas.org>
Mon, 17 Jun 2013 22:39:12 +0000 (23:39 +0100)
Also removed a lot of dead code from the early days.

14 files changed:
Makefile
include/libelfu/elfops.h
src/elfops/phdr-fixup-selfref.c [deleted file]
src/elfops/section-by-name.c [deleted file]
src/elfops/section-in-segment.c [deleted file]
src/elfops/section-name.c [deleted file]
src/modelops/dump.c
src/modelops/fromFile.c
src/modelops/layout.c
src/modelops/reladd.c
src/modelops/relocate.c
src/modelops/section.c
src/modelops/symtab.c
src/modelops/toFile.c

index 641817907db2fd85c684f8b4b4991d0120f9eac3..c8dee7616279a3a2a91c2fc104a1da46b14a53fa 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -14,7 +14,7 @@ SOURCES := $(shell find $(SRCDIR)/ -iname "*.c")
 OBJS    := $(patsubst %.c, $(BUILDDIR)/%.o, $(SOURCES))
 
 INCLUDES := $(patsubst %, -I%, $(INCLUDEDIR) $(SRCDIR)) $(shell pkg-config --cflags-only-I $(LIBRARIES))
-CFLAGS   := -g -Wall $(shell pkg-config --cflags-only-other $(LIBRARIES))
+CFLAGS   := -g -Wall -pedantic -Wno-variadic-macros $(shell pkg-config --cflags-only-other $(LIBRARIES))
 LDFLAGS  := $(shell pkg-config --libs $(LIBRARIES))
 
 
index 73c7aeca5dc4f0f43accc7d0aad67484a8dc8159..48ef3808641df972673242418532f9ed8a7528c1 100644 (file)
@@ -9,12 +9,5 @@
 
 int elfu_eCheck(Elf *e);
 
-   char* elfu_eScnName(Elf *e, Elf_Scn *scn);
-Elf_Scn* elfu_eScnByName(Elf *e, char *name);
-
-Elf_Scn* elfu_eScnFirstInSegment(Elf *e, GElf_Phdr *phdr);
-Elf_Scn* elfu_eScnLastInSegment(Elf *e, GElf_Phdr *phdr);
-
-void elfu_ePhdrFixupSelfRef(Elf *e);
 
 #endif
diff --git a/src/elfops/phdr-fixup-selfref.c b/src/elfops/phdr-fixup-selfref.c
deleted file mode 100644 (file)
index c961ceb..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-#include <libelfu/libelfu.h>
-
-
-void elfu_ePhdrFixupSelfRef(Elf *e)
-{
-  GElf_Ehdr ehdr;
-  size_t i, n;
-
-  if (!gelf_getehdr(e, &ehdr)) {
-    ELFU_WARNELF("gelf_getehdr");
-    return;
-  }
-
-  if (elf_getphdrnum(e, &n)) {
-    ELFU_WARNELF("elf_getphdrnum");
-  }
-
-  for (i = 0; i < n; i++) {
-    GElf_Phdr phdr;
-
-    if (gelf_getphdr(e, i, &phdr) != &phdr) {
-      ELFU_WARN("gelf_getphdr() failed for #%d: %s\n", i, elf_errmsg(-1));
-      continue;
-    }
-
-    if (phdr.p_type == PT_PHDR) {
-      phdr.p_offset = ehdr.e_phoff;
-      phdr.p_filesz = elf32_fsize(ELF_T_PHDR, n, EV_CURRENT);
-      phdr.p_memsz = phdr.p_filesz;
-
-      if (!gelf_update_phdr (e, i, &phdr)) {
-        ELFU_WARNELF("gelf_update_ehdr");
-      }
-    }
-  }
-
-  /* Tell libelf that phdrs have changed */
-  elf_flagphdr(e, ELF_C_SET, ELF_F_DIRTY);
-}
diff --git a/src/elfops/section-by-name.c b/src/elfops/section-by-name.c
deleted file mode 100644 (file)
index 8bb93a3..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-#include <string.h>
-#include <libelfu/libelfu.h>
-
-
-Elf_Scn* elfu_eScnByName(Elf *e, char *name)
-{
-  size_t shstrndx;
-  Elf_Scn *scn;
-
-  if (elf_getshdrstrndx(e, &shstrndx) != 0) {
-    return NULL;
-  }
-
-  scn = elf_getscn(e, 1);
-  while (scn) {
-    GElf_Shdr shdr;
-    char *curname;
-
-    if (gelf_getshdr(scn, &shdr) != &shdr) {
-      return NULL;
-    }
-
-    /* elf_strptr returns NULL if there was an error */
-    curname = elf_strptr(e, shstrndx, shdr.sh_name);
-
-    /* strcmp... but we really have no bounds on the lengths here */
-    if (!strcmp(curname, name)) {
-      return scn;
-    }
-
-    scn = elf_nextscn(e, scn);
-  }
-
-  return NULL;
-}
diff --git a/src/elfops/section-in-segment.c b/src/elfops/section-in-segment.c
deleted file mode 100644 (file)
index 7e6206b..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-#include <stdlib.h>
-#include <libelfu/libelfu.h>
-
-
-/*
- * Returns the section that starts at the same point in the file as
- * the segment AND is wholly contained in the memory image.
- *
- * If no section fits, NULL is returned.
- */
-Elf_Scn* elfu_eScnFirstInSegment(Elf *e, GElf_Phdr *phdr)
-{
-  Elf_Scn *scn;
-
-  scn = elf_getscn(e, 1);
-  while (scn) {
-    GElf_Shdr shdr;
-
-    if (gelf_getshdr(scn, &shdr) != &shdr) {
-      return NULL;
-    }
-
-    if (shdr.sh_offset == phdr->p_offset
-        && PHDR_CONTAINS_SCN_IN_MEMORY(phdr, &shdr)) {
-      return scn;
-    }
-
-    scn = elf_nextscn(e, scn);
-  }
-
-  return NULL;
-}
-
-
-
-/*
- * Returns the first section that  is contained in the segment and
- * ends as close to its memory image of as possible (the "last"
- * section in the segment).
- *
- * If no section fits, NULL is returned.
- */
-Elf_Scn* elfu_eScnLastInSegment(Elf *e, GElf_Phdr *phdr)
-{
-  Elf_Scn *last = NULL;
-  Elf_Scn *scn;
-
-
-  scn = elf_getscn(e, 1);
-  while (scn) {
-    GElf_Shdr shdr;
-
-    if (gelf_getshdr(scn, &shdr) != &shdr) {
-      ELFU_WARNELF("gelf_getshdr");
-      continue;
-    }
-
-    if (PHDR_CONTAINS_SCN_IN_MEMORY(phdr, &shdr)) {
-      if (!last) {
-        last = scn;
-      } else {
-        GElf_Shdr shdrOld;
-
-        if (gelf_getshdr(last, &shdrOld) != &shdrOld) {
-          continue;
-        }
-
-        if (shdr.sh_offset + shdr.sh_size
-            > shdrOld.sh_offset + shdrOld.sh_size) {
-          // TODO: Check (leftover space in memory image) < (p_align)
-          last = scn;
-        }
-      }
-    }
-
-    scn = elf_nextscn(e, scn);
-  }
-
-  return last;
-}
diff --git a/src/elfops/section-name.c b/src/elfops/section-name.c
deleted file mode 100644 (file)
index 4832db9..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-#include <stdlib.h>
-#include <libelfu/libelfu.h>
-
-
-char* elfu_eScnName(Elf *e, Elf_Scn *scn)
-{
-  size_t shstrndx;
-  GElf_Shdr shdr;
-
-  if (elf_getshdrstrndx(e, &shstrndx) != 0) {
-    return NULL;
-  }
-
-  if (gelf_getshdr(scn, &shdr) != &shdr) {
-    return NULL;
-  }
-
-  /* elf_strptr returns NULL if there was an error */
-  return elf_strptr(e, shstrndx, shdr.sh_name);
-}
index 27556f9ebc80d57bf0e1dc36e83617d969e6e5a6..b2e172e269067d42c6e30fcc0fb6c9d88b84bd0f 100644 (file)
@@ -99,25 +99,25 @@ void elfu_mDumpPhdr(ElfuElf *me, ElfuPhdr *mp)
   assert(me);
   assert(mp);
 
-  ELFU_INFO("%12s %8jx %8jx %8jx %8jx %8jx %8jx %8jx %8jx\n",
+  ELFU_INFO("%12s %8x %8x %8x %8x %8x %8x %8x %8x\n",
             segmentTypeStr(mp->phdr.p_type),
-            (uintmax_t) mp->phdr.p_type,
-            (uintmax_t) mp->phdr.p_offset,
-            (uintmax_t) mp->phdr.p_vaddr,
-            (uintmax_t) mp->phdr.p_paddr,
-            (uintmax_t) mp->phdr.p_filesz,
-            (uintmax_t) mp->phdr.p_memsz,
-            (uintmax_t) mp->phdr.p_flags,
-            (uintmax_t) mp->phdr.p_align);
+            (unsigned)mp->phdr.p_type,
+            (unsigned)mp->phdr.p_offset,
+            (unsigned)mp->phdr.p_vaddr,
+            (unsigned)mp->phdr.p_paddr,
+            (unsigned)mp->phdr.p_filesz,
+            (unsigned)mp->phdr.p_memsz,
+            (unsigned)mp->phdr.p_flags,
+            (unsigned)mp->phdr.p_align);
 
   if (!CIRCLEQ_EMPTY(&mp->childPhdrList)) {
     ElfuPhdr *mpc;
 
     ELFU_INFO("      -> Child PHDRs:\n");
     CIRCLEQ_FOREACH(mpc, &mp->childPhdrList, elemChildPhdr) {
-      ELFU_INFO("        * %-8s @ %8jx\n",
+      ELFU_INFO("        * %-8s @ %8x\n",
                 segmentTypeStr(mpc->phdr.p_type),
-                mpc->phdr.p_vaddr);
+                (unsigned)mpc->phdr.p_vaddr);
     }
   }
 
@@ -126,9 +126,9 @@ void elfu_mDumpPhdr(ElfuElf *me, ElfuPhdr *mp)
 
     ELFU_INFO("      -> Child sections:\n");
     CIRCLEQ_FOREACH(msc, &mp->childScnList, elemChildScn) {
-      ELFU_INFO("        * %-17s @ %8jx\n",
+      ELFU_INFO("        * %-17s @ %8x\n",
                 elfu_mScnName(me, msc),
-                msc->shdr.sh_addr);
+                (unsigned)msc->shdr.sh_addr);
     }
   }
 }
@@ -146,15 +146,15 @@ void elfu_mDumpScn(ElfuElf *me, ElfuScn *ms)
   linkstr = ms->linkptr ? elfu_mScnName(me, ms->linkptr) : "";
   infostr = ms->infoptr ? elfu_mScnName(me, ms->infoptr) : "";
 
-  ELFU_INFO("%-17s %-15s %8jx %9jx %8jx %2jx %2jx %2jd %-17s %-17s\n",
+  ELFU_INFO("%-17s %-15s %8x %9x %8x %2x %2x %2d %-17s %-17s\n",
             namestr,
             typestr,
-            ms->shdr.sh_addr,
-            ms->shdr.sh_offset,
-            ms->shdr.sh_size,
-            ms->shdr.sh_entsize,
-            ms->shdr.sh_flags,
-            ms->shdr.sh_addralign,
+            (unsigned)ms->shdr.sh_addr,
+            (unsigned)ms->shdr.sh_offset,
+            (unsigned)ms->shdr.sh_size,
+            (unsigned)ms->shdr.sh_entsize,
+            (unsigned)ms->shdr.sh_flags,
+            (unsigned)ms->shdr.sh_addralign,
             linkstr,
             infostr);
 }
@@ -172,9 +172,9 @@ void elfu_mDumpEhdr(ElfuElf *me)
   ELFU_INFO("     e_type       %8x\n", me->ehdr.e_type);
   ELFU_INFO("     e_machine    %8x\n", me->ehdr.e_machine);
   ELFU_INFO("     e_version    %8x\n", me->ehdr.e_version);
-  ELFU_INFO("     e_entry      %8jx\n", me->ehdr.e_entry);
-  ELFU_INFO("     e_phoff      %8jx\n", me->ehdr.e_phoff);
-  ELFU_INFO("     e_shoff      %8jx\n", me->ehdr.e_shoff);
+  ELFU_INFO("     e_entry      %8x\n", (unsigned)me->ehdr.e_entry);
+  ELFU_INFO("     e_phoff      %8x\n", (unsigned)me->ehdr.e_phoff);
+  ELFU_INFO("     e_shoff      %8x\n", (unsigned)me->ehdr.e_shoff);
   ELFU_INFO("     e_flags      %8x\n", me->ehdr.e_flags);
   ELFU_INFO("     e_ehsize     %8x\n", me->ehdr.e_ehsize);
   ELFU_INFO("     e_phentsize  %8x\n", me->ehdr.e_phentsize);
@@ -224,9 +224,9 @@ void elfu_mDumpElf(ElfuElf *me)
 
   ELFU_INFO("Orphaned sections:\n");
   CIRCLEQ_FOREACH(ms, &me->orphanScnList, elemChildScn) {
-    ELFU_INFO("        * %-17s @ %8jx\n",
+    ELFU_INFO("        * %-17s @ %8x\n",
               elfu_mScnName(me, ms),
-              ms->shdr.sh_addr);
+              (unsigned)ms->shdr.sh_addr);
   }
   ELFU_INFO("\n");
 
index bc089bfe99a9b427983091daad31474f03a62ed0..dd8b46222b5654b0220b631f491249188d30db5e 100644 (file)
@@ -52,7 +52,7 @@ static void parseSymtab(ElfuElf *me, ElfuScn *ms, ElfuScn**origScnArr)
       CIRCLEQ_INSERT_TAIL(&ms->symtab.syms, newsym, elem);
     }
   } else {
-    // Unknown elfclass
+    /* Unknown elfclass */
     assert(0);
   }
 
@@ -126,11 +126,14 @@ static void parseRelatab64(ElfuScn *ms)
 
 static int cmpScnOffs(const void *ms1, const void *ms2)
 {
+  ElfuScn *s1 = *(ElfuScn**)ms1;
+  ElfuScn *s2 = *(ElfuScn**)ms2;
+
   assert(ms1);
   assert(ms2);
 
-  ElfuScn *s1 = *(ElfuScn**)ms1;
-  ElfuScn *s2 = *(ElfuScn**)ms2;
+  s1 = *(ElfuScn**)ms1;
+  s2 = *(ElfuScn**)ms2;
 
   assert(s1);
   assert(s2);
@@ -230,7 +233,7 @@ static ElfuScn* modelFromSection(Elf_Scn *scn)
 
     ms->data.d_buf = malloc(ms->shdr.sh_size);
     if (!ms->data.d_buf) {
-      ELFU_WARN("modelFromSection: malloc() failed for data buffer (%jx bytes).\n", ms->shdr.sh_size);
+      ELFU_WARN("modelFromSection: malloc() failed for data buffer (%x bytes).\n", (unsigned)ms->shdr.sh_size);
       goto ERROR;
     }
 
@@ -246,7 +249,7 @@ static ElfuScn* modelFromSection(Elf_Scn *scn)
       if (data->d_off + data->d_size > ms->shdr.sh_size) {
         ELFU_WARN("modelFromSection: libelf delivered a bogus data blob. Skipping\n");
       } else {
-        memcpy(ms->data.d_buf + data->d_off, data->d_buf, data->d_size);
+        memcpy((char*)ms->data.d_buf + data->d_off, data->d_buf, data->d_size);
       }
 
       data = elf_rawdata(scn, data);
@@ -427,12 +430,14 @@ ElfuElf* elfu_mFromElf(Elf *e)
           if (me->elfclass == ELFCLASS32) {
             parseReltab32(ms);
           } else if (me->elfclass == ELFCLASS64) {
-            // Not used on x86-64
+            /* Not used on x86-64 */
+            assert(0);
           }
           break;
         case SHT_RELA:
           if (me->elfclass == ELFCLASS32) {
-            // TODO
+            /* Not used on x86-32 */
+            assert(0);
           } else if (me->elfclass == ELFCLASS64) {
             parseRelatab64(ms);
           }
index e4b3fb13aab028d93b4e24fecbc66a93fc17a3f7..8abc766e167e8dea322d8949c3854791ce836bea 100644 (file)
@@ -115,7 +115,7 @@ GElf_Addr elfu_mLayoutGetSpaceInPhdr(ElfuElf *me, GElf_Word size,
       GElf_Off endAddr = OFFS_END(last->phdr.p_vaddr, last->phdr.p_filesz);
       ElfuScn *ms;
 
-      ELFU_INFO("Expanding NOBITS at address 0x%jx...\n", endAddr);
+      ELFU_INFO("Expanding NOBITS at address 0x%x...\n", (unsigned)endAddr);
 
       CIRCLEQ_FOREACH(ms, &last->childScnList, elemChildScn) {
         if (ms->shdr.sh_offset == endOff) {
@@ -124,7 +124,8 @@ GElf_Addr elfu_mLayoutGetSpaceInPhdr(ElfuElf *me, GElf_Word size,
           ms->data.d_buf = malloc(ms->shdr.sh_size);
           memset(ms->data.d_buf, '\0', ms->shdr.sh_size);
           if (!ms->data.d_buf) {
-            ELFU_WARN("mExpandNobits: Could not allocate %jd bytes for NOBITS expansion. Data may be inconsistent.\n", ms->shdr.sh_size);
+            ELFU_WARN("mExpandNobits: Could not allocate %u bytes for NOBITS expansion. Data may be inconsistent.\n",
+                      (unsigned)ms->shdr.sh_size);
             assert(0);
             goto ERROR;
           }
@@ -227,11 +228,14 @@ GElf_Addr elfu_mLayoutGetSpaceInPhdr(ElfuElf *me, GElf_Word size,
 
 static int cmpPhdrOffs(const void *mp1, const void *mp2)
 {
+  ElfuPhdr *p1;
+  ElfuPhdr *p2;
+
   assert(mp1);
   assert(mp2);
 
-  ElfuPhdr *p1 = *(ElfuPhdr**)mp1;
-  ElfuPhdr *p2 = *(ElfuPhdr**)mp2;
+  p1 = *(ElfuPhdr**)mp1;
+  p2 = *(ElfuPhdr**)mp2;
 
   assert(p1);
   assert(p2);
index fa8ffff9af55f527ee5d1fd77a9a838b8e3619c1..bc909e4c0e7074adeeffd4efc4467877c455d926 100644 (file)
@@ -7,7 +7,7 @@
 
 static int appendData(ElfuScn *ms, void *buf, size_t len)
 {
-  void *newbuf;
+  char *newbuf;
 
   assert(ms);
   assert(ms->shdr.sh_type != SHT_NOBITS);
@@ -67,9 +67,9 @@ static ElfuScn* insertSection(ElfuElf *me, ElfuElf *mrel, ElfuScn *oldscn)
       goto ERROR;
     }
 
-    ELFU_INFO("Inserting %s at address 0x%jx...\n",
+    ELFU_INFO("Inserting %s at address 0x%x...\n",
               elfu_mScnName(mrel, oldscn),
-              injAddr);
+              (unsigned)injAddr);
 
     injOffset = injAddr - injPhdr->phdr.p_vaddr + injPhdr->phdr.p_offset;
 
@@ -120,10 +120,10 @@ static ElfuScn* insertSection(ElfuElf *me, ElfuElf *mrel, ElfuScn *oldscn)
 
     return newscn;
   } else {
-      ELFU_WARN("insertSection: Skipping non-memory section %s (type %d flags %jd).\n",
+      ELFU_WARN("insertSection: Skipping non-memory section %s (type %d flags %u).\n",
                 elfu_mScnName(mrel, oldscn),
                 oldscn->shdr.sh_type,
-                oldscn->shdr.sh_flags);
+                (unsigned)oldscn->shdr.sh_flags);
       goto ERROR;
   }
 
@@ -137,10 +137,10 @@ static ElfuScn* insertSection(ElfuElf *me, ElfuElf *mrel, ElfuScn *oldscn)
 
 static void* subScnAdd1(ElfuElf *mrel, ElfuScn *ms, void *aux1, void *aux2)
 {
-  (void)aux2;
+  ElfuScn *newscn;
   ElfuElf *me = (ElfuElf*)aux1;
+  (void)aux2;
 
-  ElfuScn *newscn;
 
   switch(ms->shdr.sh_type) {
     case SHT_PROGBITS: /* 1 */
@@ -166,9 +166,8 @@ static void* subScnAdd1(ElfuElf *mrel, ElfuScn *ms, void *aux1, void *aux2)
 
 static void* subScnAdd2(ElfuElf *mrel, ElfuScn *ms, void *aux1, void *aux2)
 {
-  (void)aux2;
   ElfuElf *me = (ElfuElf*)aux1;
-  (void)me;
+  (void)aux2;
 
   switch(ms->shdr.sh_type) {
     case SHT_NULL: /* 0 */
@@ -217,7 +216,7 @@ static void* subScnAdd2(ElfuElf *mrel, ElfuScn *ms, void *aux1, void *aux2)
 static void insertSymClone(ElfuElf *me, const ElfuScn *oldmsst, const ElfuSym *oldsym)
 {
   GElf_Xword newsize;
-  void *newbuf;
+  char *newbuf;
   ElfuScn *newscn = NULL;
   ElfuSym *newsym;
   char *oldsymname;
index 90a319bd2a04ce80d5fffa2a7950fc3fea430445..eefed026c8ad16d3594b9f9bf4693001a6ee3941 100644 (file)
@@ -13,9 +13,9 @@ void elfu_mRelocate(ElfuElf *metarget, ElfuScn *mstarget, ElfuScn *msrt)
   assert(mstarget);
   assert(msrt);
 
-  ELFU_DEBUG("Relocating in section of type %d size %jx\n",
+  ELFU_DEBUG("Relocating in section of type %u size %x\n",
              mstarget->shdr.sh_type,
-             mstarget->shdr.sh_size);
+             (unsigned)mstarget->shdr.sh_size);
 
   CIRCLEQ_FOREACH(rel, &msrt->reltab.rels, elem) {
     Elf32_Word *dest32 = (Elf32_Word*)(((char*)(mstarget->data.d_buf)) + rel->offset);
@@ -41,12 +41,13 @@ void elfu_mRelocate(ElfuElf *metarget, ElfuScn *mstarget, ElfuScn *msrt)
           ELFU_DEBUG("Skipping relocation: Unknown type %d\n", rel->type);
       }
     } else if (metarget->elfclass == ELFCLASS64) {
-      /* x86-64 only uses RELA with explicit addend. */
-      assert(rel->addendUsed);
       Elf64_Word a64 = rel->addend;
       Elf64_Addr p64 = mstarget->shdr.sh_addr + rel->offset;
       Elf64_Addr s64 = elfu_mSymtabLookupVal(metarget, msrt->linkptr, rel->sym);
 
+      /* x86-64 only uses RELA with explicit addend. */
+      assert(rel->addendUsed);
+
       switch(rel->type) {
         case R_X86_64_NONE:
           ELFU_DEBUG("Skipping relocation: R_386_NONE\n");
index a96377ca21f00d1b4d8b8d26c6be244c3a8da492..26751268a8c537128c9eb451c48f0669ef97979e 100644 (file)
@@ -146,11 +146,14 @@ static void* subScnsToArray(ElfuElf *me, ElfuScn *ms, void *aux1, void *aux2)
 
 static int cmpScnOffs(const void *ms1, const void *ms2)
 {
+  ElfuScn *s1;
+  ElfuScn *s2;
+
   assert(ms1);
   assert(ms2);
 
-  ElfuScn *s1 = *(ElfuScn**)ms1;
-  ElfuScn *s2 = *(ElfuScn**)ms2;
+  s1 = *(ElfuScn**)ms1;
+  s2 = *(ElfuScn**)ms2;
 
   assert(s1);
   assert(s2);
@@ -167,12 +170,12 @@ static int cmpScnOffs(const void *ms1, const void *ms2)
 
 ElfuScn** elfu_mScnSortedByOffset(ElfuElf *me, size_t *count)
 {
-  assert(me);
-
   size_t numSecs;
   ElfuScn **sortedSecs;
   size_t i;
 
+  assert(me);
+
   /* Sort sections by offset in file */
   numSecs = elfu_mScnCount(me);
   sortedSecs = malloc(numSecs * sizeof(*sortedSecs));
index a7c1485c9d74bb9b41fcef6797e1b8cdfe480157..e62871fa8c70d642043147a43800578f4952d2b1 100644 (file)
@@ -76,7 +76,7 @@ static GElf_Word pltLookupVal(ElfuElf *me, char *name)
        * from the start of the PLT, where j is the PLT entry and 16 is
        * the number of bytes the machine code in a PLT entry take. */
       GElf_Addr addr = plt->shdr.sh_addr + (16 * j);
-      ELFU_DEBUG("dynsymLookupVal: Guessing symbol '%s' is in destination memory at %jx (PLT entry #%d).\n", name, addr, j);
+      ELFU_DEBUG("dynsymLookupVal: Guessing symbol '%s' is in destination memory at %x (PLT entry #%u).\n", name, (unsigned)addr, j);
       return addr;
     }
   }
@@ -215,7 +215,7 @@ void elfu_mSymtabFlatten(ElfuElf *me)
       i++;
     }
   } else {
-    // Unknown elfclass
+    /* Unknown elfclass */
     assert(0);
   }
 
index 1fec8b0c51dafb022bf3678862397874dd44b6d3..368f12a58fb0baf7ce1b021671826b5fb0108d1b 100644 (file)
@@ -34,10 +34,10 @@ static void modelToPhdrs(ElfuElf *me, Elf *e)
 
 static void* modelToSection(ElfuElf *me, ElfuScn *ms, void *aux1, void *aux2)
 {
+  Elf_Scn *scnOut;
+  Elf *e = (Elf*)aux1;
   (void) me;
   (void) aux2;
-  Elf *e = (Elf*)aux1;
-  Elf_Scn *scnOut;
 
   scnOut = elf_newscn(e);
   if (!scnOut) {