Permalink
Browse files

Properly include elf.h

  • Loading branch information...
1 parent 22936a8 commit b178aa23546db6967ce73792157d0e2e89d4c4d2 @probonopd committed Sep 18, 2016
Showing with 31 additions and 25 deletions.
  1. +5 −3 appimagetool.c
  2. +4 −8 build.sh
  3. +1 −14 elf.c
  4. +21 −0 elf.h
View
@@ -22,6 +22,8 @@
#include <unistd.h>
#include <string.h>
+#include "elf.h"
+
extern int _binary_runtime_start;
extern int _binary_runtime_size;
@@ -377,7 +379,7 @@ main (int argc, char *argv[])
if (fp == NULL)
die("Failed to run objdump command");
- long int ui_offset;
+ long ui_offset = 0;
while(fgets(line, sizeof(line), fp) != NULL ){
if(strstr(line, ".note.upd-info") != NULL)
{
@@ -396,11 +398,11 @@ main (int argc, char *argv[])
/* Convert from a string that contains hex to an int and add 32 */
ui_offset = (int)strtol(token, NULL, 16) + 32;
if(verbose)
- printf("ui_offset: %i\n", ui_offset);
+ printf("ui_offset: %lu\n", ui_offset);
}
}
fclose(fp);
- if(ui_offset == NULL)
+ if(ui_offset == 0)
die("Could not determine offset for updateinformation");
fseek(fpdst, ui_offset, SEEK_SET);
// fwrite(0x00, 1, 1024, fpdst); // FIXME: Segfaults; why?
View
@@ -90,14 +90,6 @@ printf '\x41\x49\x02' | dd of=runtime bs=1 seek=8 count=3 conv=notrunc
ld -r -b binary -o data.o runtime
-# Compile appimagetool but do not link
-
-cc -D_FILE_OFFSET_BITS=64 -I ../squashfuse -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -g -Os -c ../appimagetoolnoglib.c
-
-# Now statically link against libsquashfuse and liblzma
-
-cc data.o appimagetoolnoglib.o -DENABLE_BINRELOC ../binreloc.c ../squashfuse/.libs/libsquashfuse.a ../squashfuse/.libs/libfuseprivate.a -Wl,-Bdynamic -lfuse -lpthread -lz -Wl,-Bstatic -llzma -Wl,-Bdynamic -o appimagetoolnoglib
-
# Compile appimagetool but do not link - glib version
cc -D_FILE_OFFSET_BITS=64 -I ../squashfuse $(pkg-config --cflags glib-2.0) -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -g -Os -c ../appimagetool.c
@@ -106,6 +98,10 @@ cc -D_FILE_OFFSET_BITS=64 -I ../squashfuse $(pkg-config --cflags glib-2.0) -I/us
cc data.o appimagetool.o ../elf.c -DENABLE_BINRELOC ../binreloc.c ../squashfuse/.libs/libsquashfuse.a ../squashfuse/.libs/libfuseprivate.a -Wl,-Bdynamic -lfuse -lpthread $(pkg-config --libs glib-2.0) -lz -Wl,-Bstatic -llzma -Wl,-Bdynamic -o appimagetool
+# Version without glib
+# cc -D_FILE_OFFSET_BITS=64 -I ../squashfuse -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -g -Os -c ../appimagetoolnoglib.c
+# cc data.o appimagetoolnoglib.o -DENABLE_BINRELOC ../binreloc.c ../squashfuse/.libs/libsquashfuse.a ../squashfuse/.libs/libfuseprivate.a -Wl,-Bdynamic -lfuse -lpthread -lz -Wl,-Bstatic -llzma -Wl,-Bdynamic -o appimagetoolnoglib
+
cd ..
# Reset squashfuse to its original state
View
@@ -1,16 +1,3 @@
-/*
-Calculate the size of an ELF file on disk based on the information in its header
-
-Example:
-ls -l 126584
-Calculation using the values also reported by readelf -h:
-Start of section headers e_shoff 124728
-Size of section headers e_shentsize 64
-Number of section headers e_shnum 29
-e_shoff + ( e_shentsize * e_shnum ) = 126584
-*/
-
-
#include <elf.h>
#include <byteswap.h>
#include <stdio.h>
@@ -95,7 +82,7 @@ static unsigned long read_elf64(int fd)
return(ehdr.e_shoff + (ehdr.e_shentsize * ehdr.e_shnum));
}
-unsigned long get_elf_size(char *fname)
+unsigned long get_elf_size(const char *fname)
/* TODO, FIXME: This assumes that the section header table (SHT) is
the last part of the ELF. This is usually the case but
it could also be that the last section is the last part
View
@@ -0,0 +1,21 @@
+/*
+Calculate the size of an ELF file on disk based on the information in its header
+
+Example:
+
+ls -l 126584
+
+Calculation using the values also reported by readelf -h:
+Start of section headers e_shoff 124728
+Size of section headers e_shentsize 64
+Number of section headers e_shnum 29
+
+e_shoff + ( e_shentsize * e_shnum ) = 126584
+*/
+
+#ifndef __ELFSIZE_H__
+#define __ELFSIZE_H__
+
+unsigned long get_elf_size(const char *fname);
+
+#endif /* __ELFSIZE_H__ */

0 comments on commit b178aa2

Please sign in to comment.