summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedrich Oslage <ben.collins@canonical.com>2008-08-21 10:27:48 -0400
committerBen Collins <ben.collins@canonical.com>2008-08-21 10:27:48 -0400
commita55764ceef83086d00b5f7b8b3027b517fc4ca23 (patch)
tree59f2b4e2c8566544885308429ff3c5eb28b9130a
parenteb6151388752b52804f80ff27e90ec2dbde71339 (diff)
downloadsilo-a55764ceef83086d00b5f7b8b3027b517fc4ca23.tar.gz
Include libgcc.a to get __ffssi2 and add a simple sprintf function to fix these undefined references when compiling with GCC-4.3:
/usr/bin/../lib/libext2fs.a(inline.o): In function `ext2fs_find_next_bit_set': (.text+0x4f8): undefined reference to `__ffssi2' /usr/bin/../lib/libext2fs.a(inline.o): In function `ext2fs_find_next_bit_set': (.text+0x518): undefined reference to `__ffssi2' /usr/bin/../lib/libext2fs.a(inline.o): In function `ext2fs_find_next_bit_set': (.text+0x544): undefined reference to `__ffssi2' /usr/bin/../lib/libext2fs.a(inline.o): In function `ext2fs_find_first_bit_set': (.text+0x5a8): undefined reference to `__ffssi2' /usr/bin/../lib/libext2fs.a(inline.o): In function `ext2fs_find_first_bit_set': (.text+0x5d8): undefined reference to `__ffssi2' /usr/bin/../lib/libext2fs.a(rw_bitmaps.o): In function `read_bitmaps': (.text+0x46c): undefined reference to `sprintf' /usr/bin/../lib/libext2fs.a(rw_bitmaps.o): In function `read_bitmaps': (.text+0x664): undefined reference to `sprintf' Signed-off-by: Friedrich Oslage <bluebird@gentoo.org> Signed-off-by: Ben Collins <ben.collins@canonical.com>
-rw-r--r--common/printf.c89
-rw-r--r--include/silo.h2
-rw-r--r--second/Makefile8
3 files changed, 95 insertions, 4 deletions
diff --git a/common/printf.c b/common/printf.c
index eed5da2..0d6d84c 100644
--- a/common/printf.c
+++ b/common/printf.c
@@ -21,6 +21,7 @@
USA. */
#include "promlib.h"
+#include <stringops.h>
/*
* This part is rewritten by Igor Timkin <ivt@msu.su>. Than I
@@ -147,3 +148,91 @@ void prom_printf (char *fmt,...)
vprintf (fmt, x1);
va_end (x1);
}
+
+static int sprintn (char *str, long long n, int b)
+{
+ static char prbuf[33];
+ register char *cp;
+ int count = 0;
+
+ if (b == 10 && n < 0) {
+ memset (str + count, '-', 1);
+ count++;
+ n = -n;
+ }
+ cp = prbuf;
+ do
+ *cp++ = "0123456789ABCDEF"[(unsigned int) (((unsigned long)n) % b)];
+ while ((n = ((unsigned long long)n) / b & 0x0FFFFFFFFFFFFFFFULL));
+ do {
+ memset (str + count, *--cp, 1);
+ count++;
+ } while (cp > prbuf);
+
+ return count;
+}
+
+int vsprintf (char *str, char *fmt, va_list adx)
+{
+ register int c;
+ char *s;
+ int count = 0;
+
+ for (;;) {
+ while ((c = *fmt++) != '%') {
+ memset (str + count, c, 1);
+ if (c == '\0') {
+ return count;
+ }
+ }
+ c = *fmt++;
+ if (c == 'd' || c == 'o' || c == 'x' || c == 'X') {
+ count += sprintn (str + count, (long long) va_arg (adx, unsigned),
+ c == 'o' ? 8 : (c == 'd' ? 10 : 16));
+ } else if (c == 'c') {
+ memset (str + count, va_arg (adx, unsigned), 1);
+ count++;
+ } else if (c == 's') {
+ if ((s = va_arg (adx, char *)) == NULL)
+ s = (char *)"(null)";
+ while ((c = *s++)) {
+ memset (str + count, c, 1);
+ count++;
+ }
+ } else if (c == 'l' || c == 'O') {
+ count += sprintn (str + count, (long long) va_arg (adx, long), c == 'l' ? 10 : 8);
+ } else if (c == 'L') {
+ int hex = 0;
+ if (*fmt == 'x') {
+ fmt++;
+ hex = 1;
+ }
+ count += sprintn (str + count, (long long) va_arg (adx, long long), hex ? 16 : 10);
+ } else {
+ /* This is basically what libc's printf does */
+ memset (str + count, '%', 1);
+ count++;
+ memset (str + count, c, 1);
+ count++;
+ }
+ }
+
+ return count;
+}
+
+/*
+ * Scaled down version of C Library sprintf.
+ * Only %c %s %d (==%u) %o %x %X %l %O are recognized.
+ */
+
+int sprintf (char *s, char *format, ...)
+{
+ va_list arg;
+ int done;
+
+ va_start (arg, format);
+ done = vsprintf (s, format, arg);
+ va_end (arg);
+
+ return done;
+}
diff --git a/include/silo.h b/include/silo.h
index 51c62e7..fe5adcb 100644
--- a/include/silo.h
+++ b/include/silo.h
@@ -87,6 +87,8 @@ int silo_disk_partitionable(void);
void silo_disk_close(void);
/* printf.c */
int vprintf (char *, va_list);
+int vsprintf (char *str, char *fmt, va_list adx);
+int sprintf (char *s, char *format, ...);
int putchar (int);
/* malloc.c */
void *malloc (int);
diff --git a/second/Makefile b/second/Makefile
index 3a7763d..ff4c8b5 100644
--- a/second/Makefile
+++ b/second/Makefile
@@ -58,13 +58,13 @@ fs/libfs.a: $(FS_OBJS)
$(AR) rc $@ $(FS_OBJS)
second: $(OBJS) mark.o
- $(LD) $(LDFLAGS_SMALL) -Bstatic -o second $(OBJS) -lext2fs mark.o
- $(LD) $(LDFLAGS_LARGE) -Bstatic -o second2 $(OBJS) -lext2fs mark.o
+ $(LD) $(LDFLAGS_SMALL) -Bstatic -o second $(OBJS) -lext2fs mark.o `$(CC) -print-libgcc-file-name`
+ $(LD) $(LDFLAGS_LARGE) -Bstatic -o second2 $(OBJS) -lext2fs mark.o `$(CC) -print-libgcc-file-name`
$(NM) second | grep -v '*ABS*' | sort > second.map
silotftp: $(OBJSNET) mark.o
- $(LD) $(LDFLAGS_SMALL) -Bstatic -o silotftp $(OBJSNET) -lext2fs mark.o
- $(LD) $(LDFLAGS_LARGE) -Bstatic -o silotftp2 $(OBJSNET) -lext2fs mark.o
+ $(LD) $(LDFLAGS_SMALL) -Bstatic -o silotftp $(OBJSNET) -lext2fs mark.o `$(CC) -print-libgcc-file-name`
+ $(LD) $(LDFLAGS_LARGE) -Bstatic -o silotftp2 $(OBJSNET) -lext2fs mark.o `$(CC) -print-libgcc-file-name`
$(NM) silotftp | grep -v '*ABS*' | sort > silotftp.map
second.l: second