undefined reference to `__ffs'
Hi,
With kernel 2.4.27 and the snapshot patch from 8/26 (yesterday) I am getting the following error :
make[1]: Leaving directory `/usr/src/Lineo/current_build2/linux-2.4.27/arch/i386/lib'
ld -m elf_i386 -T /usr/src/Lineo/current_build2/linux-2.4.27/arch/i386/vmlinux.lds -e stext arch/i386/kernel/head.o arch/i386/kernel/init_task.o init/main.o
init/version.o init/do_mounts.o \
--start-group \
arch/i386/kernel/kernel.o arch/i386/mm/mm.o kernel/kernel.o mm/mm.o
fs/fs.o ipc/ipc.o \
drivers/char/char.o drivers/block/block.o drivers/misc/misc.o
drivers/net/net.o drivers/pci/driver.o drivers/mtd/mtdlink.o
drivers/net/pcmcia/pcmcia_net.o drivers/media/media.o \
net/network.o \
/usr/src/Lineo/current_build2/linux-2.4.27/arch/i386/lib/lib.a
/usr/src/Lineo/current_build2/linux-2.4.27/lib/lib.a
/usr/src/Lineo/current_build2/linux-2.4.27/arch/i386/lib/lib.a \
--end-group \
-o vmlinuxdrivers/mtd/mtdlink.o: In function `cfi_intelext_partition_fixup':
drivers/mtd/mtdlink.o(.text+0x76c6): undefined reference to `__ffs'
make: *** [vmlinux] Error 1
Any ideas?
-Brian
Quoted 4 lines
drivers/mtd/mtdlink.o: In function `cfi_intelext_partition_fixup':
drivers/mtd/mtdlink.o(.text+0x76c6): undefined reference to `__ffs'
make: *** [vmlinux] Error 1
Hmmm,
Looks like _ffs is defined in :
[root@Smog include]# grep -l -r "__ffs" *asm-ia64/topology.hasm-ia64/bitops.hasm-ppc64/bitops.h
but in asm-i386/bitops.h it is defined as ffs()
So, should there be a macro rule for ffs->__ffs for compiling for i386?
-Brian
Quoted 9 lines · Brian T
Quoted 4 lines
drivers/mtd/mtdlink.o: In function `cfi_intelext_partition_fixup':
drivers/mtd/mtdlink.o(.text+0x76c6): undefined reference to `__ffs'
make: *** [vmlinux] Error 1Hmmm,
Looks like
_ffsis defined in :
Quoted 8 lines
[root@Smog include]# grep -l -r "
__ffs" *asm-ia64/topology.hasm-ia64/bitops.hasm-ppc64/bitops.hbut in
asm-i386/bitops.hit is defined asffs()So, should there be a macro rule for
ffs->__ffsfor compiling for i386?
No, they aren't equivalent.
Quoted 1 line
From
linux/asm-i386/bitops.hin 2.6.8:
/**
* __ffs - find first bit in word.
* @word: The word to search
*
* Undefined if no bit exists, so code should check against 0 first. */
static inline unsigned long __ffs(unsigned long word)
{
__asm__("bsfl %1,%0"
:"=r" (word)
:"rm" (word));
return word;
}Nicolas
Quoted 13 lines
No, they aren't equivalent.
Quoted 1 line
From
linux/asm-i386/bitops.hin 2.6.8:/**
*__ffs- find first bit in word.
* @word: The word to search
*
* Undefined if no bit exists, so code should check against 0 first. */
static inline unsigned long__ffs(unsigned long word)
Quoted 7 lines
{
__asm__("bsfl %1,%0"
:"=r" (word)
:"rm" (word));
return word;
}Ok,
So MTD is no longer compatable with the current 2.4 tree? I just unpacked it and didn't see it in linux/asm-i386/bitops.h . Am I looking in the wrong place?
-Brian
Quoted 5 lines · Brian T
Ok,
So MTD is no longer compatable with the current 2.4 tree? I just unpacked it and didn't see it in
linux/asm-i386/bitops.h. Am I looking in the wrong place?
Not really. Some efforts have been made to fixup the current code to work with 2.4, but I don't know to what extent. It shouldn't take too much effort to get whatever is broken working again (famous last words).
As long as it doesn't make the 2.6 code ugly. Right, dwmw2... ;)
josh
Quoted 1 line · Josh Boyer
As long as it doesn't make the 2.6 code ugly. Right, dwmw2... ;)
Maybe.
Friends don't let friends use 2.4.
Signature · 1 line
dwmw2
Quoted 3 lines · Brian T
So MTD is no longer compatable with the current 2.4 tree? I just unpacked it and didn't see it in
linux/asm-i386/bitops.h. Am I looking in the wrong place?
__ffs was never in 2.4. Move to 2.6 or add it to compatmac.h and provide a nice patch, if you really want to hang on with 2.4
tglx
Quoted 4 lines
__ffswas never in 2.4. Move to 2.6 or add it tocompatmac.hand provide a nice patch, if you really want to hang on with 2.4
Thanks, I'll try to get that working and test it. If it works I'll send in a patch.
-Brian
Quoted 5 lines · Brian T
Quoted 1 line
So MTD is no longer compatable with the current 2.4 tree? I just
unpacked
Quoted 1 line
Quoted 1 line
it and didn't see it in
linux/asm-i386/bitops.h. Am I looking in the
wrong
Quoted 6 lines
Quoted 1 line
place?
__ffswas never in 2.4. Move to 2.6 or add it tocompatmac.hand provide a nice patch, if you really want to hang on with 2.4tglx
compatmac.h patch attached for __ffs() .
Compiles against 2.4.27 now. Hope I didn't break anything.
-Brian
linux/mtd/compatmac.h renamed from linux/mtd/compatmac.h.orig +16 -0
@@ -64,6 +64,22 @@#include <linux/sched.h> +#if LINUX_VERSION_CODE <KERNEL_VERSION (2 ,5 ,0 ) +/** +* * __ffs - find first bit in word. +* * @word: The word to search +* * +* * Undefined if no bit exists, so code should check against 0 first. +* */ +static inline unsigned long __ffs (unsigned long word) +{ + __asm__("bsfl %1,%0" + :"=r" (word) + :"rm" (word)); +return word; +} +#endif /* < 2.5.0 */ +#ifdef __rh_config_h__#define sigmask_lock sighand->siglock#define sig sighand
Quoted 8 lines · Brian T
Quoted 3 lines · Brian T
Quoted 1 line
So MTD is no longer compatable with the current 2.4 tree? I just
unpacked
Quoted 1 line
Quoted 1 line
it and didn't see it in
linux/asm-i386/bitops.h. Am I looking in thewrong
Quoted 2 lines
Quoted 1 line
place?
Quoted 8 lines
Quoted 4 lines
__ffswas never in 2.4. Move to 2.6 or add it tocompatmac.hand provide a nice patch, if you really want to hang on with 2.4tglx
compatmac.hpatch attached for__ffs().Compiles against 2.4.27 now. Hope I didn't break anything.
Hrm... that won't work on non-x86 architectures.
josh
Quoted 10 lines
Quoted 5 lines
compatmac.hpatch attached for__ffs().Compiles against 2.4.27 now. Hope I didn't break anything.
Hrm... that won't work on non-x86 architectures.
josh
Not sure how to fix it for non-x86 then. Point me in the right direction?
-Brian
Quoted 1 line · Brian T
Not sure how to fix it for non-x86 then. Point me in the right direction?
Welcome to the hell that is compatmac.h ;).
Seriously though, maybe take a look at generic_ffs() in include/linux/bitops.h (in the 2.6 kernel). It's not optimized, but it should work for all architectures if I am reading things right.
josh
Quoted 7 lines · Josh Boyer
Quoted 1 line · Brian T
Not sure how to fix it for non-x86 then. Point me in the right direction?
Welcome to the hell that is
compatmac.h;).Seriously though, maybe take a look at
generic_ffs()ininclude/linux/bitops.h(in the 2.6 kernel).
Again, ffs()/generic_ffs() are not equivalent to __ffs().
For a generic solution to add to compatmac.h, just use:
#define __ffs(x) (ffs(x) - 1)
Nicolas
Quoted 11 lines · Nicolas Pitre
Quoted 7 lines · Josh Boyer
Quoted 1 line · Brian T
Not sure how to fix it for non-x86 then. Point me in the right direction?
Welcome to the hell that is
compatmac.h;).Seriously though, maybe take a look at
generic_ffs()ininclude/linux/bitops.h(in the 2.6 kernel).Again, ffs()/generic_ffs() are not equivalent to
__ffs().
Hm, I remember you saying that now. Care to explain how they are different?
josh
Quoted 8 lines · Josh Boyer
Quoted 7 lines · Nicolas Pitre
Quoted 5 lines · Josh Boyer
Quoted 1 line · Brian T
Not sure how to fix it for non-x86 then. Point me in the right direction?
Welcome to the hell that is
compatmac.h;).
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Seriously though, maybe take a look at
generic_ffs()ininclude/linux/bitops.h(in the 2.6 kernel).Again, ffs()/generic_ffs() are not equivalent to
__ffs().Hm, I remember you saying that now. Care to explain how they are different?
Guys, you really should look at the source...
linux-2.6.8/include/asm-i386/bitops.h:
/**
* __ffs - find first bit in word.
* @word: The word to search
*
* Undefined if no bit exists, so code should check against 0 first. */
[...]
/**
* ffz - find first zero in word.
* @word: The word to search
*
* Undefined if no zero exists, so code should check against ~0UL first. */
[...]
/**
* ffs - find first bit set
* @x: the word to search
*
* This is defined the same way as
* the libc and compiler builtin ffs routines, therefore
* differs in spirit from the above ffz (man ffs). */
In short, one starts at 0 while the other one starts at 1.
Nicolas
Quoted 13 lines · Nicolas Pitre
Quoted 11 lines · Josh Boyer
Quoted 10 lines · Nicolas Pitre
Quoted 7 lines · Josh Boyer
Quoted 1 line · Brian T
Not sure how to fix it for non-x86 then. Point me in the right direction?
Welcome to the hell that is
compatmac.h;).Seriously though, maybe take a look at
generic_ffs()ininclude/linux/bitops.h(in the 2.6 kernel).
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Again, ffs()/generic_ffs() are not equivalent to
__ffs().Hm, I remember you saying that now. Care to explain how they are different?
Guys, you really should look at the source...
Yes, I should have. I did right after I sent my last email. Sorry. I deserve my scolding for being lazy ;).
At least it's in the archives now though.
josh