From 606478ad2a706b857eae5de89f3ce3d444276f73 Mon Sep 17 00:00:00 2001 From: Dominique Martinet Date: Tue, 3 Oct 2017 16:45:58 +0900 Subject: fix Makefile/compilation, make header include libdwarf/*dwarf.h instead of *dwarf.h --- Makefile | 3 ++- dwarf-extract-struct.c | 15 +++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 4eb9d72..c7de7f2 100644 --- a/Makefile +++ b/Makefile @@ -3,10 +3,11 @@ OBJECTS=$(SOURCES:.c=.o) MAIN=dwarf-extract-struct CFLAGS+=-g -Wall -Werror +LDFLAGS=-ldwarf all: $(MAIN) $(MAIN): $(OBJECTS) clean: - rm -f *.o $(MAIN) + rm -f *.o $(MAIN) diff --git a/dwarf-extract-struct.c b/dwarf-extract-struct.c index b6ef87f..7e9bb2c 100644 --- a/dwarf-extract-struct.c +++ b/dwarf-extract-struct.c @@ -14,8 +14,8 @@ #include #include #include -#include "dwarf.h" -#include "libdwarf.h" +#include "libdwarf/dwarf.h" +#include "libdwarf/libdwarf.h" static void parse_dwarf(Dwarf_Debug dbg, const char *struct_name, const char *field_names[], int field_count); @@ -25,15 +25,15 @@ static void print_field(Dwarf_Debug dbg, Dwarf_Die die, const char *field_name, int debug = 0; -void usage(char *argv[]) { +void usage(const char *argv[]) { printf("%s debug_file struct_name field [field...]\n", argv[0]); } -int main(int argc, char *argv[]) { +int main(int argc, const char *argv[]) { Dwarf_Debug dbg = 0; int fd = -1; const char *filepath; - const char *struct_name, **field_names; + const char *struct_name; int res = DW_DLV_ERROR; Dwarf_Error error; Dwarf_Handler errhand = 0; @@ -46,19 +46,18 @@ int main(int argc, char *argv[]) { filepath = argv[1]; struct_name = argv[2]; - field_names = argv + 3; fd = open(filepath,O_RDONLY); if(fd < 0) { printf("Failure attempting to open %s\n",filepath); } - res = dwarf_init(fd,DW_DLC_READ,errhand,errarg, &dbg,&error); + res = dwarf_init(fd, DW_DLC_READ, errhand, errarg, &dbg, &error); if(res != DW_DLV_OK) { printf("Giving up, cannot do DWARF processing\n"); exit(1); } - parse_dwarf(dbg, struct_name, field_names, argc - 3); + parse_dwarf(dbg, struct_name, argv + 3, argc - 3); res = dwarf_finish(dbg,&error); if(res != DW_DLV_OK) { -- cgit v1.2.1-2-g3f67