I had some problems compiling and later, using shared libraries from
uClibc-0.9.30.1 on a Coldfire M5485 processor.
The attached patches fixes the problems I've encountered:
- m68k_cf_no_mmap2.patch
: Disable mmap2() if we're compiling for coldfire and fall back to mmap().
It seems to map a different file area on a 2.6.25 linux kernel.
I will investigate this further after I'll get a full rootfs.
- m68k_cf_operands_missmatch.patch and m68k_cf_pc_relative_addressing.patch
: Uses pc-relative addresing[1], computes ADDR_ALIGN, PAGE_ALIGN
and OFFSET_ALIGN relatively
to _dl_pagesize[3]. On coldfire/M5485 _dl_pagesize is 0x2000.
After some investigation and looking at OpenBSD library loader[2] I
[1] "Linking Error: relocation truncated to fit: R_68K_PC16" :
http://lists.uclibc.org/pipermail/uclibc/2009-March/042152.html
[2] https://bugs.busybox.net/show_bug.cgi?id=203
[3]
http://www.openbsd.org/cgi-bin/cvsweb/src/libexec/ld.so/library.c?rev=1.58;content-type=text%2Fplain
--
Regards, Groleo!
--- uClibc-0.9.30.1.orig/ldso/include/dl-syscall.h 2008-09-18 18:10:12.000000000 +0300
+++ uClibc-0.9.30.1/ldso/include/dl-syscall.h 2009-03-27 17:17:16.944491833 +0200
@@ -152,7 +152,7 @@
# define __NR__dl_mmap __NR_mmap
static __always_inline _syscall6(void *, _dl_mmap, void *, start, size_t, length,
int, prot, int, flags, int, fd, off_t, offset);
-
+#if !defined (__mcoldfire__) // Might be a kernel problem. failed on 2.6.25
/* then try mmap2() */
#elif defined(__NR_mmap2)
@@ -176,7 +176,7 @@
return __syscall_mmap2(addr, size, prot, flags,
fd, (off_t) (offset >> MMAP2_PAGE_SHIFT));
}
-
+#endif
/* finally, fall back to mmap(), syscall1() style */
#elif defined(__NR_mmap)
--- uClibc-0.9.30.1.orig/libpthread/linuxthreads.old/sysdeps/m68k/pt-machine.h 2008-01-06 02:04:02.000000000 +0200
+++ uClibc-0.9.30.1/libpthread/linuxthreads.old/sysdeps/m68k/pt-machine.h 2009-03-17 10:45:39.234486101 +0200
@@ -40,7 +40,7 @@
#else
"bset #7,%1; sne %0"
#endif
- : "=dm"(ret), "=m"(*spinlock)
+ : "=&dm"(ret), "=m"(*spinlock)
: "m"(*spinlock)
: "cc");
--- uClibc-0.9.30.1.orig/ldso/ldso/m68k/dl-sysdep.h 2008-09-15 19:36:11.000000000 +0300
+++ uClibc-0.9.30.1/ldso/ldso/m68k/dl-sysdep.h 2009-03-27 17:39:11.460994143 +0200
@@ -26,9 +26,9 @@
extern unsigned long _dl_linux_resolver (struct elf_resolve *, int);
/* 4096 bytes alignment */
-#define PAGE_ALIGN 0xfffff000
-#define ADDR_ALIGN 0xfff
-#define OFFS_ALIGN 0x7ffff000
+#define ADDR_ALIGN (_dl_pagesize-1)
+#define PAGE_ALIGN (0xFFFFFFFF-ADDR_ALIGN)
+#define OFFS_ALIGN (0x7FFFFFFF-ADDR_ALIGN)
/* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry, so
PLT entries should not be allowed to define the value.
@@ -41,26 +41,37 @@
/* Return the link-time address of _DYNAMIC. Conveniently, this is the
first element of the GOT. This must be inlined in a function which
uses global data. */
-static __inline__ Elf32_Addr
+static __always_inline Elf32_Addr
elf_machine_dynamic (void)
{
- register Elf32_Addr *got __asm__ ("%a5");
- return *got;
+ Elf32_Addr addr;
+
+ __asm__ ("move.l [email protected](%%a5), %0"
+ : "=a" (addr));
+ return addr;
}
+#ifdef __mcoldfire__
+#define PCREL_OP(OP, SRC, DST, TMP, PC) \
+ "move.l #" SRC " - ., " TMP "\n\t" OP " (-8, " PC ", " TMP "), " DST
+#else
+#define PCREL_OP(OP, SRC, DST, TMP, PC) \
+ OP " " SRC "(" PC "), " DST
+#endif
+
/* Return the run-time load address of the shared object. */
-static __inline__ Elf32_Addr
+static __always_inline Elf32_Addr
elf_machine_load_address (void)
{
Elf32_Addr addr;
- __asm__ ("lea _dl_start(%%pc), %0\n\t"
- "sub.l [email protected](%%a5), %0"
- : "=a" (addr));
+ __asm__ (PCREL_OP ("lea", "_dl_start", "%0", "%0", "%%pc") "\n\t"
+ "sub.l [email protected](%%a5), %0"
+ : "=a" (addr));
return addr;
}
-static __inline__ void
+static __always_inline void
elf_machine_relative (Elf32_Addr load_off, const Elf32_Addr rel_addr,
Elf32_Word relative_count)
{
_______________________________________________
uClibc mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/uclibc