From 1b7a4e380899d0f6aa87147e198d53b2af818191 Mon Sep 17 00:00:00 2001 From: Zack Landau Date: Thu, 21 Nov 2013 23:16:39 -0800 Subject: [PATCH 01/10] Fix 'all' dependency in makefile The 'all' target in the Makefile was messed up, causing 'make install' to not see a normal 'make' as a dependency. --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index f588078..4fefca2 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,8 @@ DEPS := ${SRCS:.c=.dep} DIST := ${TARGET}-${VERSION} .PHONY: all clean distclean dist install uninstall - all:: ${TARGET} + +all:: ${TARGET} ${TARGET}: ${OBJS} ${CC} -o $@ $^ ${LDFLAGS} From 6f6ecf80518595a828bd8facfc1d2db033d972ce Mon Sep 17 00:00:00 2001 From: Zack Landau Date: Thu, 21 Nov 2013 23:18:25 -0800 Subject: [PATCH 02/10] Change exit code of --help to be 0 --- atosl.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/atosl.c b/atosl.c index 72ee5d5..b820d11 100644 --- a/atosl.c +++ b/atosl.c @@ -1197,9 +1197,11 @@ int main(int argc, char *argv[]) { options.use_globals = 1; break; case '?': - case 'h': print_help(); exit(EXIT_FAILURE); + case 'h': + print_help(); + exit(EXIT_SUCCESS); default: fatal("unhandled option"); } From 99d17e5f3290ce0b12547444df67698bbe7ad627 Mon Sep 17 00:00:00 2001 From: Zack Landau Date: Thu, 21 Nov 2013 23:37:41 -0800 Subject: [PATCH 03/10] Fix handling of --verbose long option We were using some hybrid of letting getopt store the value of the --verbose flag and trying to handle it ourselves, which was breaking the long option. --- atosl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/atosl.c b/atosl.c index b820d11..fdf38e3 100644 --- a/atosl.c +++ b/atosl.c @@ -55,7 +55,7 @@ static int debug = 0; static const char *shortopts = "vl:o:A:gh"; static struct option longopts[] = { - {"verbose", no_argument, &debug, 1}, + {"verbose", no_argument, NULL, 'v'}, {"load-address", required_argument, NULL, 'l'}, {"dsym", required_argument, NULL, 'o'}, {"arch", optional_argument, NULL, 'A'}, From feeac940639bb7cf6061ba9e7f7d2ff2b6074904 Mon Sep 17 00:00:00 2001 From: Zack Landau Date: Thu, 21 Nov 2013 23:24:15 -0800 Subject: [PATCH 04/10] Add --version parameter --- atosl.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/atosl.c b/atosl.c index fdf38e3..bbb1a39 100644 --- a/atosl.c +++ b/atosl.c @@ -53,13 +53,14 @@ _dwarf_decode_u_leb128(Dwarf_Small * leb128, static int debug = 0; -static const char *shortopts = "vl:o:A:gh"; +static const char *shortopts = "vl:o:A:gVh"; static struct option longopts[] = { {"verbose", no_argument, NULL, 'v'}, {"load-address", required_argument, NULL, 'l'}, {"dsym", required_argument, NULL, 'o'}, {"arch", optional_argument, NULL, 'A'}, {"globals", no_argument, NULL, 'g'}, + {"version", no_argument, NULL, 'V'}, {"help", no_argument, NULL, 'h'}, }; @@ -151,6 +152,8 @@ void print_help(void) " -A, --arch=ARCH\t\tspecify architecture\n"); fprintf(stderr, " -g, --globals\t\t\tlookup symbols using global section\n"); + fprintf(stderr, + " -V, --version\t\t\tget current version\n"); fprintf(stderr, " -h, --help\t\t\tthis help\n"); fprintf(stderr, "\n"); @@ -1196,6 +1199,9 @@ int main(int argc, char *argv[]) { case 'g': options.use_globals = 1; break; + case 'V': + fprintf(stderr, "atosl %s\n", VERSION); + exit(EXIT_SUCCESS); case '?': print_help(); exit(EXIT_FAILURE); From 39b0793b8728da22be5a58be4e4bb1af451bc0cc Mon Sep 17 00:00:00 2001 From: Zack Landau Date: Thu, 21 Nov 2013 23:39:59 -0800 Subject: [PATCH 05/10] NULL terminate the longopts struct --- atosl.c | 1 + 1 file changed, 1 insertion(+) diff --git a/atosl.c b/atosl.c index bbb1a39..99ee669 100644 --- a/atosl.c +++ b/atosl.c @@ -62,6 +62,7 @@ static struct option longopts[] = { {"globals", no_argument, NULL, 'g'}, {"version", no_argument, NULL, 'V'}, {"help", no_argument, NULL, 'h'}, + {NULL, 0, NULL, 0} }; static struct { From 8c7a886a7033f76133dc5f350dbe21fc17ff4091 Mon Sep 17 00:00:00 2001 From: Zack Landau Date: Thu, 21 Nov 2013 23:43:10 -0800 Subject: [PATCH 06/10] Remove unnecessary DWARF* flags DWARFCFLAGS and DWARFLIBS were no different than just adding to CFLAGS and LIBS, removed. --- README.md | 2 +- config.mk | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index dc0faea..fc918f2 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ brew install https://gist.github.com/zlandau/7550479/raw/b084adb5506b186b520783b #### Update config.mk.local ```sh -echo "DWARFLDFLAGS += -L$(dirname $(brew list binutils| grep libiberty.a))" >> config.mk.local +echo "LDFLAGS += -L$(dirname $(brew list binutils| grep libiberty.a))" >> config.mk.local ``` ## Usage diff --git a/config.mk b/config.mk index 34c7bac..1d7dcba 100644 --- a/config.mk +++ b/config.mk @@ -2,11 +2,8 @@ VERSION = 1.0 PREFIX = /usr/local -DWARFCFLAGS = -DWARFLDFLAGS = - -CFLAGS = -Wall -Werror -O2 ${DWARFCFLAGS} -DATOSL_VERSION=\"${VERSION}\" -LDFLAGS = ${DWARFLDFLAGS} -ldwarf -liberty +CFLAGS = -Wall -Werror -O2 -DATOSL_VERSION=\"${VERSION}\" +LDFLAGS = -ldwarf -liberty CC = cc From c6c1a5a223da9bb1dcbfab4e2866b4f4bf3fd615 Mon Sep 17 00:00:00 2001 From: Zack Landau Date: Thu, 21 Nov 2013 23:40:45 -0800 Subject: [PATCH 07/10] Bump version to 1.1 --- config.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.mk b/config.mk index 1d7dcba..03c0cbf 100644 --- a/config.mk +++ b/config.mk @@ -1,4 +1,4 @@ -VERSION = 1.0 +VERSION = 1.1 PREFIX = /usr/local From 60b81ce41fda582b9a1263f40c9ca6a35761ebfc Mon Sep 17 00:00:00 2001 From: Zack Landau Date: Thu, 21 Nov 2013 23:55:02 -0800 Subject: [PATCH 08/10] Update link to libdwarf.rb gist --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fc918f2..54d23d6 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)" ```sh brew install binutils -brew install https://gist.github.com/zlandau/7550479/raw/b084adb5506b186b520783bd69f92996cf2dada8/libdwarf.rb +brew install https://gist.github.com/zlandau/7550479/raw/f72753f6a59f6a3fadf9a2e2952a9f6846c15a8d/libdwarf.rb ``` #### Update config.mk.local From 6ff0a7369b48dfce71bebc3e5a4d7e58f3b17b00 Mon Sep 17 00:00:00 2001 From: Zack Landau Date: Fri, 22 Nov 2013 00:16:59 -0800 Subject: [PATCH 09/10] Add Travis-CI build status to README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 54d23d6..2991985 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,8 @@ __atosl__ is a partial replacement for Apple's atos tool for converting addresses within a binary file to symbols. +[![Build Status](https://travis-ci.org/facebook/atosl.png?branch=master)](https://travis-ci.org/facebook/atos) + ## Why The primary benefit of atosl is its ability to run on other platforms. From a5b8d1ff364ddb3674b995af6ea9024503ca8780 Mon Sep 17 00:00:00 2001 From: Zack Landau Date: Fri, 22 Nov 2013 00:17:14 -0800 Subject: [PATCH 10/10] Improve Travis CI config - Add clang as a compiler - Add './atosl --version' as a basic sanity test --- .travis.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 69b94b4..772854c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,10 @@ language: c +compiler: + - clang + - gcc before_install: - sudo apt-get update -qq - sudo apt-get install -qq binutils-dev libdwarf-dev -script: make +script: + - make + - ./atosl --version