I can't use svn protocol, because my firewall permits only the standard ports for ftp, http and https, etc. So, I accessed the filo-0.5 URI:
http://openbios.org/viewvc/trunk/filo-0.5/?root=FILO
Next, I clicked the "Download GNU tarball" link with URI:
http://openbios.org/viewvc/trunk/filo-0.5.tar.gz?root=FILO&view=tar
The file downloaded is trunk.tar.gz which extracts fine:
$ tar xvzf trunk.tar.gz
Target directory is trunk/filo-0.5 as expected.
Compilation issues:
Make is run once to create the default Config file and define the include/arch symlink. A second make invocation should build the file.elf target, but fatal compilation errors prevent this.
I'm using gcc v4.1.2 and make v3.81 (Knoppix 5.1.1). Is my toolchain too old?
Here is a log of the two make invocations mentioned above. The Config is not changed from the default generated, but will need to be changed to generate the desired target.
------
The errors that occur using the default Config generated from i386/defconfig without making any changes to Config or the filo-0.5 source files:
$ make rm -f include/arch ln -s ../i386/include include/arch test -f Config && mv Config Config.bak || true cat defconfig i386/defconfig >>Config *** Default Config file is created *** *** Now you examine this file and edit it as you like *** $ make Makefile:64: warning: overriding commands for target `clean' makerules:46: warning: ignoring old commands for target `clean' echo '#define PROGRAM_NAME "FILO"' > main/version.h echo '#define PROGRAM_VERSION "0.5.5 (fuchsk@Knoppix) Mon Jun 9 12:42:45 EDT 2008"' >> main/version.h make -C main make[1]: Entering directory `/mnt/s2u1/atom/cb/trunk/filo-0.5/main' /bin/echo -e '/* GENERATED FILE, DO NOT EDIT */\n' >../config.h sed -e 's/#.*//' -e '/=/!d' -e 's/([^[:space:]]*)[[:space:]]*=[[:space:]]*(.*).*/#define \1 \2/' -e 's/^#define ([^ ]*) 0$/#undef \1/' ../Config >>../config.h gcc -m32 -Wall -Os -fomit-frame-pointer -fno-common -ffreestanding -fno-strict-aliasing -Wno-unused -nostdinc -imacros ../config.h -I../include -I/usr/lib/gcc/i486-linux-gnu/4.1.2/include -MD -c filo.c -o filo.o gcc -m32 -Wall -Os -fomit-frame-pointer -fno-common -ffreestanding -fno-strict-aliasing -Wno-unused -nostdinc -imacros ../config.h -I../include -I/usr/lib/gcc/i486-linux-gnu/4.1.2/include -MD -c linuxbios.c -o linuxbios.o gcc -m32 -Wall -Os -fomit-frame-pointer -fno-common -ffreestanding -fno-strict-aliasing -Wno-unused -nostdinc -imacros ../config.h -I../include -I/usr/lib/gcc/i486-linux-gnu/4.1.2/include -MD -c malloc.c -o malloc.o malloc.c: In function 'allot2': malloc.c:206: warning: assignment makes integer from pointer without a cast gcc -m32 -Wall -Os -fomit-frame-pointer -fno-common -ffreestanding -fno-strict-aliasing -Wno-unused -nostdinc -imacros ../config.h -I../include -I/usr/lib/gcc/i486-linux-gnu/4.1.2/include -MD -c printf.c -o printf.o printf.c: In function 'vtxprintf': printf.c:197: error: 'se' undeclared (first use in this function) printf.c:197: error: (Each undeclared identifier is reported only once printf.c:197: error: for each function it appears in.) printf.c:197: error: 'value' undeclared (first use in this function) printf.c:198: error: 'cp' undeclared (first use in this function) printf.c:199: warning: no return statement in function returning non-void printf.c: At top level: printf.c:200: error: expected identifier or '(' before 'if' printf.c:202: error: expected identifier or '(' before 'return' printf.c:203: error: expected identifier or '(' before '}' token printf.c:206: error: redefinition of 'simple_strtoll' printf.c:60: error: previous definition of 'simple_strtoll' was here printf.c: In function 'simple_strtoll': printf.c:209: error: expected ')' before 'flags' printf.c:214: error: too few arguments to function 'simple_strtoull' printf.c:214: error: expected ';' before '}' token printf.c: At top level: printf.c:217: warning: data definition has no type or storage class printf.c:217: warning: type defaults to 'int' in declaration of 'field_width' printf.c:218: error: expected identifier or '(' before 'if' printf.c:220: error: expected identifier or '(' before 'else' printf.c:231: warning: data definition has no type or storage class printf.c:231: warning: type defaults to 'int' in declaration of 'precision' printf.c:232: error: expected identifier or '(' before 'if' printf.c:246: warning: data definition has no type or storage class printf.c:246: warning: type defaults to 'int' in declaration of 'qualifier' printf.c:247: error: expected identifier or '(' before 'if' printf.c:253: warning: data definition has no type or storage class printf.c:253: warning: type defaults to 'int' in declaration of 'base' printf.c:255: error: expected identifier or '(' before 'switch' printf.c:331: error: expected identifier or '(' before 'if' printf.c:333: error: expected identifier or '(' before 'else' printf.c:335: error: expected identifier or '(' before 'else' printf.c:339: error: expected identifier or '(' before 'else' printf.c:341: error: expected identifier or '(' before 'else' printf.c:343: error: expected '=', ',', ';', 'asm' or '__attribute__' before '+=' token printf.c:344: error: expected identifier or '(' before '}' token printf.c:345: error: expected identifier or '(' before 'return' printf.c:346: error: expected identifier or '(' before '}' token make[1]: *** [printf.o] Error 1 make[1]: Leaving directory `/mnt/s2u1/atom/cb/trunk/filo-0.5/main' make: *** [main/builtin.o] Error 2
Thanks,
Ken Fuchs
gcc -m32 -Wall -Os -fomit-frame-pointer -fno-common -ffreestanding -fno-strict-aliasing -Wno-unused -nostdinc -imacros ../config.h -I../include -I/usr/lib/gcc/i486-linux-gnu/4.1.2/include -MD -c printf.c -o printf.o
What does this with -E show? This is really weird.
ron
ron minnich wrote:
gcc -m32 -Wall -Os -fomit-frame-pointer -fno-common -ffreestanding -fno-strict-aliasing -Wno-unused -nostdinc -imacros ../config.h -I../include -I/usr/lib/gcc/i486-linux-gnu/4.1.2/include -MD -c printf.c -o printf.o
What does this with -E show? This is really weird.
With -E, the compilation produces (without warnings or errors) the following preprocessor output appended below my sig.
Thanks,
Ken Fuchs
------
# 1 "printf.c" # 1 "<built-in>" # 1 "<command line>" # 1 "./../config.h" 1 # 1 "<command line>" 2 # 1 "printf.c" # 16 "printf.c" # 1 "/usr/lib/gcc/i486-linux-gnu/4.1.2/include/stdarg.h" 1 # 43 "/usr/lib/gcc/i486-linux-gnu/4.1.2/include/stdarg.h" typedef __builtin_va_list __gnuc_va_list; # 105 "/usr/lib/gcc/i486-linux-gnu/4.1.2/include/stdarg.h" typedef __gnuc_va_list va_list; # 17 "printf.c" 2 # 1 "../include/lib.h" 1
# 1 "/usr/lib/gcc/i486-linux-gnu/4.1.2/include/stddef.h" 1 # 152 "/usr/lib/gcc/i486-linux-gnu/4.1.2/include/stddef.h" typedef int ptrdiff_t; # 214 "/usr/lib/gcc/i486-linux-gnu/4.1.2/include/stddef.h" typedef unsigned int size_t; # 326 "/usr/lib/gcc/i486-linux-gnu/4.1.2/include/stddef.h" typedef int wchar_t; # 5 "../include/lib.h" 2 # 1 "../include/arch/stdint.h" 1
typedef unsigned char uint8_t; typedef unsigned short uint16_t; typedef unsigned int uint32_t; typedef unsigned long long uint64_t;
typedef signed char int8_t; typedef signed short int16_t; typedef signed int int32_t; typedef signed long long int64_t; # 6 "../include/lib.h" 2
void vga_init(void); void vga_putchar(unsigned int c);
int kbd_havekey(void); int kbd_havechar(void); int kbd_getchar(void);
void serial_init(void); void serial_putchar(unsigned char c); int serial_havechar(void); int serial_getchar(void);
void console_init(void); int putchar(int c); int puts(const char *s); int printf(const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); int havekey(void); int havechar(void); int getchar(void); int getline(char *buf, int max);
extern int last_putchar;
void *malloc(size_t size); void free(void *ptr); void *calloc(size_t nmemb, size_t size); void *realloc(void *ptr, size_t size); void malloc_check(void); void malloc_diag(void); void *allot2(size_t size, unsigned int alignment); void forget2(void *ptr);
size_t strnlen(const char *src, size_t max); size_t strlen(const char *src); int strcmp(const char *s1, const char *s2); int memcmp(const void *s1, const void *s2, size_t n); void *memcpy(void *dest, const void *src, size_t n); void *memset(void *s, int c, size_t n); void *memmove(void *dest, const void *src, size_t n); int isspace(int c); int isdigit(int c); int tolower(int c); char *strdup(const char *s); char *strchr(const char *s, int c); char *strncpy(char *to, const char *from, int count); char * strcpy (char *dest, const char *src); char * strstr (const char *s1, const char *s2); int strncat (char *s1, const char *s2, int n); int sprintf(char * buf, const char *fmt, ...);
unsigned long long simple_strtoull(const char *cp,char **endp,unsigned int base); unsigned long long strtoull_with_suffix(const char *cp,char **endp,unsigned int base);
unsigned int get_le32(const unsigned char *); unsigned int get_le16(const unsigned char *); void hexdump(const void *p, unsigned int len);
long long simple_strtoll(const char *cp,char **endp,unsigned int base);
void halt(void) __attribute__((noreturn));
struct sys_info; int elf_load(struct sys_info *, const char *filename, const char *cmdline);
int linux_load(struct sys_info *, const char *filename, const char *cmdline); # 18 "printf.c" 2 # 26 "printf.c" static inline unsigned char __toupper(unsigned char c) { if (((c) >= 'a' && (c) <= 'z')) c -= 'a'-'A'; return c; }
unsigned long long simple_strtoull(const char *cp,char **endp,unsigned int base) { unsigned long long result = 0,value;
if (!base) { base = 10; if (*cp == '0') { base = 8; cp++; if ((*cp == 'x') && (((cp[1]) >= '0' && (cp[1]) <= '9') || ((cp[1])
= 'a' && (cp[1]) <= 'f') || ((cp[1]) >= 'A' && (cp[1]) <= 'F'))) {
cp++; base = 16; } } } while ((((*cp) >= '0' && (*cp) <= '9') || ((*cp) >= 'a' && (*cp) <= 'f') || ((*cp) >= 'A' && (*cp) <= 'F')) && (value = ((*cp) >= '0' && (*cp) <= '9') ? *cp-'0' : (((*cp) >= 'a' && (*cp) <= 'z') ? __toupper(*cp) : *cp)-'A'+10) < base) { result = result*base + value; cp++; } if (endp) *endp = (char *)cp; return result; }
long long simple_strtoll(const char *cp,char **endp,unsigned int base) { if(*cp=='-') return -simple_strtoull(cp+1,endp,base); return simple_strtoull(cp,endp,base); }
unsigned long long strtoull_with_suffix(const char *cp,char **endp,unsigned int base) { unsigned long long result;
if (!endp) { printf("%s must be called with endp\n", __FUNCTION__); return 0; } result = simple_strtoull(cp, endp, base); switch (__toupper(**endp)) { case 'K': result <<= 10; ++*endp; break; case 'M': result <<= 20; ++*endp; break; case 'G': result <<= 30; ++*endp; break; } return result; }
static int skip_atoi(const char **s) { int i=0;
while (((**s) >= '0' && (**s) <= '9')) i = i*10 + *((*s)++) - '0'; return i; } # 116 "printf.c" static int number(int (*tx_byte)(int byte), long long num, int base, int size, int precision ,int type) { char c,sign,tmp[66]; const char *digits="0123456789abcdefghijklmnopqrstuvwxyz"; int i; int count = 0;
if (type & 64) digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; if (type & 16) type &= ~1; if (base < 2 || base > 36) return 0; c = (type & 1) ? '0' : ' '; sign = 0; if (type & 2) { if (num < 0) { sign = '-'; num = -num; size--; } else if (type & 4) { sign = '+'; size--; } else if (type & 8) { sign = ' '; size--; } } if (type & 32) { if (base == 16) size -= 2; else if (base == 8) size--; } i = 0; if (num == 0) tmp[i++]='0'; else while (num != 0) tmp[i++] = digits[({ int __res; __res = ((unsigned long long) num) % (unsigned) base; num = ((unsigned long long) num) / (unsigned) base; __res; })]; if (i > precision) precision = i; size -= precision; if (!(type&(1 +16))) while(size-->0) tx_byte(' '), count++; if (sign) tx_byte(sign), count++; if (type & 32) { if (base==8) tx_byte('0'), count++; else if (base==16) { tx_byte('0'), count++; tx_byte(digits[33]), count++; } } if (!(type & 16)) while (size-- > 0) tx_byte(c), count++; while (i < precision--) tx_byte('0'), count++; while (i-- > 0) tx_byte(tmp[i]), count++; while (size-- > 0) tx_byte(' '), count++; return count; }
int vtxprintf(int (*tx_byte)(int byte), const char *fmt, va_list args) { int len; unsigned long long num; int i, base; const char *s;
int flags;
int field_width; int precision;
int qualifier; se + value; cp++; } if (endp) *endp = (char *)cp; return result; }
long long simple_strtoll(const char *cp,char **endp,unsigned int base) { if(*cp=='-') return -simple_strtoull(cp+1,endp,base); return simple_strtoull(cp,endp flags |= 16; goto repeat; case '+': flags |= 4; goto repeat; case ' ': flags |= 8; goto repeat; case '#': flags |= 32; goto repeat; case '0': flags |= 1; goto repeat; }
field_width = -1; if (((*fmt) >= '0' && (*fmt) <= '9')) field_width = skip_atoi(&fmt); else if (*fmt == '*') { ++fmt;
field_width = __builtin_va_arg(args,int); if (field_width < 0) { field_width = -field_width; flags |= 16; } }
precision = -1; if (*fmt == '.') { ++fmt; if (((*fmt) >= '0' && (*fmt) <= '9')) precision = skip_atoi(&fmt); else if (*fmt == '*') { ++fmt;
precision = __builtin_va_arg(args,int); } if (precision < 0) precision = 0; }
qualifier = -1; if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L') { qualifier = *fmt; ++fmt; }
base = 10;
switch (*fmt) { case 'c': if (!(flags & 16)) while (--field_width > 0) tx_byte(' '), count++; tx_byte((unsigned char) __builtin_va_arg(args,int)), count++; while (--field_width > 0) tx_byte(' '), count++; continue;
case 's': s = __builtin_va_arg(args,char *); if (!s) s = "<NULL>";
len = strnlen(s, precision);
if (!(flags & 16)) while (len < field_width--) tx_byte(' '), count++; for (i = 0; i < len; ++i) tx_byte(*s++), count++; while (len < field_width--) tx_byte(' '), count++; continue;
case 'p': if (field_width == -1) { field_width = 2*sizeof(void *); flags |= 1; } count += number(tx_byte, (unsigned long) __builtin_va_arg(args,void *), 16, field_width, precision, flags); continue;
case 'n': if (qualifier == 'l') { long * ip = __builtin_va_arg(args,long *); *ip = count; } else { int * ip = __builtin_va_arg(args,int *); *ip = count; } continue;
case '%': tx_byte('%'), count++; continue;
case 'o': base = 8; break;
case 'X': flags |= 64; case 'x': base = 16; break;
case 'd': case 'i': flags |= 2; case 'u': break;
default: tx_byte('%'), count++; if (*fmt) tx_byte(*fmt), count++; else --fmt; continue; } if (qualifier == 'L') num = __builtin_va_arg(args,unsigned long long); else if (qualifier == 'l') num = __builtin_va_arg(args,unsigned long); else if (qualifier == 'h') { num = (unsigned short) __builtin_va_arg(args,int); if (flags & 2) num = (short) num; } else if (flags & 2) num = __builtin_va_arg(args,int); else num = __builtin_va_arg(args,unsigned int); count += number(tx_byte, num, base, field_width, precision, flags); } return count; }
static char *str_buf; static int str_tx_byte(int byte) { *str_buf = byte; str_buf++; return byte; }
int vsprintf(char * buf, const char *fmt, va_list args) { int i; str_buf = buf; i = vtxprintf(str_tx_byte, fmt, args);
*str_buf = '\0'; return i; }
int sprintf(char * buf, const char *fmt, ...) { va_list args; int i;
__builtin_va_start(args,fmt); i=vsprintf(buf,fmt,args); __builtin_va_end(args); return i; }
int printf(const char *fmt, ...) { va_list args; int i;
__builtin_va_start(args,fmt); i = vtxprintf(putchar, fmt, args); __builtin_va_end(args); return i; }