From patchwork Thu Aug 4 04:52:45 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Breeds X-Patchwork-Id: 108348 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id 8B86BB6F87 for ; Thu, 4 Aug 2011 14:52:46 +1000 (EST) Received: by ozlabs.org (Postfix, from userid 1026) id 08398B6F69; Thu, 4 Aug 2011 14:52:45 +1000 (EST) Date: Thu, 4 Aug 2011 14:52:45 +1000 From: Tony Breeds To: Douglas Mencken Subject: Re: link problem solved! Message-ID: <20110804045245.GX20597@ozlabs.org> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Cc: yaboot-devel@lists.ozlabs.org X-BeenThere: yaboot-devel@lists.ozlabs.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical and development discussion regarding yaboot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: yaboot-devel-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: yaboot-devel-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org On Sat, Jul 16, 2011 at 12:32:50AM +0400, Douglas Mencken wrote: > Finally, I found a workaround for "undefined reference to `getenv', > `stdout', `printf', `fputs', ..." problem. > > The solution is to link with libc too (it's not auto-linked in the > case of static linking, unlike dyn-linking; and e2fsprogs static lib > doesn't include all the libc stuff in it, even in .a ar, i.e. static > lib). > sed -i 's/LLIBS.*=.*-lext2fs/LLIBS = -lext2fs -lc/' ./Makefile Yes we really don't want to link agasit the system libc. Please try this patch (on top of http://patchwork.ozlabs.org/patch/77840/) It works for me on debian sid. commit 12b4fd99d0921d202f595ee4e4c3470d889ef250 Author: Tony Breeds Date: Thu Aug 4 14:31:46 2011 +1000 Add some "hacky" workarounds for missing libc functions required by libext2fs Signed-off-by: Tony Breeds Yours Tony diff --git a/Makefile b/Makefile index f549977..b46165f 100644 --- a/Makefile +++ b/Makefile @@ -84,6 +84,7 @@ OBJS = second/crt0.o second/yaboot.o second/cache.o second/prom.o second/file.o second/partition.o second/fs.o second/cfg.o second/setjmp.o second/cmdline.o \ second/fs_of.o second/fs_ext2.o second/fs_iso.o second/fs_swap.o \ second/iso_util.o \ + lib/nonstd.o \ lib/nosys.o lib/string.o lib/strtol.o lib/vsprintf.o lib/ctype.o lib/malloc.o lib/strstr.o ifeq ($(USE_MD5_PASSWORDS),y) diff --git a/include/nonstd.h b/include/nonstd.h new file mode 100644 index 0000000..2f49d3e --- /dev/null +++ b/include/nonstd.h @@ -0,0 +1,16 @@ +/* Copyright */ + +#ifndef NONSTD_H +#define NONSTD_H + +typedef int FILE; + +extern FILE *stdout; + +int printf(const char *format, ...); +int fprintf(FILE *stream, const char *format, ...); +int fputs(const char *s, FILE *stream); +int fflush(FILE *stream); +char *getenv(const char *name); + +#endif diff --git a/lib/nonstd.c b/lib/nonstd.c new file mode 100644 index 0000000..aec5b05 --- /dev/null +++ b/lib/nonstd.c @@ -0,0 +1,49 @@ +/* Copyright */ + + +#include "ctype.h" +#include "types.h" +#include "stddef.h" +#include "stdlib.h" +#include "ctype.h" +#include "prom.h" +#include "nonstd.h" + +FILE *stdout; + +int printf(const char *format, ...) +{ + va_list ap; + va_start (ap, format); + prom_vfprintf (prom_stdout, format, ap); + va_end (ap); + + return 0; +} + +int fprintf(FILE *stream, const char *format, ...) +{ + va_list ap; + va_start (ap, format); + prom_vfprintf (prom_stdout, format, ap); + va_end (ap); + + return 0; +} + +int fputs(const char *s, FILE *stream) +{ + prom_printf("%s", s); + + return 0; +} + +int fflush(FILE *stream) +{ + return 0; +} + +char *getenv(const char *name) +{ + return NULL; +}