From 8f7d369dd47897694fa3b2c30144a93d0b6def08 Mon Sep 17 00:00:00 2001 From: Detlef Riekenberg Date: Sat, 30 Mar 2024 16:16:53 +0100 Subject: [PATCH 1/2] makefiles: Allow to overwrite CC/CFLAGS, CPP, AR/ARFLAGS and LDFLAGS Now, building with a different Toolchain is possible -- Regards ... Detlef --- ebfc/Makefile | 8 +++++--- elfls/Makefile | 4 ++-- elfrw/Makefile | 8 +++++--- elftoc/Makefile | 7 ++++--- infect/Makefile | 4 ++-- objres/Makefile | 6 +++--- rebind/Makefile | 4 ++-- sstrip/Makefile | 4 ++-- 8 files changed, 25 insertions(+), 20 deletions(-) diff --git a/ebfc/Makefile b/ebfc/Makefile index b90077e..fb75624 100644 --- a/ebfc/Makefile +++ b/ebfc/Makefile @@ -1,7 +1,9 @@ # Makefile for ebfc -CC = gcc -CFLAGS = -Wall -Wextra -Wno-missing-field-initializers +CC ?= gcc +CFLAGS ?= -Wall -Wextra -Wno-missing-field-initializers +AR ?= ar +ARFLAGS ?= crs # The main program. @@ -15,7 +17,7 @@ brainfuck.o: brainfuck.c elfparts.h ebfc.h libelfparts.a: elfparts.o \ ehdr.o phdrtab.o shdrtab.o progbits.o \ strtab.o symtab.o hash.o rel.o got.o dynamic.o - ar crs libelfparts.a $^ + $(AR) $(ARFLAGS) libelfparts.a $^ elfparts.o: elfparts.c elfparts.h elfpartsi.h ehdr.o: ehdr.c elfparts.h elfpartsi.h diff --git a/elfls/Makefile b/elfls/Makefile index 2161b50..1ca41f9 100644 --- a/elfls/Makefile +++ b/elfls/Makefile @@ -1,7 +1,7 @@ # Makefile for elfls -CC = gcc -CFLAGS = -Wall -Wextra -I../elfrw +CC ?= gcc +CFLAGS ?= -Wall -Wextra -I../elfrw elfls: elfls.c ../elfrw/libelfrw.a diff --git a/elfrw/Makefile b/elfrw/Makefile index ba59129..f32141a 100644 --- a/elfrw/Makefile +++ b/elfrw/Makefile @@ -1,13 +1,15 @@ # Makefile for libelfrw.a -CC = gcc -CFLAGS = -Wall -Wextra -O3 +CC ?= gcc +CFLAGS ?= -Wall -Wextra -O3 +AR ?= ar +ARFLAGS ?= crs LIBOBJS = elfrw.o elfrw_dyn.o elfrw_ehdr.o elfrw_phdr.o elfrw_rel.o \ elfrw_shdr.o elfrw_sym.o elfrw_ver.o libelfrw.a: $(LIBOBJS) - ar crs $@ $^ + $(AR) $(ARFLAGS) $@ $^ elfrw.o: elfrw.c elfrw.h elfrw_int.h elfrw_dyn.o: elfrw_dyn.c elfrw_int.h diff --git a/elftoc/Makefile b/elftoc/Makefile index fc31454..7579043 100644 --- a/elftoc/Makefile +++ b/elftoc/Makefile @@ -1,8 +1,9 @@ # Makefile for elftoc -CC = gcc -CFLAGS = -Wall -Wextra -LDFLAGS = -Wall -Wextra +CC ?= gcc +CFLAGS ?= -Wall -Wextra +LDFLAGS ?= -Wall -Wextra +CPP ?= $(CC) -E OBJS = gen.o names.o address.o readelf.o shdrtab.o phdrtab.o dynamic.o \ pieces.o outbase.o outitems.o outelf64.o outelf32.o out.o elftoc.o diff --git a/infect/Makefile b/infect/Makefile index e47cddd..250a3f8 100644 --- a/infect/Makefile +++ b/infect/Makefile @@ -1,7 +1,7 @@ # Makefile for infect -CC = gcc -CFLAGS = -Wall -Wextra +CC ?= gcc +CFLAGS ?= -Wall -Wextra infect: infect.c diff --git a/objres/Makefile b/objres/Makefile index 88cdf88..5378ba4 100644 --- a/objres/Makefile +++ b/objres/Makefile @@ -1,8 +1,8 @@ # Makefile for objres -CC = gcc -CFLAGS = -Wall -Wextra -I../elfrw -LDFLAGS = -Wall -Wextra +CC ?= gcc +CFLAGS ?= -Wall -Wextra -I../elfrw +LDFLAGS ?= -Wall -Wextra objres: objres.o ../elfrw/libelfrw.a diff --git a/rebind/Makefile b/rebind/Makefile index 77b084e..023e1b5 100644 --- a/rebind/Makefile +++ b/rebind/Makefile @@ -1,7 +1,7 @@ # Makefile for rebind -CC = gcc -CFLAGS = -Wall -Wextra -I../elfrw +CC ?= gcc +CFLAGS ?= -Wall -Wextra -I../elfrw rebind: rebind.c ../elfrw/libelfrw.a diff --git a/sstrip/Makefile b/sstrip/Makefile index 44cc017..86b32e3 100644 --- a/sstrip/Makefile +++ b/sstrip/Makefile @@ -1,7 +1,7 @@ # Makefile for sstrip -CC = gcc -CFLAGS = -Wall -Wextra -I../elfrw +CC ?= gcc +CFLAGS ?= -Wall -Wextra -I../elfrw sstrip: sstrip.c ../elfrw/libelfrw.a From beacc276e56ac7eeed35e6f87bab64d5c486e9dd Mon Sep 17 00:00:00 2001 From: Detlef Riekenberg Date: Sat, 30 Mar 2024 16:21:49 +0100 Subject: [PATCH 2/2] elfls.c: Increase buffers to avoid compiler warnings on x86_64-linux -- Regards ... Detlef --- elfls/elfls.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/elfls/elfls.c b/elfls/elfls.c index 8d5fef3..c3f3577 100644 --- a/elfls/elfls.c +++ b/elfls/elfls.c @@ -78,9 +78,9 @@ static int ldepls = FALSE; /* TRUE = show libraries */ static int dostrs = TRUE; /* TRUE = show entry strings */ static int dooffs = TRUE; /* TRUE = show file offsets */ -static char sizefmt[8]; /* num digits to show sizes */ -static char addrfmt[8]; /* num digits to show addresses */ -static char offsetfmt[8]; /* num digits to show offsets */ +static char sizefmt[16]; /* num digits to show sizes */ +static char addrfmt[16]; /* num digits to show addresses */ +static char offsetfmt[16]; /* num digits to show offsets */ static int outwidth; /* maximum width of output */ /* The error-reporting function.