]> pd.if.org Git - zpackage/commitdiff
add elftype as zpm-elftype
authorNathan Wagner <nw@hydaspes.if.org>
Fri, 12 Oct 2018 22:28:38 +0000 (22:28 +0000)
committerNathan Wagner <nw@hydaspes.if.org>
Sat, 3 Nov 2018 12:38:45 +0000 (12:38 +0000)
.gitignore
Makefile
elf/elftype.c

index 9274c8835f536d1caafd4c9a8438d1b91a5a856a..70122a687e1d2dbcc949582ed212f5c697589b2c 100644 (file)
@@ -1,4 +1,3 @@
-elftype
 *.o
 *.a
 *~
 *.o
 *.a
 *~
index d5d19c1256e817126fc6e85e7eea046039601656..75e3b8eb68d2f5a50ceef3cc27776b08335aedaa 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -28,7 +28,8 @@ curdir=$(shell pwd)
 
 ZPKGBIN=zpm-addfile zpm-extract zpm-init zpm-vercmp zpm-stat zpm-hash \
        zpm-findpkg zpm-shell zpm-soneed zpm-foreach-path zpm-parse \
 
 ZPKGBIN=zpm-addfile zpm-extract zpm-init zpm-vercmp zpm-stat zpm-hash \
        zpm-findpkg zpm-shell zpm-soneed zpm-foreach-path zpm-parse \
-       zpm-runscript zpm-soname zpm-syncfs zpm-packagehash zpm-verify
+       zpm-runscript zpm-soname zpm-syncfs zpm-packagehash zpm-verify \
+       zpm-elftype
 
 SCRIPTS=zpm zpm-install zpm-merge zpm-list zpm-preserve zpm-test zpm-log \
        zpm-contents zpm-uninstall zpm-pathmod
 
 SCRIPTS=zpm zpm-install zpm-merge zpm-list zpm-preserve zpm-test zpm-log \
        zpm-contents zpm-uninstall zpm-pathmod
@@ -102,8 +103,8 @@ programs: $(ZPKGBIN)
 uncompress: uncompress.o 
        $(CC) $(CFLAGS) -o $@ $+ -llzma
 
 uncompress: uncompress.o 
        $(CC) $(CFLAGS) -o $@ $+ -llzma
 
-elftype: elf/elftype.c
-       $(CC) $(CFLAGS) -o $@ $+
+zpm-elftype: elf/elftype.c
+       $(CC) -Ielf $(CFLAGS) -o $@ $+
 
 zpm-soname: elf/soname.c
        $(CC) -Ielf $(CFLAGS) -o $@ $+
 
 zpm-soname: elf/soname.c
        $(CC) -Ielf $(CFLAGS) -o $@ $+
index d9b253a2249458208fb82e642d489610eb82a285..717dc122743b4492b935829a418b2d939c59afe0 100644 (file)
@@ -16,7 +16,7 @@
 #define SYMLINKS    0x10
 
 int readline(FILE *f, char *fn);
 #define SYMLINKS    0x10
 
 int readline(FILE *f, char *fn);
-int checkfile(char *fn, unsigned int want, int perr, int quiet);
+int checkfile(char *fn, unsigned int want, int perr);
 
 int errors = 0;
 int zeroterm = 0;
 
 int errors = 0;
 int zeroterm = 0;
@@ -24,7 +24,6 @@ int zeroterm = 0;
 int main(int ac, char **av) {
        int option;
        unsigned int want = 0;
 int main(int ac, char **av) {
        int option;
        unsigned int want = 0;
-       int quiet = 0;
        int printtype = 0;
        int printname = 0;
        int verbose = 0;
        int printtype = 0;
        int printname = 0;
        int verbose = 0;
@@ -32,7 +31,7 @@ int main(int ac, char **av) {
        FILE *list = 0;
        char fn[PATH_MAX];
        
        FILE *list = 0;
        char fn[PATH_MAX];
        
-       while ((option = getopt(ac, av, "vtnredclaqp0f:")) != -1) {
+       while ((option = getopt(ac, av, "vtnredclap0f:")) != -1) {
                switch (option) {
                        case 'r': want |= RELOCATABLE; break;
                        case 'e': want |= EXECUTABLE; break;
                switch (option) {
                        case 'r': want |= RELOCATABLE; break;
                        case 'e': want |= EXECUTABLE; break;
@@ -40,7 +39,6 @@ int main(int ac, char **av) {
                        case 'c': want |= CORE; break;
                        case 'l': want |= SYMLINKS; break;
                        case 'a': want = (RELOCATABLE|EXECUTABLE|DYNAMIC|CORE); break;
                        case 'c': want |= CORE; break;
                        case 'l': want |= SYMLINKS; break;
                        case 'a': want = (RELOCATABLE|EXECUTABLE|DYNAMIC|CORE); break;
-                       case 'q': quiet++; break;
                        case 't': printtype++; break;
                        case 'n': printname++; break;
                        case 'v': verbose++; break;
                        case 't': printtype++; break;
                        case 'n': printname++; break;
                        case 'v': verbose++; break;
@@ -63,10 +61,9 @@ int main(int ac, char **av) {
 
        if (list) {
                int type;
 
        if (list) {
                int type;
-               quiet = 2;
                perr = 0;
                while (readline(list, fn)) {
                perr = 0;
                while (readline(list, fn)) {
-                       if ((type = checkfile(fn, want,perr,quiet)) & want) {
+                       if ((type = checkfile(fn, want, perr)) & want) {
                                if (printtype) {
                                        switch (type) {
                                                case RELOCATABLE:
                                if (printtype) {
                                        switch (type) {
                                                case RELOCATABLE:
@@ -90,7 +87,7 @@ int main(int ac, char **av) {
 
                fn = av[optind];
                if (verbose) fprintf(stderr, "checking %s\n", av[optind]);
 
                fn = av[optind];
                if (verbose) fprintf(stderr, "checking %s\n", av[optind]);
-               type = checkfile(fn,want,perr,quiet);
+               type = checkfile(fn,want,perr);
 
                if (printtype) {
                        switch (type) {
 
                if (printtype) {
                        switch (type) {
@@ -147,7 +144,7 @@ int readline(FILE *f, char *fn) {
        return 0;
 }
 
        return 0;
 }
 
-int checkfile(char *fn, unsigned int want, int perr, int quiet) {
+int checkfile(char *fn, unsigned int want, int perr) {
        Elf64_Ehdr hdr;
        int fd, bytes;
        int endian = 0;
        Elf64_Ehdr hdr;
        int fd, bytes;
        int endian = 0;
@@ -170,7 +167,7 @@ int checkfile(char *fn, unsigned int want, int perr, int quiet) {
        }
        bytes = read(fd, &hdr, sizeof hdr);
        close(fd);
        }
        bytes = read(fd, &hdr, sizeof hdr);
        close(fd);
-       if (bytes < sizeof hdr) {
+       if ((size_t)bytes < sizeof hdr) {
                if (perr) fprintf(stderr, "could not read full elf header (wanted %zu got %d bytes)\n", sizeof hdr, bytes);
                return 0;
        }
                if (perr) fprintf(stderr, "could not read full elf header (wanted %zu got %d bytes)\n", sizeof hdr, bytes);
                return 0;
        }