summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile33
-rw-r--r--extra/Configs/Config.m68k.coff167
-rw-r--r--include/features.h23
-rw-r--r--include/unistd.h6
-rw-r--r--libc/misc/internals/__uClibc_main.c15
-rw-r--r--libc/stdlib/random.c3
-rw-r--r--libc/stdlib/unix_grantpt.c4
-rw-r--r--libc/string/string.c6
-rw-r--r--libc/string/strtok_r.c2
-rw-r--r--libc/sysdeps/linux/m68k/Makefile2
-rw-r--r--libc/sysdeps/linux/m68k/README.m68k10
-rw-r--r--libc/sysdeps/linux/m68k/bits/vfork.h31
-rw-r--r--libc/sysdeps/linux/m68k/crt0.S5
-rw-r--r--libc/sysdeps/linux/m68k/vfork.c25
14 files changed, 249 insertions, 83 deletions
diff --git a/Makefile b/Makefile
index a7b007801..8d524ee42 100644
--- a/Makefile
+++ b/Makefile
@@ -30,7 +30,7 @@
TOPDIR=./
include Rules.mak
-ifeq ($(LDSO_PRESENT), $(TARGET_ARCH))
+ifeq ($(DO_SHARED),shared)
LDSO_DIR = ldso
endif
DIRS = extra $(LDSO_DIR) libc libcrypt libresolv libutil libm
@@ -120,15 +120,10 @@ uClibc_config.h: Config
else \
echo "#undef __UCLIBC_HAS_LOCALE__" >> uClibc_config.h ; \
fi
- @if [ "$(TARGET_ARCH)" = "m68k" ] ; then \
- echo "#define __VFORK_MACRO__ 1" >> uClibc_config.h ; \
- if [ `expr "$(CC)" : ".*\(m68k-elf-.*\)"`x = x ]; then \
- echo "#define const" >> uClibc_config.h ; \
- echo "#define __const" >> uClibc_config.h ; \
- echo "#define __extension" >> uClibc_config.h ; \
- fi; \
+ @if [ "$(HAVE_ELF)" = "false" ] ; then \
+ echo "#undef HAVE_ELF" >> uClibc_config.h ; \
else \
- echo "#undef __VFORK_MACRO__" >> uClibc_config.h ; \
+ echo "#define HAVE_ELF 1" >> uClibc_config.h ; \
fi
@if [ "$(TARGET_ARCH)" = "sh" ] ; then \
echo "#define NO_UNDERSCORES 1" >> uClibc_config.h ; \
@@ -156,14 +151,14 @@ install_target:
ifeq ($(DO_SHARED),shared)
install -d $(TARGET_PREFIX)$(ROOT_DIR)/lib
cp -fa lib/*.so* $(TARGET_PREFIX)$(ROOT_DIR)/lib;
-endif
-ifeq ($(LDSO_PRESENT), $(TARGET_ARCH))
install -d $(TARGET_PREFIX)$(ROOT_DIR)/etc
install -d $(TARGET_PREFIX)$(ROOT_DIR)/sbin
install -d $(TARGET_PREFIX)$(ROOT_DIR)/usr/bin
cp -f ldso/util/ldd $(TARGET_PREFIX)$(ROOT_DIR)/usr/bin
cp -f ldso/util/ldconfig $(TARGET_PREFIX)$(ROOT_DIR)/sbin
-# -@if [ -x ldso/util/ldconfig ] ; then ldso/util/ldconfig; fi
+ifeq ($(NATIVE_ARCH), $(TARGET_ARCH))
+ -@if [ -x ldso/util/ldconfig ] ; then ldso/util/ldconfig; fi
+endif
endif
# Installs development library and headers
@@ -171,19 +166,19 @@ endif
# in $(DEVEL_PREFIX)$(ROOT_DIR)/include. Probably true only if you're using
# a packaging system.
install_dev:
+ install -d $(DEVEL_PREFIX)$(ROOT_DIR)/usr/lib
+ cp -fa lib/*.[ao] $(DEVEL_PREFIX)$(ROOT_DIR)/usr/lib;
ifeq ($(DO_SHARED),shared)
install -d $(DEVEL_PREFIX)$(ROOT_DIR)/lib
cp -fa lib/*.so* $(DEVEL_PREFIX)$(ROOT_DIR)/lib;
-endif
- install -d $(DEVEL_PREFIX)$(ROOT_DIR)/usr/lib
- cp -fa lib/*.[ao] $(DEVEL_PREFIX)$(ROOT_DIR)/usr/lib;
-ifeq ($(LDSO_PRESENT), $(TARGET_ARCH))
install -d $(DEVEL_PREFIX)$(ROOT_DIR)/etc
install -d $(DEVEL_PREFIX)$(ROOT_DIR)/sbin
install -d $(DEVEL_PREFIX)$(ROOT_DIR)/usr/bin
cp -f ldso/util/ldd $(DEVEL_PREFIX)$(ROOT_DIR)/usr/bin
cp -f ldso/util/ldconfig $(DEVEL_PREFIX)$(ROOT_DIR)/sbin
-# -@if [ -x ldso/util/ldconfig ] ; then ldso/util/ldconfig; fi
+ifeq ($(NATIVE_ARCH), $(TARGET_ARCH))
+ -@if [ -x ldso/util/ldconfig ] ; then ldso/util/ldconfig; fi
+endif
endif
install -d $(DEVEL_PREFIX)$(ROOT_DIR)/etc
install -d $(DEVEL_PREFIX)$(ROOT_DIR)/usr/include
@@ -200,12 +195,10 @@ endif
$(MAKE) -C extra/gcc-uClibc install
clean:
- @rm -rf tmp lib
+ @rm -rf tmp lib include/bits/uClibc_config.h uClibc_config.h
- find include -type l -exec rm -f {} \;
- find . \( -name \*.o -o -name \*.a -o -name \*.so -o -name core \) -exec rm -f {} \;
-ifeq ($(LDSO_PRESENT), $(TARGET_ARCH))
$(MAKE) -C ldso clean
-endif
.PHONY: dummy subdirs
diff --git a/extra/Configs/Config.m68k.coff b/extra/Configs/Config.m68k.coff
new file mode 100644
index 000000000..bb9fc3369
--- /dev/null
+++ b/extra/Configs/Config.m68k.coff
@@ -0,0 +1,167 @@
+# Library Configuration rules for uClibc
+#
+# This file contains rules which are shared between multiple Makefiles. Feel
+# free to adjust to taste...
+# -Erik Andersen <andersen@lineo.com> <andersee@debian.org>
+#
+# Copyright (C) 2000 by Lineo, inc.
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU Library General Public License as published by the Free
+# Software Foundation; either version 2 of the License, or (at your option) any
+# later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Library General Public License
+# along with this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Derived in part from the Linux-8086 C library, the GNU C Library, and several
+# other sundry sources. Files within this library are copyright by their
+# respective copyright holders.
+
+# What arch do you want to compile for...
+#TARGET_ARCH=arm
+#TARGET_ARCH=i386
+TARGET_ARCH=m68k
+#TARGET_ARCH=powerpc
+#TARGET_ARCH=sh
+#TARGET_ARCH=sparc
+
+# If you are running a cross compiler, you may want to set this
+# to something more interesting...
+NATIVE_CC = gcc
+CROSS = m68k-coff-
+CC = $(CROSS)gcc
+AR = $(CROSS)ar
+LD = $(CROSS)ld
+NM = $(CROSS)nm
+STRIPTOOL = $(CROSS)strip
+#STRIPTOOL = /bin/true
+
+# Set the following to `true' to make a debuggable build, and `false' for
+# production builds.
+DODEBUG = false
+
+# Compiler warnings you want to see
+WARNINGS=-Wall
+
+# Note that the kernel source you use to compile with should be the same as the
+# Linux kernel you run your apps on. uClibc doesn't even try to achieve binary
+# compatibility across kernel versions. So don't expect, for example, uClibc
+# compiled with Linux kernel 2.0.x to implement lchown properly, since 2.0.x
+# can't do that. Similarly, if you compile uClibc vs Linux 2.4.x kernel headers,
+# but then run on Linux 2.0.x, lchown will be compiled into uClibc, but won't
+# work at all. You have been warned.
+KERNEL_SOURCE=/opt/uClinux/linux
+
+# Set this to `false' if your CPU doesn't have a memory management unit (MMU).
+# Set it to `true' otherwise.
+HAS_MMU = false
+
+# Set this to `false' if you don't have/need basic floating point support
+# support in libc (strtod, printf, scanf). Set it to `true' otherwise.
+# Note: If not true, Rules.mak disables libm as well.
+HAS_FLOATING_POINT = false
+
+# Set this to `false' if you don't have/need float functions in libm.
+# Set it to `true' otherwise, and make sure HAS_FLOATING_POINT is true as well.
+HAS_LIBM_FLOAT = false
+
+# Set this to `false' if you don't have/need double functions in libm.
+# Set it to `true' otherwise, and make sure HAS_FLOATING_POINT is true as well.
+HAS_LIBM_DOUBLE = false
+
+# Set this to `false' if you don't have/need long double functions in libm.
+# Set it to `true' otherwise, and make sure HAS_FLOATING_POINT is true as well.
+HAS_LIBM_LONG_DOUBLE = false
+
+# Set this to `false' if you don't have/need "(unsigned) long long int" support.
+# Set it to `true' otherwise.
+# Affects *printf and *scanf functions.
+# Also omits strto(u)ll, and (u)lltostr from the library if `false'.
+HAS_LONG_LONG = true
+
+# Set this to `false' if you don't have/need locale support; `true' otherwise.
+# Note: Currently only affects the ctype functions. You must also generate
+# a locale file for anything but the C locale. See directory extra/locale for
+# a utility to do so. Also see the following option.
+HAS_LOCALE = false
+
+# Set this to the path of your uClibc locale file directory.
+# Warning! This must be different than the glibc locale directory to avoid
+# name conflicts, as the locale files are entirely different in format!
+LOCALE_DIR = "/usr/share/uClibc-locale/"
+
+# This specifies which malloc implementation is used.
+# "malloc-simple" is very, very small, but is also very, very dumb
+# and does not try to make good use of memory or clean up after itself.
+#
+# "malloc" on the other hand is a bit bigger, but is pretty smart thereby
+# minimizing memory wastage and reusing already allocated memory. This
+# can be lots faster and safer IMHO.
+#
+# "malloc-930716" is from libc-5.3.12 and was/is the standard gnu malloc.
+# It is actually smaller than "malloc", at least on i386. Right now, it
+# only works on i386 (and maybe m68k) because it needs sbrk.
+MALLOC = malloc-simple
+#MALLOC = malloc
+#MALLOC = malloc-930716
+
+# If you want to collect common syscall code into one function, set to this to
+# `true'. Set it to false otherwise.
+# On i386 this saves about than 2.8k over all syscalls.
+# The idea came from the implementation in dietlibc.
+# At present, only affects i386.
+UNIFIED_SYSCALL = false
+
+# If you want large file summit support (greater then 2 Gib),
+# turn this on. This has no effect unless your kernel supports
+# lfs. This currently does nothing, but may someday...
+DOLFS = false
+
+# If you want to include RPC support, enable this. RPC is almost never used
+# for anything except NFS support, so unless you plan to use NFS, leave this
+# disabled. This is off by default.
+INCLUDE_RPC = true
+
+# ROOT_DIR is the base directory which will be compiled into the uClibc
+# runtime environment. When compiled as a shared library, the shared
+# library loader will look in <ROOT_DIR>/lib and <ROOT_DIR>/usr/lib
+# for shared libraries.
+#
+# DEVEL_PREFIX is the base directory which will be compiled into the uClibc
+# development environment. The uClibc development environment will
+# look for the uClibc header files under <DEVEL_PREFIX><ROOT_DIR>/usr/include,
+# and for static libs and crt0.o in <DEVEL_PREFIX><ROOT_DIR>/usr/lib.
+# Also, 'make install' will install the compiler tools to
+# <DEVEL_PREFIX><ROOT_DIR>/bin and <DEVEL_PREFIX><ROOT_DIR>/usr/bin.
+#
+# TARGET_PREFIX is the directory under which 'make install' will install the
+# uClibc runtime environment. This path does not get compiled into anything,
+# and is provided simply to make it easier to build standalone target systems.
+# Note: This doesn't do anything if there are no shared libs.
+
+DEVEL_PREFIX =
+ROOT_DIR = /opt/uClinux
+TARGET_PREFIX =
+
+#
+# ARCH_CFLAGS if your have something special to add to the CFLAGS
+#
+ARCH_CFLAGS = -Wa,--bitwise-or -msoft-float
+#
+# this is needed for 2.4 m68knommu builds
+#
+ARCH_CFLAGS2 = -I$(KERNEL_SOURCE)/include
+#
+# get this from elsewhere, maybe
+#
+OPTIMIZATION = $(DEBUG_CFLAGS)
+
+# This is a COFF compiler (ick), so disable all the cool stuff
+HAVE_ELF = false
diff --git a/include/features.h b/include/features.h
index 54330dae9..af64066d9 100644
--- a/include/features.h
+++ b/include/features.h
@@ -45,6 +45,10 @@
# define __restrict /* Ignore */
#endif
+/* __extension__ is known in gcc 2.8 above. */
+#if !defined __GNUC__ || __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8)
+# define __extension__ /* Ignore */
+#endif
#ifdef __STDC__
@@ -105,13 +109,20 @@
#undef __need_uClibc_config_h
-#if 1 /* This only works with GNU ld, but that is what we use 'round these parts */
-#define link_warning(symbol, msg) \
-asm (".section " ".gnu.warning." #symbol "\n\t.previous"); \
-static const char __evoke_link_warning_##symbol[] \
-__attribute__ ((section (".gnu.warning." #symbol "\n\t#"))) = msg;
+/* Some nice features only work properly with ELF */
+#if defined HAVE_ELF
+# define link_warning(symbol, msg) \
+ asm (".section " ".gnu.warning." #symbol "\n\t.previous"); \
+ static const char __evoke_link_warning_##symbol[] \
+ __attribute__ ((section (".gnu.warning." #symbol "\n\t#"))) = msg;
+# define weak_alias(name, aliasname) \
+ extern __typeof (name) aliasname __attribute__ ((weak, alias (#name)));
#else
-# define link_warning(symbol, msg)
+# define link_warning(symbol, msg) \
+ asm (".stabs \"" msg "\",30,0,0,0\n\t" \
+ ".stabs \"" #symbol "\",1,0,0,0\n");
+# define weak_alias(name, aliasname) \
+ __asm__(".global alias\n.set alias,original");
#endif
diff --git a/include/unistd.h b/include/unistd.h
index 16deb1ac3..b13d0c1f1 100644
--- a/include/unistd.h
+++ b/include/unistd.h
@@ -649,7 +649,7 @@ extern int setegid __P ((__gid_t __gid));
#ifdef __UCLIBC_HAS_MMU__
extern __pid_t fork __P ((void));
#else
-#define fork fork_not_available_on_mmuless_systems
+#define fork fork_not_available_on_mmuless_systems__use_vfork
#endif
#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
@@ -1008,10 +1008,6 @@ extern int pthread_atfork __P ((void (*__prepare) (void),
void (*__child) (void)));
#endif
-#ifdef __VFORK_MACRO__
-#include <bits/vfork.h>
-#endif
-
__END_DECLS
#endif /* unistd.h */
diff --git a/libc/misc/internals/__uClibc_main.c b/libc/misc/internals/__uClibc_main.c
index 26c028015..dc8c62f97 100644
--- a/libc/misc/internals/__uClibc_main.c
+++ b/libc/misc/internals/__uClibc_main.c
@@ -36,6 +36,13 @@ void __uClibc_empty_func(void)
{
}
+#ifdef HAVE_ELF
+weak_alias(__environ, environ);
+weak_alias(__uClibc_empty_func, __init_stdio);
+weak_alias(__uClibc_empty_func, __stdio_close_all);
+#endif
+
+
extern void __init_stdio(void);
extern void __stdio_close_all(void);
@@ -80,7 +87,9 @@ void __uClibc_main(int argc, char **argv, char **envp)
char **__environ = 0;
-__asm__(".weak environ;environ = __environ");
-__asm__(".weak __init_stdio; __init_stdio = __uClibc_empty_func");
-__asm__(".weak __stdio_close_all; __stdio_close_all = __uClibc_empty_func");
+#ifndef HAVE_ELF
+weak_alias(__environ, environ);
+weak_alias(__uClibc_empty_func, __init_stdio);
+weak_alias(__uClibc_empty_func, __stdio_close_all);
+#endif
diff --git a/libc/stdlib/random.c b/libc/stdlib/random.c
index bef89c01f..cbd4206ae 100644
--- a/libc/stdlib/random.c
+++ b/libc/stdlib/random.c
@@ -34,5 +34,4 @@ void srandom(unsigned int seed)
seed3 = seed % 31656 + 1;
}
-__asm__(".weak srand; srand = srandom");
-
+weak_alias(srandom, srand);
diff --git a/libc/stdlib/unix_grantpt.c b/libc/stdlib/unix_grantpt.c
index eb6ce0b35..c8d70ad64 100644
--- a/libc/stdlib/unix_grantpt.c
+++ b/libc/stdlib/unix_grantpt.c
@@ -140,7 +140,11 @@ grantpt (int fd)
/* We have to use the helper program. */
helper:
+#ifdef __UCLIBC_HAS_MMU__
pid = fork ();
+#else
+ pid = vfork ();
+#endif
if (pid == -1)
goto cleanup;
else if (pid == 0)
diff --git a/libc/string/string.c b/libc/string/string.c
index 0e2df303b..bb524eeac 100644
--- a/libc/string/string.c
+++ b/libc/string/string.c
@@ -77,7 +77,7 @@ int strcmp(const char *s1, const char *s2)
}
#ifndef __UCLIBC_HAS_LOCALE__
-__asm__(".weak strcoll; strcoll = strcmp");
+weak_alias(strcmp, strcoll);
#endif /* __UCLIBC_HAS_LOCALE__ */
#endif
@@ -191,7 +191,7 @@ char *strchr(const char *str, int c)
return 0;
}
-__asm__(".weak index; index = strchr");
+weak_alias(strchr, index);
#endif
/********************** Function strrchr ************************************/
@@ -214,7 +214,7 @@ char *strrchr(const char *str, int c)
return prev;
}
-__asm__(".weak rindex; rindex = strrchr");
+weak_alias(strrchr, rindex);
#endif
/********************** Function strdup ************************************/
diff --git a/libc/string/strtok_r.c b/libc/string/strtok_r.c
index 37b313455..e6c24218a 100644
--- a/libc/string/strtok_r.c
+++ b/libc/string/strtok_r.c
@@ -52,4 +52,4 @@ char *__strtok_r(char *s, const char *delim, char **save_ptr)
return token;
}
-__asm__(".weak strtok_r; strtok_r = __strtok_r");
+weak_alias(__strtok_r, strtok_r);
diff --git a/libc/sysdeps/linux/m68k/Makefile b/libc/sysdeps/linux/m68k/Makefile
index e4346e4c8..5f2b73581 100644
--- a/libc/sysdeps/linux/m68k/Makefile
+++ b/libc/sysdeps/linux/m68k/Makefile
@@ -32,7 +32,7 @@ CRT0_OBJ=$(patsubst %.S,%.o, $(CRT0))
SSRC=setjmp.S # longjmp.S _start.S clone.S
SOBJS=$(patsubst %.S,%.o, $(SSRC))
-CSRC=ptrace.c #errno.c
+CSRC=ptrace.c vfork.c
COBJS=$(patsubst %.c,%.o, $(CSRC))
OBJS=$(SOBJS) $(MOBJ) $(COBJS)
diff --git a/libc/sysdeps/linux/m68k/README.m68k b/libc/sysdeps/linux/m68k/README.m68k
index 697413852..f774e6f7a 100644
--- a/libc/sysdeps/linux/m68k/README.m68k
+++ b/libc/sysdeps/linux/m68k/README.m68k
@@ -40,16 +40,6 @@ Installation:
run:
make install
-Usage:
- Any program you compile should have this added to CFLAGS:
-
- -D__VFORK_MACRO__ -Dconst= -D__const=
-
- (You need the equal sign so that const and __const are defined
- as NULL instead of as '1') The 'const' keyword is broken for
- m68k-pic-coff-gcc 2.7.2.3-pic-060999. There _was_ a fix
- floating around, but apparently it didn't work.
-
Problems:
I _may_ be able to help if you run into problems. Create a
diff --git a/libc/sysdeps/linux/m68k/bits/vfork.h b/libc/sysdeps/linux/m68k/bits/vfork.h
deleted file mode 100644
index ceb9af8a6..000000000
--- a/libc/sysdeps/linux/m68k/bits/vfork.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/* orginally from include/unistd.h, written by ndf@linux.mit.edu> */
-
-#ifndef _M68K_VFORK_H
-#define _M68K_VFORK_H 1
-
-extern int _clone __P ((int (*fn)(void *arg), void *child_stack, int flags, void *arg));
-
-#ifndef __NR_vfork
-#define __NR_vfork __NR_fork /* uClinux-2.0 only has fork which is vfork */
-#endif
-
-#define vfork() ({ \
-unsigned long __res; \
-__asm__ __volatile__ ("movel %1,%%d0;" \
- "trap #0;" \
- "movel %%d0,%0" \
- : "=d" (__res) \
- : "0" (__NR_vfork) \
- : "%d0"); \
-if (__res >= (unsigned long)-4096) { \
- errno = -__res; \
- __res = (pid_t)-1; \
-} \
-(pid_t)__res; \
-})
-
-
-#define clone clone_not_available_use__clone
-
-#endif /* _M68K_VFORK_H */
-
diff --git a/libc/sysdeps/linux/m68k/crt0.S b/libc/sysdeps/linux/m68k/crt0.S
index 182e8baea..06b4b54f5 100644
--- a/libc/sysdeps/linux/m68k/crt0.S
+++ b/libc/sysdeps/linux/m68k/crt0.S
@@ -50,8 +50,11 @@ __exit:
*/
empty_func:
rts
+#if defined HAVE_ELF
.weak atexit
-atexit = empty_func
+#else
+ .set atexit,empty_func
+#endif
/*
* a little bit of stuff to support C++
diff --git a/libc/sysdeps/linux/m68k/vfork.c b/libc/sysdeps/linux/m68k/vfork.c
new file mode 100644
index 000000000..9edcb650d
--- /dev/null
+++ b/libc/sysdeps/linux/m68k/vfork.c
@@ -0,0 +1,25 @@
+/* orginally from include/unistd.h, written by ndf@linux.mit.edu> */
+#include <unistd.h>
+#include <sys/types.h>
+#include <asm/unistd.h>
+
+#ifndef __NR_vfork
+#define __NR_vfork __NR_fork /* uClinux-2.0 only has fork which is vfork */
+#endif
+
+pid_t vfork(void)
+{
+ pid_t __res;
+ __asm__ __volatile__ ("movel %1,%%d0;"
+ "trap #0;"
+ "movel %%d0,%0"
+ : "=d" (__res)
+ : "0" (__NR_vfork)
+ : "%d0");
+ if (__res >= (unsigned long)-4096) {
+ errno = -__res;
+ __res = (pid_t)-1;
+ }
+ return(__res);
+}
+