diff mbox

[U-Boot] JFFS2: Fix undefined reference to `__aeabi_uldivmod' error

Message ID 1382865251-17302-1-git-send-email-wd@denx.de
State Deferred
Delegated to: Wolfgang Denk
Headers show

Commit Message

Wolfgang Denk Oct. 27, 2013, 9:14 a.m. UTC
Building boards that have JFFS2 support enabled will fail when using
U-Boot's builtin GCC library, for example like this:

USE_PRIVATE_LIBGCC=yes ./MAKEALL omap3_evm
...
fs/jffs2/libjffs2.o: In function `jffs2_1pass_build_lists':
fs/jffs2/jffs2_1pass.c:1441: undefined reference to `__aeabi_uldivmod'

This is caused by a u64 / u32 division in jffs2_1pass.c; the problem
can be avoided by using do_div() instead of plain division.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Reported-by: Chris Ruehl <chris.ruehl@gtsys.com.hk>
Cc: Chris Ruehl <chris.ruehl@gtsys.com.hk>

---
 fs/jffs2/jffs2_1pass.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Chris Ruehl Oct. 27, 2013, 9:46 a.m. UTC | #1
Wolfgang,

GOOD Catch!

On Sunday, October 27, 2013 05:14 PM, Wolfgang Denk wrote:
> Building boards that have JFFS2 support enabled will fail when using
> U-Boot's builtin GCC library, for example like this:
>
> USE_PRIVATE_LIBGCC=yes ./MAKEALL omap3_evm
> ...
> fs/jffs2/libjffs2.o: In function `jffs2_1pass_build_lists':
> fs/jffs2/jffs2_1pass.c:1441: undefined reference to `__aeabi_uldivmod'
>
> This is caused by a u64 / u32 division in jffs2_1pass.c; the problem
> can be avoided by using do_div() instead of plain division.
>
> Signed-off-by: Wolfgang Denk<wd@denx.de>
> Reported-by: Chris Ruehl<chris.ruehl@gtsys.com.hk>
> Cc: Chris Ruehl<chris.ruehl@gtsys.com.hk>
>
> ---
>   fs/jffs2/jffs2_1pass.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/jffs2/jffs2_1pass.c b/fs/jffs2/jffs2_1pass.c
> index c856983..a7dbe79 100644
> --- a/fs/jffs2/jffs2_1pass.c
> +++ b/fs/jffs2/jffs2_1pass.c
> @@ -1438,7 +1438,7 @@ jffs2_1pass_build_lists(struct part_info * part)
>   {
>   	struct b_lists *pL;
>   	struct jffs2_unknown_node *node;
> -	u32 nr_sectors = part->size/part->sector_size;
> +	u32 nr_sectors = do_div(part->size, part->sector_size);
>   	u32 i;
>   	u32 counter4 = 0;
>   	u32 counterF = 0;
Wolfgang Denk Oct. 27, 2013, 10:01 a.m. UTC | #2
Dear Chris,

In message <526CE0F6.8020408@gtsys.com.hk> you wrote:
> 
> GOOD Catch!

Thanks :-)

It would be nice if you could run an actual test on your hardware,and
then eventually even provide an Tested-by: ?

Best regards,

Wolfgang Denk
Daniel Schwierzeck Oct. 27, 2013, 6:17 p.m. UTC | #3
2013/10/27 Wolfgang Denk <wd@denx.de>:
> Building boards that have JFFS2 support enabled will fail when using
> U-Boot's builtin GCC library, for example like this:
>
> USE_PRIVATE_LIBGCC=yes ./MAKEALL omap3_evm
> ...
> fs/jffs2/libjffs2.o: In function `jffs2_1pass_build_lists':
> fs/jffs2/jffs2_1pass.c:1441: undefined reference to `__aeabi_uldivmod'

I recently noticed a similar problem on MIPS too:

fs/jffs2/libjffs2.o: In function `jffs2_get_list':
jffs2_1pass.c:(.text.jffs2_get_list+0x5c): undefined reference to `__udivdi3'

Your patch solves it, thanks.
Tested-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

>
> This is caused by a u64 / u32 division in jffs2_1pass.c; the problem
> can be avoided by using do_div() instead of plain division.
>
> Signed-off-by: Wolfgang Denk <wd@denx.de>
> Reported-by: Chris Ruehl <chris.ruehl@gtsys.com.hk>
> Cc: Chris Ruehl <chris.ruehl@gtsys.com.hk>
>
> ---
>  fs/jffs2/jffs2_1pass.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/jffs2/jffs2_1pass.c b/fs/jffs2/jffs2_1pass.c
> index c856983..a7dbe79 100644
> --- a/fs/jffs2/jffs2_1pass.c
> +++ b/fs/jffs2/jffs2_1pass.c
> @@ -1438,7 +1438,7 @@ jffs2_1pass_build_lists(struct part_info * part)
>  {
>         struct b_lists *pL;
>         struct jffs2_unknown_node *node;
> -       u32 nr_sectors = part->size/part->sector_size;
> +       u32 nr_sectors = do_div(part->size, part->sector_size);
>         u32 i;
>         u32 counter4 = 0;
>         u32 counterF = 0;
> --
> 1.8.3.1
>
> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
Wolfgang Denk Oct. 27, 2013, 8:07 p.m. UTC | #4
In message <1382865251-17302-1-git-send-email-wd@denx.de> I wrote:
> Building boards that have JFFS2 support enabled will fail when using
> U-Boot's builtin GCC library, for example like this:
> 
> USE_PRIVATE_LIBGCC=yes ./MAKEALL omap3_evm
> ...
> fs/jffs2/libjffs2.o: In function `jffs2_1pass_build_lists':
> fs/jffs2/jffs2_1pass.c:1441: undefined reference to `__aeabi_uldivmod'
> 
> This is caused by a u64 / u32 division in jffs2_1pass.c; the problem
> can be avoided by using do_div() instead of plain division.
> 
> Signed-off-by: Wolfgang Denk <wd@denx.de>
> Reported-by: Chris Ruehl <chris.ruehl@gtsys.com.hk>
> Cc: Chris Ruehl <chris.ruehl@gtsys.com.hk>

I would like to withdraw this patch.

It appears nobody has been running a MAKEALL with USE_PRIVATE_LIBGCC
enabled for a long, long time.  There are a number of other places
that show similar problems.  Instead of fixing these one by one, I
think we should rather bundle this.

I'm working on a more complete patch (or patch series).

Best regards,

Wolfgang Denk
Chris Ruehl Oct. 27, 2013, 11:50 p.m. UTC | #5
Wolfgang,

On Sunday, October 27, 2013 06:01 PM, Wolfgang Denk wrote:
> Dear Chris,
>
> In message<526CE0F6.8020408@gtsys.com.hk>  you wrote:
>>
>> GOOD Catch!
>
> Thanks :-)
>
> It would be nice if you could run an actual test on your hardware,and
> then eventually even provide an Tested-by: ?

Yes, I will run the test, later today.


>
> Best regards,
>
> Wolfgang Denk
>
diff mbox

Patch

diff --git a/fs/jffs2/jffs2_1pass.c b/fs/jffs2/jffs2_1pass.c
index c856983..a7dbe79 100644
--- a/fs/jffs2/jffs2_1pass.c
+++ b/fs/jffs2/jffs2_1pass.c
@@ -1438,7 +1438,7 @@  jffs2_1pass_build_lists(struct part_info * part)
 {
 	struct b_lists *pL;
 	struct jffs2_unknown_node *node;
-	u32 nr_sectors = part->size/part->sector_size;
+	u32 nr_sectors = do_div(part->size, part->sector_size);
 	u32 i;
 	u32 counter4 = 0;
 	u32 counterF = 0;