tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Tinycc-devel] fixes for uClibc build


From: Zdenek Pavlas
Subject: [Tinycc-devel] fixes for uClibc build
Date: Mon, 27 Jun 2005 12:36:31 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050513 Debian/1.7.8-1

Hello,

Please consider following patches.

Float parsing code in tcc.c uses ldexp(), but there's no -lm
in $LDFLAGS.  LIBC inlines most of math.h functions by default
but uClibc does not, so force inlining.

--- tcc-0.9.23/tcc.c
+++ tcc/tcc.c
@@ -32,7 +32,13 @@
 #include <stdarg.h>
 #include <string.h>
 #include <errno.h>
+#if defined __UCLIBC__ && defined __i386__
+#  define __USE_EXTERN_INLINES /* want inlined ldexp() */
+#  include <math.h>
+#  undef  __USE_EXTERN_INLINES
+#else
 #include <math.h>
+#endif
 #include <unistd.h>
 #include <signal.h>
 #include <fcntl.h>

Fix a bug in tcc_add_file_internal() which prevents recognition
of archive files that are smaller than sizeof(ElfXX_Ehdr).

--- tcc-0.9.23/tcc.c
+++ tcc/tcc.c
@@ -9893,14 +9899,13 @@
         /* assume executable format: auto guess file type */
         ret = read(fd, &ehdr, sizeof(ehdr));
         lseek(fd, 0, SEEK_SET);
-        if (ret <= 0) {
+        if (ret < 8) {
             error_noabort("could not read header");
             goto fail;
-        } else if (ret != sizeof(ehdr)) {
-            goto try_load_script;
         }

-        if (ehdr.e_ident[0] == ELFMAG0 &&
+        if (ret == sizeof(ehdr) &&
+            ehdr.e_ident[0] == ELFMAG0 &&
             ehdr.e_ident[1] == ELFMAG1 &&
             ehdr.e_ident[2] == ELFMAG2 &&
             ehdr.e_ident[3] == ELFMAG3) {

uClibc uses yet another name for it's dynamic linker.

--- tcc-0.9.23/tccelf.c
+++ tcc/tccelf.c
@@ -1063,6 +1063,8 @@
 /* name of ELF interpreter */
 #ifdef __FreeBSD__
 static char elf_interp[] = "/usr/libexec/ld-elf.so.1";
+#elif defined __UCLIBC__
+static char elf_interp[] = "/lib/ld-uClibc.so.0";
 #else
 static char elf_interp[] = "/lib/ld-linux.so.2";
 #endif

Malloc hooks have to be either disabled in bcheck.c or (better)
added to uClibc's malloc implementation. TCC then builds fine.

regards,

--
Zdenek Pavlas




reply via email to

[Prev in Thread] Current Thread [Next in Thread]