Hi,

try to use "objdump -D xx.o"

You should see the disassembled section of module_init.

Stéphane wrote:
Hi

I don't exactly know but:

objdump -sx xx.o :

ucAsserv.o:     file format elf32-big
ucAsserv.o
architecture: UNKNOWN!, flags 0x00000011:
HAS_RELOC, HAS_SYMS
start address 0x00000000

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .text         00000058  00000000  00000000  00000034  2**2
                  CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
  1 .data         00000000  00000000  00000000  0000008c  2**2
                  CONTENTS, ALLOC, LOAD, DATA
  2 .bss          0000000c  00000000  00000000  0000008c  2**2
                  ALLOC
  3 .modinfo      00000045  00000000  00000000  0000008c  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  4 .rodata       00000019  00000000  00000000  000000d1  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  5 .comment      000000a6  00000000  00000000  000000ea  2**0
                  CONTENTS, READONLY
SYMBOL TABLE:
00000000 l    df *ABS*    00000000 ucAsserv.c
00000000 l    d  .text    00000000 .text
00000000 l    d  .data    00000000 .data
00000000 l    d  .bss    00000000 .bss
00000000 l       .text    00000000 gcc2_compiled.
00000000 l    d  .modinfo    00000000 .modinfo
00000000 l     O .modinfo    00000021 __module_kernel_version
00000000 l    d  .rodata    00000000 .rodata
00000008 l     O .bss    00000004 VitL
00000004 l     O .bss    00000004 global_left_encoder
00000000 l     O .bss    00000004 global_right_encoder
00000039 l     O .modinfo    0000000c __module_license
00000000 l    d  .comment    00000000 .comment
00000000 g     F .text    00000050 init_module
00000000         *UND*    00000000 printk
00000050 g     F .text    00000008 cleanup_module
00000021 g     O .modinfo    00000018 __module_author


RELOCATION RECORDS FOR [.text]:
OFFSET   TYPE              VALUE
00000006 UNKNOWN           .bss+0x00000008
0000000c UNKNOWN           .bss+0x00000004
00000012 UNKNOWN           .bss
00000018 UNKNOWN           .rodata
0000001e UNKNOWN           printk
00000026 UNKNOWN           .bss+0x00000004
0000002e UNKNOWN           .bss
00000034 UNKNOWN           .bss+0x00000008
0000003a UNKNOWN           .rodata+0x00000009
00000040 UNKNOWN           printk


Contents of section .text:
 0000 4e560000 42b90000 000042b9 00000000  NV..B.....B.....
 0010 42b90000 00004879 00000000 4eb90000  B.....Hy....N...
 0020 0000588f 20390000 00004c39 08000000  ..X. 9....L9....
 0030 000023c0 00000000 48790000 00004eb9  ..#.....Hy....N.
 0040 00000000 588f4280 60000002 4e5e4e75  ....X.B.`...N^Nu
0050 4e560000 4e5e4e75 NV..N^Nu Contents of section .modinfo:
 0000 6b65726e 656c5f76 65727369 6f6e3d32  kernel_version=2
 0010 2e342e33 312d7563 302d414e 492d3130  .4.31-uc0-ANI-10
 0020 00617574 686f723d 53746570 68616e65  .author=Stephane
 0030 20476572 6d61696e 006c6963 656e7365   Germain.license
0040 3d47504c 00 =GPL. Contents of section .rodata:
 0000 3c363e42 75673a0a 003c363e 4e657665  <6>Bug:..<6>Neve
0010 72205265 6163680a 00 r Reach.. Contents of section .comment:
 0000 00474343 3a202847 4e552920 322e3935  .GCC: (GNU) 2.95
 0010 2e332032 30303130 33313520 2872656c  .3 20010315 (rel
 0020 65617365 2928436f 6c644669 72652070  ease)(ColdFire p
 0030 61746368 6573202d 20323030 31303331  atches - 2001031
 0040 38206672 6f6d2068 7474703a 2f2f6669  8 from http://fi
 0050 64646573 2e6e6574 2f636f6c 64666972  ddes.net/coldfir
 0060 652f2928 75436c69 6e757820 58495020  e/)(uClinux XIP
 0070 616e6420 73686172 6564206c 69622070  and shared lib p
 0080 61746368 65732066 726f6d20 68747470  atches from http
 0090 3a2f2f77 77772e73 6e617067 6561722e  ://www.snapgear.
00a0 636f6d2f 2900 com/).





Wolfgang Reissnegger a écrit :
Hi Stéphane,

can you also generate an objdump of the module and post it?

Stéphane wrote:
Hmm,

In Makefile:

/********************/

INCLUDE := -isystem ../uClinux-dist-20060803/linux-2.4.x/include
CFLAGS  := -DMODULE -D__KERNEL__ ${WARN} ${INCLUDE}
CC      := /opt/uClinux-m68k-elf/bin/m68k-elf-gcc
   ${TARGET}.o: ${TARGET}.c

/************************/

and with -S  :

/*****************************************/

        .file   "ucAsserv.c"
gcc2_compiled.:
.section        .modinfo,"a",@progbits
        .type    __module_kernel_version,@object
        .size    __module_kernel_version,33
__module_kernel_version:
        .string "kernel_version=2.4.31-uc0-ANI-10"
.section        .rodata
.LC0:
        .string "<6>Bug:\n"
.LC1:
        .string "<6>Never Reach\n"
.text
        .align  2
.globl init_module
        .type    init_module,@function
init_module:
        link.w %a6,#0
        clr.l VitL
        clr.l global_left_encoder
        clr.l global_right_encoder
        pea .LC0
        jsr printk
        addq.l #4,%sp
        move.l global_left_encoder,%d0
        muls.l global_right_encoder,%d0
        move.l %d0,VitL
        pea .LC1
        jsr printk
        addq.l #4,%sp
        clr.l %d0
        jbra .L95
        .align  2
.L95:
        unlk %a6
        rts
.Lfe1:
        .size    init_module,.Lfe1-init_module
        .align  2
.globl cleanup_module
        .type    cleanup_module,@function
cleanup_module:
        link.w %a6,#0
.L96:
        unlk %a6
        rts
.Lfe2:
        .size    cleanup_module,.Lfe2-cleanup_module
.globl __module_author
.section        .modinfo
        .type    __module_author,@object
        .size    __module_author,24
__module_author:
        .string "author=Stephane Germain"
        .type    __module_license,@object
        .size    __module_license,12
__module_license:
        .string "license=GPL"
        .local  global_right_encoder
        .comm   global_right_encoder,4,2
        .local  global_left_encoder
        .comm   global_left_encoder,4,2
        .local  VitL
        .comm   VitL,4,2
        .ident  "GCC: (GNU) 2.95.3 20010315 (release)(ColdFire patches -
20010318 from
http://fiddes.net/coldfire/)(uClinux XIP and shared lib patches from
http://www.snapgear.com/)"

/***************************************************/


I use the default toolchain

/opt/uClinux-m68k-elf/bin/m68k-elf-gcc -v :
Reading specs from
/opt/uClinux-m68k-elf/lib/gcc-lib/m68k-elf/2.95.3/specs
gcc version 2.95.3 20010315 (release)(ColdFire patches - 20010318 from
http://fiddes.net/coldfire/)(uClinux XIP
and shared lib patches from http://www.snapgear.com/)

thanks


Wolfgang Reissnegger a écrit :
Hi Stéphane,

looks like you are compiling your code with compiler flags that
generate instructions that the processor does not support. That's why
you see the illegal instruction trap.

The reason that it all works if the variables are local is probably
that you also use an optimization flag (e.g. -O3) that causes the
compiler to optimize the whole multiplication away in main because it
has no effect on the function's result and is local to the function.

You should try to compile the code with gcc -S to generate assembler
output. Then you can identify the instruction that causes the problem.

Cheers,
   Wolfgang

Stéphane wrote:
Hi,

I have a bug that I can be resume as:

/***************************/
#include <linux/module.h>    // Needed by all modules
#include <linux/kernel.h>    // Needed for KERN_INFO

static long global_right_encoder;
static long global_left_encoder;
static long VitL;

int init_module(void)
{
    VitL = 0;
    global_left_encoder = 0;
    global_right_encoder = 0;

    printk(KERN_INFO "Bug:\n");
       VitL = global_left_encoder*global_right_encoder;
       printk(KERN_INFO "Never Reach\n");
       return 0;
}


void cleanup_module(void)
{
}

MODULE_AUTHOR("Stephane Germain");
MODULE_LICENSE("GPL");
/**********************************/

result:

insmod xxx.o:
SIGSEGV

dmesg:
Bug:
*** ILLEGAL INSTRUCTION ***   FORMAT=0
Current process id is 47
BAD KERNEL TRAP: 00000000
PC: [<000a8bec>]
SR: 2014  SP: 007dbee8  a2: 10c16b34
d0: 00000000    d1: 00000991    d2: 00000000    d3: ffffffea
d4: 00000060    d5: 00000008    a0: 0003dc8c    a1: 0003dca8
Process insmod (pid: 47, stackpage=007db000)
Frame format=0
Stack from 007dbf1c:
        000a8c14 007d3000 007dbfc4 10c17856 007c5348 00102428 007c5348
000000e8
        00000002 00000001 007da000 00192e00 007c51c0 00190004 00140560
0015fae0
        007d3000 007d4000 00000060 0003dd58 000a8bc0 000000e8 00000000
00000000
        00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000
        00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000
        00000000 00000000 0019fdc8 10c127d2 00192e00 007c5348 00102428
007c5348
Call Trace:
        [<10c17856>] [<10c127d2>]
Code: 4c39 0800 000a 8c3c 23c0 000a 8c44 4879 000a 8c1d

/*****************************/


if the variables are local, all work!

Somebody know something that I don't  about that?

Thanks

Stephane Germain



_______________________________________________
uClinux-dev mailing list
uClinux-dev@uclinux.org
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by uclinux-dev@uclinux.org
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev
_______________________________________________
uClinux-dev mailing list
uClinux-dev@uclinux.org
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by uclinux-dev@uclinux.org
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev


_______________________________________________
uClinux-dev mailing list
uClinux-dev@uclinux.org
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by uclinux-dev@uclinux.org
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev
_______________________________________________
uClinux-dev mailing list
uClinux-dev@uclinux.org
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by uclinux-dev@uclinux.org
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev



_______________________________________________
uClinux-dev mailing list
uClinux-dev@uclinux.org
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by uclinux-dev@uclinux.org
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev

_______________________________________________
uClinux-dev mailing list
uClinux-dev@uclinux.org
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by uclinux-dev@uclinux.org
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev

Reply via email to