Library ??? - PowerPoint PPT Presentation

About This Presentation
Title:

Library ???

Description:

Library imggaibi_at_hotmail.com library Compile Gcc c file_name ... – PowerPoint PPT presentation

Number of Views:86
Avg rating:3.0/5.0
Slides: 10
Provided by: LEES168
Category:
Tags: library

less

Transcript and Presenter's Notes

Title: Library ???


1
Library ???
  • ???
  • imggaibi_at_hotmail.com

2
?? library
  • Compile
  • Gcc c file_name
  • ?????? ???? ?? ??? ??? ???? ???? ??? ???.
  • ?? ????? ??
  • Ar crv liblib_name.a file_name.o
  • ?????? ???? ???? ?? ar? ????.
  • ??? ? ?? ?? ???? ???? ???? ???? ???? ????.
  • ????? ?? ??
  • Ranlib liblib_name.a
  • ?????? ????? ???? ?? ????? ??? ??? ??? ??.
  • GNU ????? ?? ??? ??? ?? ? ??? ???? ?? ????.
  • ??
  • Gcc o runable_name file_name.c L. llib_name
  • ?????? ???? ?? ?????? ??? ??? ???? ? ??.
  • -L ?????? ?? ??
  • -l ????? ????? ? ??

3
?? library
  • Rename
  • ???? ?? ??? ??? libfile_name.c? ??
  • Compile
  • Gcc fPIC Wall g c libfile_name.c
  • Library ??
  • Gcc g shared Wl , -soname,libfile_name.so.0
    o libfile_name.so.0.0 libfile_name.o lc
  • ?? ??
  • Ln sf libfile_name.so.0.0 libfile_name.so.0
  • ?? ??? ?? ??
  • Ln sf libfile_name.so.0 libfile_name.so
  • ??
  • Gcc o runable_filename runable_filename.c L.
    lfile_name
  • ?? ??
  • ????? ?? ??
  • LD_LIBRARY_PATHLD_LIBRARY_PATH(pwd)
  • Export LD_LIBRARY_PATH

4
??? ? ?? (1)
  • ??? ? ??? ?? ??
  • ?? ??
  • ??? ? ??? ????.
  • Linux2.4/include/asm/unistd.h
  • sys_call_table? ????.
  • Linux2.4/arch/arm/kernel/calls.S
  • ??? ???? ??? ??
  • Linux2.4/arch/arm/kernel/? ??
  • ??? ?????.
  • Linux2.4/arch/arm/kernel/Makefile
  • ??? ?? ?????.

5
??? ? ?? (2)
  • ??? ??? ?? ???? ?? ????? ????.
  • ??? ??? ?? ???? ????? ????.
  • ?????? ????. (ar, ranlib)

6
??? ? ?? (3)
  • sys_call_table
  • syscall number Linux2.4/include/asm/unistd.h
  • define __NR_SYSCALL_BASE 0x900000
  • define __NR_exit (__NR_SYSCALL_BASE 1)
  • define __NR_fork (__NR_SYSCALL_BASE 2)
  • define __NR_read (__NR_SYSCALL_BASE 3)
  • .
  • define __NR_wrapper (__NR_SYSCALL_BASE 227)
  • sys_call_table Linux2.4/arch/arm/kernel/calls.S
  • ENTRY(sys_call_table)
  • .long SYMBOL_NAME(sys_ni_syscall) / 0 /
  • .long SYMBOL_NAME(sys_exit) / 1 /
  • .long SYMBOL_NAME(sys_fork_wrapper) / 2 /
  • .long SYMBOL_NAME(sys_read) / 3 /
  • .
  • .long SYMBOL_NAME(sys_wrapper) / 227 /
  • .rept NR_syscalls-216
  • .long SYMBOL_NAME(sys_ni_syscall)
  • .endr

7
??? ? ?? (4)
  • ?? ??? ??? ? ??? ???? ??
  • asmlinkage int sys_fork(regs) /
    arch/arm/kernel/sys_arm.c /
  • return do_fork(..)
  • int do_fork(..) / kernel/fork.c /
  • .
  • / create new process /
  • asmlinkage int sys_read(fd, buf, count) /
    fs/read_write.c /
  • ..
  • / read data /

8
??? ? ?? (5)
  • ??? ? ?? ?? (2)
  • 3. ??? ? ?? ?? (kernel/mysyscall.c)
  • asmlinkage int sys_wrapper(int a, int b)
  • printk(Hello Linux, Im in
    Kernel\n)
  • return a b
  • 4. Makefile ?? (kernel/Makefile)
  • O_OBJS sched.o fork.o exec_domain.o panic.o
    printk.o \
  • wrapper.o
  • 5. ?? ? ???

9
??? ? ?? (6)
  • ??? ? ?? ?? (3)
  • 6. ??? ???? ??
  • include ltlinux/unistd.hgt
  • include ltstdio.hgt
  • _syscall2(int, wrapper)
  • int main()
  • printf(sum d (use wrapper())\n", wrapper(10,
    10))
Write a Comment
User Comments (0)
About PowerShow.com