zoukankan      html  css  js  c++  java
  • iTOP4412设备驱动学习三--设备节点的生成和调用:杂项设备驱动的注册和调用

    本节是关于生成设备节点。

    学习资料来源于迅为的视频学习教程的整理

    1.区分概念:

        设备注册:platform_device,查看:/sys/devices/platform

        驱动注册:platform_driver

        生成设备节点:为了让应用程序可以调用,是"对上"的接口。

                                 与设备注册无关,设备节点名称不需要与设备名称相同。查看:/dev/*

                                 一般将设备节点的注册放在probe中,也可以放到init函数中。

        杂项设备,或者说是对一部分字符设备的封装或者一部分不好分类的。

        可以节省主设备号,驱动写起来相对简单(用封装好的杂项设备可以减少一步注册主设备号的过程)

    Linux设备驱动一般分为:字符设备,块设备,网络设备。也可以按照子系统来分类,如:mm,led等

    2.源代码位置

        杂项设备初始化源代码:/drivers/char/misc.c,属于内核中强制编译的。

        杂项设备注册头文件:include/linux/miscdevice.h,主要的结构体为miscdevice

     1 struct miscdevice  {
     2         int minor;     //设备号,一般系统分配随机取值
     3         const char *name;     //生成设备节点的名称,无限制
     4         const struct file_operations *fops;     //指向一个设备节点文件,对文件的操作
     5         struct list_head list;
     6         struct device *parent;
     7         struct device *this_device;
     8         const char *nodename;
     9         mode_t mode;
    10 };
    11 
    12 extern int misc_register(struct miscdevice * misc);    //生成设备节点的函数,一般在probe中被调用
    13 extern int misc_deregister(struct miscdevice *misc);

         设备节点本质是文件一个特殊文件,包括文件名,打开关闭等,文件结构体的头文件为include/linux/fs.h,结构体为file_operations

     1 //相当重要的结构体
     2 /*
     3  * NOTE:
     4  * all file operations except setlease can be called without
     5  * the big kernel lock held in all filesystems.
     6  */
     7 struct file_operations {
     8         struct module *owner;        //必选参数,一般是THIS_MODULE
     9         loff_t (*llseek) (struct file *, loff_t, int);
    10         ssize_t (*read) (struct file *, char __user *, size_t, loff_t *);
    11         ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *);
    12         ssize_t (*aio_read) (struct kiocb *, const struct iovec *, unsigned long, loff_t);
    13         ssize_t (*aio_write) (struct kiocb *, const struct iovec *, unsigned long, loff_t);
    14         int (*readdir) (struct file *, void *, filldir_t);
    15         unsigned int (*poll) (struct file *, struct poll_table_struct *);
    16 /* remove by cym 20130408 support for MT660.ko */
    17 #if 0
    18 //#ifdef CONFIG_SMM6260_MODEM
    19 #if 1// liang, Pixtree also need to use ioctl interface...
    20         int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
    21 #endif
    22 #endif
    23 /* end remove */
    24         long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);     //非必选,对GPIO操作,应用向底层驱动传值的
    25         long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
    26         int (*mmap) (struct file *, struct vm_area_struct *);
    27         int (*open) (struct inode *, struct file *);            //必选的参数,打开文件函数
    28         int (*flush) (struct file *, fl_owner_t id);
    29         int (*release) (struct inode *, struct file *);          //必选的参数,关闭文件函数
    30         int (*fsync) (struct file *, int datasync);
    31         int (*aio_fsync) (struct kiocb *, int datasync);
    32         int (*fasync) (int, struct file *, int);
    33         int (*lock) (struct file *, int, struct file_lock *);
    34         ssize_t (*sendpage) (struct file *, struct page *, int, size_t, loff_t *, int);
    35         unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
    36         int (*check_flags)(int);
    37         int (*flock) (struct file *, int, struct file_lock *);
    38         ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, loff_t *, size_t, unsigned int);
    39         ssize_t (*splice_read)(struct file *, loff_t *, struct pipe_inode_info *, size_t, unsigned int);
    40         int (*setlease)(struct file *, long, struct file_lock **);
    41         long (*fallocate)(struct file *file, int mode, loff_t offset,
    42                           loff_t len);
    43 /* add by cym 20130408 support for MT6260 and Pixtree */
    44 #if defined(CONFIG_SMM6260_MODEM) || defined(CONFIG_USE_GPIO_AS_I2C)
    45         int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);    //此处ioctl与上面的不一样
    46 #endif
    47 /* end add */
    48 };

    3. 驱动代码案例

     在probe_linux_module基础上写devicenode_linux_module驱动,注意函数调用顺序,/dev下查看

    devicenode_linux_module.c

     1 #include <linux/init.h>
     2 #include <linux/module.h>
     3 #include <linux/platform_device.h>
     4 //misc
     5 #include <linux/miscdevice.h>
     6 //注册设备节点的文件结构体
     7 #include <linux/fs.h>
     8 
     9 #define DRIVER_NAME "hello_ctl"
    10 #define DEVICE_NAME "hello_ctl123"
    11 
    12 static int hello_open(struct inode *inode, struct file *file){
    13     printk(KERN_EMERG "hello open
    ");        //调用步骤4-1
    14     return 0;
    15 }
    16 static int hello_release(struct inode *inode, struct file *file){
    17     printk(KERN_EMERG "hello release
    ");        //调用步骤4-2
    18     return 0;
    19 }
    20 static long hello_ioctl(struct file *file, unsigned int cmd, unsigned long arg){
    21     //打开之后操作的,所以参数里面不需要inode
    22     printk(KERN_EMERG "hello ioctl
    ");           //调用步骤4-3
    23     printk("cmd is %d, arg is %d
    ", cmd, arg);
    24     return 0;
    25 }
    26 //文件设备操作结构体
    27 static struct file_operations hello_ops = {
    28     .owner = THIS_MODULE,
    29      // int (*open) (struct inode *, struct file *);     
    30     .open = hello_open,                     //调用步骤3-1
    31          // int (*release) (struct inode *, struct file *)
    32     .release = hello_release,               //调用步骤3-2
    33      // long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
    34     .unlocked_ioctl = hello_ioctl,          //调用步骤3-3
    35 };
    36 //杂项设备结构体
    37 static struct miscdevice hello_dev = {
    38     .minor = MISC_DYNAMIC_MINOR,
    39     .name = DEVICE_NAME,
    40     .fops = &hello_ops,       //调用步骤2
    41 };
    42 
    43 
    44 static int hello_probe(struct platform_device *pdv){
    45     printk(KERN_EMERG "initialized
    ");
    46     misc_register(&hello_dev);      //一般在probe中调用.调用步骤1
    47     return 0;
    48 }
    49 static int hello_remove(struct platform_device *pdv){
    50     printk(KERN_EMERG "remove
    ");
    51     misc_deregister(&hello_dev);
    52     return 0;
    53 }
    54 static void hello_shutdown(struct platform_device *pdv){
    55     ;
    56 }
    57 static int hello_suspend(struct platform_device *pdv, pm_message_t pmt){
    58     return 0;
    59 }
    60 static int hello_resume(struct platform_device *pdev){
    61     return 0;
    62 }
    63 
    64 struct platform_driver hello_driver = {
    65     .probe = hello_probe,
    66     .remove = hello_remove,
    67     .shutdown = hello_shutdown,
    68     .suspend = hello_suspend,
    69     .resume = hello_resume,
    70     .driver = {
    71         .name = DRIVER_NAME,
    72         .owner = THIS_MODULE,
    73     }
    74 };
    75 
    76 static int hello_init(void)
    77 {
    78     int DriverState;
    79     printk(KERN_EMERG "hello world enter!
    ");
    80     DriverState=platform_driver_register(&hello_driver);
    81     printk(KERN_EMERG "DriverState is %d
    ", DriverState);
    82         return 0;
    83 }
    84 
    85 static void hello_exit(void)
    86 {
    87     printk(KERN_EMERG "hello world exit!
    ");
    88     platform_driver_unregister(&hello_driver); //unregister会查找release,如果找不到会报错
    89 }
    90 
    91 module_init(hello_init);
    92 module_exit(hello_exit);
    93 
    94 MODULE_LICENSE("Dual BSD/GPL");
    95 MODULE_AUTHOR("NANZH");

    Makefile

     1 obj-m += devicenode_linux_module.o
     2 
     3 KDIR := /home/nan/iTOP4412/iTop4412_Kernel_3.0
     4 
     5 PWD ?= $(shell pwd)
     6 
     7 all:
     8   make -C $(KDIR) M=$(PWD) modules 
     9 
    10 clean:
    11   rm -rf *.o

    测试结果:

     1 # 板子上:
     2 root@iTOP4412-ubuntu-desktop:# insmod devicenode_linux_module.ko 
     3 [  112.202074] hello world enter!
     4 [  112.203980] initialized
     5 [  112.236250] DriverState is 0
     6 查看生成的设备节点:
     7 root@iTOP4412-ubuntu-desktop:# ls -l /dev/hello_ctl123 
     8 crw------- 1 root root 10, 46 Nov 22 05:55 /dev/hello_ctl123
     9 root@iTOP4412-ubuntu-desktop:# rmmod devicenode_linux_module
    10 [  136.243713] hello world exit!
    11 [  136.246474] remove

    以上

    继编写简单的应用来调用设备节点:

    根据上面生成的/dev/hello_ctl123节点来调用,基于应用层的,所以使用基本的C文件形式。

    4. 函数头文件

        # include <stdio.h>     //printf

        # include <sys/types.h>   //基本系统数据类型,依据编译环境保持32位值还是64位值

        # include <sys/stat.h>    //系统调用头文件,如目录、管道、socket、字符、块的属性等

        # include <fcntl.h>    //定义了open函数

        # include <unistd>   //定义了close函数

        # include <sys/ioctl.h>    //定义了ioctl函数

    编译器使用的是arm-2009q3,即arm-none-linux-gnueabi-gcc。编译使用的头文件在编译器的libc下,如:

        /usr/local/arm/arm-2009q3/arm-none-linux-gnueabi/libc/usr/include/fcntl.h

    5. 函数

        open:返回文件描述符

        ioctl:应用向驱动传值

        close:关闭文件

    编译方法:arm-none-linux-gnueabi-gcc -o invoke_hello123 invoke_hello123.c

    6.详细的C文件:invoke_hello123.c

     1 #include <stdio.h>
     2 #include <sys/types.h>
     3 #include <sys/stat.h>
     4 #include <fcntl.h>
     5 #include <unistd.h>
     6 #include <sys/ioctl.h>
     7 
     8 int main()
     9 {
    10     int fd;
    11     char *hello_node = "/dev/hello_ctl123";  //设备节点的路径
    12 
    13     fd = open(hello_node, O_RDWR|O_NDELAY);  //只读,非阻塞方式
    14     if (fd < 0)
    15         perror("open");
    16     else{
    17         printf("App open %s success
    ",hello_node);
    18         ioctl(fd, 1, 6);
    19     }
    20 
    21     close(fd);
    22     return 0;
    23 }

    编译完成之后将编译产物invoke_hello123拷贝至开发板中运行,正确运行结果如下:

    查看运行结果:

     1 root@iTOP4412-ubuntu-desktop:~/tests/3# insmod devicenode_linux_module.ko 
     2 [ 1856.029716] hello world enter!
     3 [ 1856.040410] initialized
     4 [ 1856.068655] DriverState is 0
     5 root@iTOP4412-ubuntu-desktop:~/tests/3# ls /dev/hello_ctl123 
     6 /dev/hello_ctl123
     7 root@iTOP4412-ubuntu-desktop:~/tests/3# ls -l /dev/hello_ctl123 
     8 crw------- 1 root root 10, 46 Nov 22 07:29 /dev/hello_ctl123
     9 root@iTOP4412-ubuntu-desktop:~/tests/3# ./invoke_hello123 
    10 [ 1871.946816] hello open
    11 [ 1871.948367] hello ioctl
    12 App open /dev/hello_ctl123 success
    13 [ 1871.960204] hello release
    14 root@iTOP4412-ubuntu-desktop:~/tests/3# rmmod devicenode_linux_module
    15 [ 1880.317030] hello world exit!
    16 [ 1880.318624] remove

    dmesg中含有hello_ioctl调用的打印信息,上面没有直接打印出来,在dmesg中有。
    [   65.291707] hello world enter!
    [   65.293621] initialized
    [   65.321764] DriverState is 0
    [   69.906179] hello open
    [   69.930525] hello ioctl
    [   69.932853] cmd is 1, arg is 6
    [   69.932905] hello release

    在开发板上运行./invoke_hello123出错的log和解决如下:

    # ERROR
    root@iTOP4412-ubuntu-desktop:~/tests/3# ./invoke_hello123 
    -bash: ./invoke_hello123: No such file or directory
    解决方法:https://blog.csdn.net/qq_22863619/article/details/80294232
    iTOP4412-ubuntu-desktop:~/tests/3# readelf -a invoke_hello123  | grep Requesting 
          [Requesting program interpreter: /lib/ld-linux.so.3]
    
    由此发现缺少的是库文件:/lib/ld-linux.so.3
    遂到toolchain中查找:
    nan@nanzh:~/iTOP4412/4-1$ find /usr/local/arm/arm-2009q3/ -iname "ld-linux.so.3"
    /usr/local/arm/arm-2009q3/arm-none-linux-gnueabi/libc/lib/ld-linux.so.3
    /usr/local/arm/arm-2009q3/arm-none-linux-gnueabi/libc/thumb2/lib/ld-linux.so.3
    /usr/local/arm/arm-2009q3/arm-none-linux-gnueabi/libc/armv4t/lib/ld-linux.so.3
    nan@nanzh:~/iTOP4412/4-1$ ls -l /usr/local/arm/arm-2009q3/arm-none-linux-gnueabi/libc/lib/ld-linux.so.3
    lrwxrwxrwx 1 nan nan 12 10月 17  2009 /usr/local/arm/arm-2009q3/arm-none-linux-gnueabi/libc/lib/ld-linux.so.3 -> ld-2.10.1.so
    于是将ld-2.10.1.so拷贝到开发板中并设置软连接
    root@iTOP4412-ubuntu-desktop:# cp /mnt/ld-2.10.1.so /lib
    root@iTOP4412-ubuntu-desktop:/lib# ln -s ld-2.10.1.so ld-linux.so.3
    
    #ERROR 2
    root@iTOP4412-ubuntu-desktop:~/tests/3# ./invoke_hello123 
    ./invoke_hello123: error while loading shared libraries: libgcc_s.so.1: cannot open shared object file: No such file or directory
    方法:
    nan@nanzh:~/iTOP4412/4-1$ find /usr/local/arm/arm-2009q3/ -iname "libgcc_s.so.1"
    /usr/local/arm/arm-2009q3/arm-none-linux-gnueabi/libc/lib/libgcc_s.so.1
    /usr/local/arm/arm-2009q3/arm-none-linux-gnueabi/libc/thumb2/lib/libgcc_s.so.1
    /usr/local/arm/arm-2009q3/arm-none-linux-gnueabi/libc/armv4t/lib/libgcc_s.so.1
    nan@nanzh:~/iTOP4412/4-1$ ls -l /usr/local/arm/arm-2009q3/arm-none-linux-gnueabi/libc/lib/libgcc_s.so.1
    -rw-r--r-- 1 nan nan 69371 10月 17  2009 /usr/local/arm/arm-2009q3/arm-none-linux-gnueabi/libc/lib/libgcc_s.so.1
    拷贝到板子上继续
    root@iTOP4412-ubuntu-desktop:~/tests/3# cp /mnt/libgcc_s.so.1 /lib/
    root@iTOP4412-ubuntu-desktop:~/tests/3# ./invoke_hello123 
    ./invoke_hello123: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
    
    nan@nanzh:~/iTOP4412/4-1$ find /usr/local/arm/arm-2009q3/ -iname "libc.so.6"
    /usr/local/arm/arm-2009q3/arm-none-linux-gnueabi/libc/lib/libc.so.6
    /usr/local/arm/arm-2009q3/arm-none-linux-gnueabi/libc/thumb2/lib/libc.so.6
    /usr/local/arm/arm-2009q3/arm-none-linux-gnueabi/libc/armv4t/lib/libc.so.6
    nan@nanzh:~/iTOP4412/4-1$ ls -l /usr/local/arm/arm-2009q3/arm-none-linux-gnueabi/libc/lib/libc.so.6
    lrwxrwxrwx 1 nan nan 14 10月 17  2009 /usr/local/arm/arm-2009q3/arm-none-linux-gnueabi/libc/lib/libc.so.6 -> libc-2.10.1.so
    root@iTOP4412-ubuntu-desktop:~/tests/3# mount /dev/sdb3 /mnt
    root@iTOP4412-ubuntu-desktop:~/tests/3# cp /mnt/libc-2.10.1.so /lib
    root@iTOP4412-ubuntu-desktop:~/tests/3# cd /lib
    root@iTOP4412-ubuntu-desktop:/lib# ln -s libc-2.10.1.so libc.so.6
    
    以上总结,缺少库:/lib/ld-linux.so.3,libgcc_s.so.1,libc.so.6

    使用readelf查看的具体内容如下。(ldd用于动态库)

    root@iTOP4412-ubuntu-desktop:~/tests/3# readelf -a invoke_hello123 
    ELF Header:
      Magic:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 
      Class:                             ELF32
      Data:                              2's complement, little endian
      Version:                           1 (current)
      OS/ABI:                            UNIX - System V
      ABI Version:                       0
      Type:                              EXEC (Executable file)
      Machine:                           ARM
      Version:                           0x1
      Entry point address:               0x8440
      Start of program headers:          52 (bytes into file)
      Start of section headers:          2488 (bytes into file)
      Flags:                             0x5000002, has entry point, Version5 EABI
      Size of this header:               52 (bytes)
      Size of program headers:           32 (bytes)
      Number of program headers:         8
      Size of section headers:           40 (bytes)
      Number of section headers:         31
      Section header string table index: 28
    
    Section Headers:
      [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
      [ 0]                   NULL            00000000 000000 000000 00      0   0  0
      [ 1] .interp           PROGBITS        00008134 000134 000013 00   A  0   0  1
      [ 2] .note.ABI-tag     NOTE            00008148 000148 000020 00   A  0   0  4
      [ 3] .hash             HASH            00008168 000168 000044 04   A  4   0  4
      [ 4] .dynsym           DYNSYM          000081ac 0001ac 0000c0 10   A  5   1  4
      [ 5] .dynstr           STRTAB          0000826c 00026c 0000b3 00   A  0   0  1
      [ 6] .gnu.version      VERSYM          00008320 000320 000018 02   A  4   0  2
      [ 7] .gnu.version_r    VERNEED         00008338 000338 000040 00   A  5   2  4
      [ 8] .rel.dyn          REL             00008378 000378 000008 08   A  4   0  4
      [ 9] .rel.plt          REL             00008380 000380 000040 08   A  4  11  4
      [10] .init             PROGBITS        000083c0 0003c0 00000c 00  AX  0   0  4
      [11] .plt              PROGBITS        000083cc 0003cc 000074 04  AX  0   0  4
      [12] .text             PROGBITS        00008440 000440 000204 00  AX  0   0  4
      [13] .fini             PROGBITS        00008644 000644 000008 00  AX  0   0  4
      [14] .rodata           PROGBITS        0000864c 00064c 000038 00   A  0   0  4
      [15] .ARM.extab        PROGBITS        00008684 000684 000018 00   A  0   0  4
      [16] .ARM.exidx        ARM_EXIDX       0000869c 00069c 000038 00  AL 12   0  4
      [17] .eh_frame         PROGBITS        000086d4 0006d4 000004 00   A  0   0  4
      [18] .init_array       INIT_ARRAY      000106d8 0006d8 000004 00  WA  0   0  4
      [19] .fini_array       FINI_ARRAY      000106dc 0006dc 000004 00  WA  0   0  4
      [20] .jcr              PROGBITS        000106e0 0006e0 000004 00  WA  0   0  4
      [21] .dynamic          DYNAMIC         000106e4 0006e4 0000f0 08  WA  5   0  4
      [22] .got              PROGBITS        000107d4 0007d4 000030 04  WA  0   0  4
      [23] .data             PROGBITS        00010804 000804 000008 00  WA  0   0  4
      [24] .bss              NOBITS          0001080c 00080c 000004 00  WA  0   0  1
      [25] .ARM.attributes   ARM_ATTRIBUTES  00000000 00080c 000029 00      0   0  1
      [26] .comment          PROGBITS        00000000 000835 00002a 00      0   0  1
      [27] .debug_frame      PROGBITS        00000000 000860 00004c 00      0   0  4
      [28] .shstrtab         STRTAB          00000000 0008ac 00010b 00      0   0  1
      [29] .symtab           SYMTAB          00000000 000e90 0006f0 10     30  81  4
      [30] .strtab           STRTAB          00000000 001580 0002d9 00      0   0  1
    Key to Flags:
      W (write), A (alloc), X (execute), M (merge), S (strings)
      I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown)
      O (extra OS processing required) o (OS specific), p (processor specific)
    
    There are no section groups in this file.
    
    Program Headers:
      Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
      EXIDX          0x00069c 0x0000869c 0x0000869c 0x00038 0x00038 R   0x4
      PHDR           0x000034 0x00008034 0x00008034 0x00100 0x00100 R E 0x4
      INTERP         0x000134 0x00008134 0x00008134 0x00013 0x00013 R   0x1
          [Requesting program interpreter: /lib/ld-linux.so.3]
      LOAD           0x000000 0x00008000 0x00008000 0x006d8 0x006d8 R E 0x8000
      LOAD           0x0006d8 0x000106d8 0x000106d8 0x00134 0x00138 RW  0x8000
      DYNAMIC        0x0006e4 0x000106e4 0x000106e4 0x000f0 0x000f0 RW  0x4
      NOTE           0x000148 0x00008148 0x00008148 0x00020 0x00020 R   0x4
      GNU_STACK      0x000000 0x00000000 0x00000000 0x00000 0x00000 RW  0x4
    
     Section to Segment mapping:
      Segment Sections...
       00     .ARM.exidx 
       01     
       02     .interp 
       03     .interp .note.ABI-tag .hash .dynsym .dynstr .gnu.version .gnu.version_r .rel.dyn .rel.plt .init .plt .text .fini .rodata .ARM.extab .ARM.exidx .eh_frame 
       04     .init_array .fini_array .jcr .dynamic .got .data .bss 
       05     .dynamic 
       06     .note.ABI-tag 
       07     
    
    Dynamic section at offset 0x6e4 contains 25 entries:
      Tag        Type                         Name/Value
     0x00000001 (NEEDED)                     Shared library: [libgcc_s.so.1]
     0x00000001 (NEEDED)                     Shared library: [libc.so.6]
     0x0000000c (INIT)                       0x83c0
     0x0000000d (FINI)                       0x8644
     0x00000019 (INIT_ARRAY)                 0x106d8
     0x0000001b (INIT_ARRAYSZ)               4 (bytes)
     0x0000001a (FINI_ARRAY)                 0x106dc
     0x0000001c (FINI_ARRAYSZ)               4 (bytes)
     0x00000004 (HASH)                       0x8168
     0x00000005 (STRTAB)                     0x826c
     0x00000006 (SYMTAB)                     0x81ac
     0x0000000a (STRSZ)                      179 (bytes)
     0x0000000b (SYMENT)                     16 (bytes)
     0x00000015 (DEBUG)                      0x0
     0x00000003 (PLTGOT)                     0x107d4
     0x00000002 (PLTRELSZ)                   64 (bytes)
     0x00000014 (PLTREL)                     REL
     0x00000017 (JMPREL)                     0x8380
     0x00000011 (REL)                        0x8378
     0x00000012 (RELSZ)                      8 (bytes)
     0x00000013 (RELENT)                     8 (bytes)
     0x6ffffffe (VERNEED)                    0x8338
     0x6fffffff (VERNEEDNUM)                 2
     0x6ffffff0 (VERSYM)                     0x8320
     0x00000000 (NULL)                       0x0
    
    Relocation section '.rel.dyn' at offset 0x378 contains 1 entries:
     Offset     Info    Type            Sym.Value  Sym. Name
    00010800  00000515 R_ARM_GLOB_DAT    00000000   __gmon_start__
    
    Relocation section '.rel.plt' at offset 0x380 contains 8 entries:
     Offset     Info    Type            Sym.Value  Sym. Name
    000107e0  00000116 R_ARM_JUMP_SLOT   000083e0   open
    000107e4  00000216 R_ARM_JUMP_SLOT   000083ec   abort
    000107e8  00000316 R_ARM_JUMP_SLOT   000083f8   __libc_start_main
    000107ec  00000516 R_ARM_JUMP_SLOT   00000000   __gmon_start__
    000107f0  00000716 R_ARM_JUMP_SLOT   00008410   perror
    000107f4  00000816 R_ARM_JUMP_SLOT   0000841c   ioctl
    000107f8  00000916 R_ARM_JUMP_SLOT   00008428   printf
    000107fc  00000a16 R_ARM_JUMP_SLOT   00008434   close
    
    Unwind table index '.ARM.exidx' at offset 0x69c contains 7 entries:
    
    0x8440 <_start>: 0x1 [cantunwind]
    
    0x84a0 <__do_global_dtors_aux>: 0x80b0b0b0
      Compact model 0
      0xb0      finish
      0xb0      finish
      0xb0      finish
    
    0x84bc <frame_dummy>: @0x8684
      Compact model 1
      0xb1 0x08 pop {r3}
      0x84 0x00 pop {r14}
      0xb0      finish
      0xb0      finish
    
    0x84ec <main>: @0x8690
      Compact model 1
      0x9b      vsp = r11
      0x40      vsp = vsp - 4
      0x84 0x80 pop {r11, r14}
      0xb0      finish
      0xb0      finish
    
    0x8574 <__libc_csu_fini>: 0x80b0b0b0
      Compact model 0
      0xb0      finish
      0xb0      finish
      0xb0      finish
    
    0x8578 <__libc_csu_init>: 0x80aeb0b0
      Compact model 0
      0xae      pop {r4, r5, r6, r7, r8, r9, r10r14}
      0xb0      finish
      0xb0      finish
    
    0x8644 <_fini>: 0x1 [cantunwind]
    
    
    Symbol table '.dynsym' contains 12 entries:
       Num:    Value  Size Type    Bind   Vis      Ndx Name
         0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND 
         1: 000083e0     0 FUNC    GLOBAL DEFAULT  UND open@GLIBC_2.4 (2)
         2: 000083ec     0 FUNC    GLOBAL DEFAULT  UND abort@GLIBC_2.4 (2)
         3: 000083f8     0 FUNC    GLOBAL DEFAULT  UND __libc_start_main@GLIBC_2.4 (2)
         4: 00000000     0 FUNC    GLOBAL DEFAULT  UND __aeabi_unwind_cpp_pr0@GCC_3.5 (3)
         5: 00000000     0 NOTYPE  WEAK   DEFAULT  UND __gmon_start__
         6: 00000000     0 NOTYPE  WEAK   DEFAULT  UND _Jv_RegisterClasses
         7: 00008410     0 FUNC    GLOBAL DEFAULT  UND perror@GLIBC_2.4 (2)
         8: 0000841c     0 FUNC    GLOBAL DEFAULT  UND ioctl@GLIBC_2.4 (2)
         9: 00008428     0 FUNC    GLOBAL DEFAULT  UND printf@GLIBC_2.4 (2)
        10: 00008434     0 FUNC    GLOBAL DEFAULT  UND close@GLIBC_2.4 (2)
        11: 00000000     0 FUNC    GLOBAL DEFAULT  UND __aeabi_unwind_cpp_pr1@GCC_3.5 (3)
    
    Symbol table '.symtab' contains 111 entries:
       Num:    Value  Size Type    Bind   Vis      Ndx Name
         0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND 
         1: 00008134     0 SECTION LOCAL  DEFAULT    1 
         2: 00008148     0 SECTION LOCAL  DEFAULT    2 
         3: 00008168     0 SECTION LOCAL  DEFAULT    3 
         4: 000081ac     0 SECTION LOCAL  DEFAULT    4 
         5: 0000826c     0 SECTION LOCAL  DEFAULT    5 
         6: 00008320     0 SECTION LOCAL  DEFAULT    6 
         7: 00008338     0 SECTION LOCAL  DEFAULT    7 
         8: 00008378     0 SECTION LOCAL  DEFAULT    8 
         9: 00008380     0 SECTION LOCAL  DEFAULT    9 
        10: 000083c0     0 SECTION LOCAL  DEFAULT   10 
        11: 000083cc     0 SECTION LOCAL  DEFAULT   11 
        12: 00008440     0 SECTION LOCAL  DEFAULT   12 
        13: 00008644     0 SECTION LOCAL  DEFAULT   13 
        14: 0000864c     0 SECTION LOCAL  DEFAULT   14 
        15: 00008684     0 SECTION LOCAL  DEFAULT   15 
        16: 0000869c     0 SECTION LOCAL  DEFAULT   16 
        17: 000086d4     0 SECTION LOCAL  DEFAULT   17 
        18: 000106d8     0 SECTION LOCAL  DEFAULT   18 
        19: 000106dc     0 SECTION LOCAL  DEFAULT   19 
        20: 000106e0     0 SECTION LOCAL  DEFAULT   20 
        21: 000106e4     0 SECTION LOCAL  DEFAULT   21 
        22: 000107d4     0 SECTION LOCAL  DEFAULT   22 
        23: 00010804     0 SECTION LOCAL  DEFAULT   23 
        24: 0001080c     0 SECTION LOCAL  DEFAULT   24 
        25: 00000000     0 SECTION LOCAL  DEFAULT   25 
        26: 00000000     0 SECTION LOCAL  DEFAULT   26 
        27: 00000000     0 SECTION LOCAL  DEFAULT   27 
        28: 0000847c     0 NOTYPE  LOCAL  DEFAULT   12 $a
        29: 0000847c     0 FUNC    LOCAL  DEFAULT   12 call_gmon_start
        30: 00008498     0 NOTYPE  LOCAL  DEFAULT   12 $d
        31: 000083c0     0 NOTYPE  LOCAL  DEFAULT   10 $a
        32: 00008644     0 NOTYPE  LOCAL  DEFAULT   13 $a
        33: 00008148     0 NOTYPE  LOCAL  DEFAULT    2 $d
        34: 00008440     0 NOTYPE  LOCAL  DEFAULT   12 $a
        35: 0000869c     0 NOTYPE  LOCAL  DEFAULT   16 $d
        36: 00008470     0 NOTYPE  LOCAL  DEFAULT   12 $d
        37: 00000000     0 FILE    LOCAL  DEFAULT  ABS init.c
        38: 0000864c     0 NOTYPE  LOCAL  DEFAULT   14 $d
        39: 000083c8     0 NOTYPE  LOCAL  DEFAULT   10 $a
        40: 00008648     0 NOTYPE  LOCAL  DEFAULT   13 $a
        41: 00000000     0 FILE    LOCAL  DEFAULT  ABS crtstuff.c
        42: 000106e0     0 OBJECT  LOCAL  DEFAULT   20 __JCR_LIST__
        43: 00010808     0 NOTYPE  LOCAL  DEFAULT   23 $d
        44: 000084a0     0 NOTYPE  LOCAL  DEFAULT   12 $a
        45: 000084a0     0 FUNC    LOCAL  DEFAULT   12 __do_global_dtors_aux
        46: 000084b8     0 NOTYPE  LOCAL  DEFAULT   12 $d
        47: 0001080c     1 OBJECT  LOCAL  DEFAULT   24 completed.6082
        48: 000086a4     0 NOTYPE  LOCAL  DEFAULT   16 $d
        49: 000106dc     0 NOTYPE  LOCAL  DEFAULT   19 $d
        50: 000106dc     0 OBJECT  LOCAL  DEFAULT   19 __do_global_dtors_aux_fin
        51: 000084bc     0 NOTYPE  LOCAL  DEFAULT   12 $a
        52: 000084bc     0 FUNC    LOCAL  DEFAULT   12 frame_dummy
        53: 000084e4     0 NOTYPE  LOCAL  DEFAULT   12 $d
        54: 00008684     0 NOTYPE  LOCAL  DEFAULT   15 $d
        55: 000106d8     0 NOTYPE  LOCAL  DEFAULT   18 $d
        56: 000106d8     0 OBJECT  LOCAL  DEFAULT   18 __frame_dummy_init_array_
        57: 0001080c     0 NOTYPE  LOCAL  DEFAULT   24 $d
        58: 00000000     0 FILE    LOCAL  DEFAULT  ABS invoke_hello123.c
        59: 00008650     0 NOTYPE  LOCAL  DEFAULT   14 $d
        60: 000084ec     0 NOTYPE  LOCAL  DEFAULT   12 $a
        61: 00008564     0 NOTYPE  LOCAL  DEFAULT   12 $d
        62: 00008690     0 NOTYPE  LOCAL  DEFAULT   15 $d
        63: 000086b4     0 NOTYPE  LOCAL  DEFAULT   16 $d
        64: 00000000     0 FILE    LOCAL  DEFAULT  ABS elf-init.c
        65: 00008574     0 NOTYPE  LOCAL  DEFAULT   12 $a
        66: 000086bc     0 NOTYPE  LOCAL  DEFAULT   16 $d
        67: 00008638     0 NOTYPE  LOCAL  DEFAULT   12 $d
        68: 00000010     0 NOTYPE  LOCAL  DEFAULT   27 $d
        69: 00000000     0 FILE    LOCAL  DEFAULT  ABS crtstuff.c
        70: 000086d4     0 NOTYPE  LOCAL  DEFAULT   17 $d
        71: 000086d4     0 OBJECT  LOCAL  DEFAULT   17 __FRAME_END__
        72: 000106e0     0 NOTYPE  LOCAL  DEFAULT   20 $d
        73: 000106e0     0 OBJECT  LOCAL  DEFAULT   20 __JCR_END__
        74: 000107d4     0 OBJECT  LOCAL  HIDDEN    22 _GLOBAL_OFFSET_TABLE_
        75: 000106dc     0 NOTYPE  LOCAL  HIDDEN    18 __init_array_end
        76: 000106d8     0 NOTYPE  LOCAL  HIDDEN    18 __init_array_start
        77: 000106e4     0 OBJECT  LOCAL  HIDDEN    21 _DYNAMIC
        78: 000083cc     0 NOTYPE  LOCAL  DEFAULT   11 $a
        79: 000083dc     0 NOTYPE  LOCAL  DEFAULT   11 $d
        80: 000083e0     0 NOTYPE  LOCAL  DEFAULT   11 $a
        81: 00010804     0 NOTYPE  WEAK   DEFAULT   23 data_start
        82: 000083e0     0 FUNC    GLOBAL DEFAULT  UND open@@GLIBC_2.4
        83: 000083ec     0 FUNC    GLOBAL DEFAULT  UND abort@@GLIBC_2.4
        84: 00008574     4 FUNC    GLOBAL DEFAULT   12 __libc_csu_fini
        85: 00008440     0 FUNC    GLOBAL DEFAULT   12 _start
        86: 000083f8     0 FUNC    GLOBAL DEFAULT  UND __libc_start_main@@GLIBC_
        87: 00000000     0 FUNC    GLOBAL DEFAULT  UND __aeabi_unwind_cpp_pr0@@G
        88: 00000000     0 NOTYPE  WEAK   DEFAULT  UND __gmon_start__
        89: 00000000     0 NOTYPE  WEAK   DEFAULT  UND _Jv_RegisterClasses
        90: 00008644     0 FUNC    GLOBAL DEFAULT   13 _fini
        91: 00008410     0 FUNC    GLOBAL DEFAULT  UND perror@@GLIBC_2.4
        92: 0000864c     4 OBJECT  GLOBAL DEFAULT   14 _IO_stdin_used
        93: 00010804     0 NOTYPE  GLOBAL DEFAULT   23 __data_start
        94: 0001080c     0 NOTYPE  GLOBAL DEFAULT  ABS __bss_start__
        95: 0000841c     0 FUNC    GLOBAL DEFAULT  UND ioctl@@GLIBC_2.4
        96: 000086d4     0 NOTYPE  GLOBAL DEFAULT  ABS __exidx_end
        97: 00010808     0 OBJECT  GLOBAL HIDDEN    23 __dso_handle
        98: 00010810     0 NOTYPE  GLOBAL DEFAULT  ABS __end__
        99: 00008578   204 FUNC    GLOBAL DEFAULT   12 __libc_csu_init
       100: 00010810     0 NOTYPE  GLOBAL DEFAULT  ABS __bss_end__
       101: 00008428     0 FUNC    GLOBAL DEFAULT  UND printf@@GLIBC_2.4
       102: 00008434     0 FUNC    GLOBAL DEFAULT  UND close@@GLIBC_2.4
       103: 0001080c     0 NOTYPE  GLOBAL DEFAULT  ABS __bss_start
       104: 00010810     0 NOTYPE  GLOBAL DEFAULT  ABS _bss_end__
       105: 00010810     0 NOTYPE  GLOBAL DEFAULT  ABS _end
       106: 0001080c     0 NOTYPE  GLOBAL DEFAULT  ABS _edata
       107: 0000869c     0 NOTYPE  GLOBAL DEFAULT  ABS __exidx_start
       108: 00000000     0 FUNC    GLOBAL DEFAULT  UND __aeabi_unwind_cpp_pr1@@G
       109: 000084ec   136 FUNC    GLOBAL DEFAULT   12 main
       110: 000083c0     0 FUNC    GLOBAL DEFAULT   10 _init
    
    Histogram for bucket list length (total of 3 buckets):
     Length  Number     % of total  Coverage
          0  0          (  0.0%)
          1  0          (  0.0%)      0.0%
          2  1          ( 33.3%)     18.2%
          3  0          (  0.0%)     18.2%
          4  1          ( 33.3%)     54.5%
          5  1          ( 33.3%)    100.0%
    
    Version symbols section '.gnu.version' contains 12 entries:
     Addr: 0000000000008320  Offset: 0x000320  Link: 4 (.dynsym)
      000:   0 (*local*)       2 (GLIBC_2.4)     2 (GLIBC_2.4)     2 (GLIBC_2.4)  
      004:   3 (GCC_3.5)       0 (*local*)       0 (*local*)       2 (GLIBC_2.4)  
      008:   2 (GLIBC_2.4)     2 (GLIBC_2.4)     2 (GLIBC_2.4)     3 (GCC_3.5)    
    
    Version needs section '.gnu.version_r' contains 2 entries:
     Addr: 0x0000000000008338  Offset: 0x000338  Link: 5 (.dynstr)
      000000: Version: 1  File: libgcc_s.so.1  Cnt: 1
      0x0010:   Name: GCC_3.5  Flags: none  Version: 3
      0x0020: Version: 1  File: libc.so.6  Cnt: 1
      0x0030:   Name: GLIBC_2.4  Flags: none  Version: 2
    
    Notes at offset 0x00000148 with length 0x00000020:
      Owner                 Data size    Description
      GNU                  0x00000010    NT_GNU_ABI_TAG (ABI version tag)
        OS: Linux, ABI: 2.6.16
    Attribute Section: aeabi
    File Attributes
      Tag_CPU_name: "5TE"
      Tag_CPU_arch: v5TE
      Tag_ARM_ISA_use: Yes
      Tag_THUMB_ISA_use: Thumb-1
      Tag_ABI_PCS_wchar_t: 4
      Tag_ABI_FP_denormal: Needed
      Tag_ABI_FP_exceptions: Needed
      Tag_ABI_FP_number_model: IEEE 754
      Tag_ABI_align_needed: 8-byte
      Tag_ABI_align_preserved: 8-byte, except leaf SP
      Tag_ABI_enum_size: int
    View Code

    至此设备节点的注册和调用

  • 相关阅读:
    Windows 编程
    javascript 快速入门
    python 在windows下监听键盘按键
    eleme 项目使用到的库
    lftp 快速使用
    自动测试工具
    Cookie(1)
    fillder script使用
    Boost.Hana
    Haskell语言学习笔记(50)Extra
  • 原文地址:https://www.cnblogs.com/nanzh/p/12444029.html
Copyright © 2011-2022 走看看