2009年7月29日星期三
fedora11 flash插件安装
http://get.adobe.com/flashplayer/ 网站上下载install_flash_player_10_linux.tar.gz文件.
2.复制到mozilla插件文件夹
将下载的文件解压 后,将libflashplayer.so文件复制到/usr/lib/mozilla/plugins/文件夹下.
2009年7月27日星期一
2009年7月20日星期一
mount kvm disk image
1. kpartx -av disk.img
add map loop0p1 (253:0): 0 1863477 linear /dev/loop0 63
add map loop0p2 (253:1): 0 224910 linear /dev/loop0 1863540
add map loop0p5 : 0 224847 linear 253:1 63
2. mount /dev/mapper/loop0p1 /mnt/
通常image的根文件系统都被映射到loop0p1
卸载
1. unmount /mnt
2. kpartx -dv diks.img
del devmap : loop0p5
del devmap : loop0p2
del devmap : loop0p1
2009年7月13日星期一
linux 动态连接加载器 ld-linux用法
间接调用时,连接器会把ld-linux的执行路径嵌入到可执行文件中,如elf文件时,ld-linux被放在.interp段中。
直接调用时,在命令行下输入/lib/ld-linux-so.* [选项] [可执行程序] [程序参数]
ld-linux按照如下顺序搜索可执行程序需要的共享库:
1. (只针对elf文件) 可执行程序中如果有DT_RPATH或DT_RUNPATH段,则使用这两个段中指定的搜索目录。
2.使用环境变量LD_LIBRARY_PATH指定的搜索目录
3.使用/etc/ld.so.cache中的搜索目录,但如果可执行程序在连接时候添加了-z nodeflib选项,则不使用。
4.使用默认的库目录,/lib /usr/lib,如果添加了-z nodeflib,则不使用。
编译可执行程序时,可以安如下方法指定共享库的目录
gcc -Xlinker -rpath=DIR -o exe exe.c
编译完后,运行readelf -d exe可以看到如下段
0x0000000f (RPATH) Library rpath: [DIR]
2009年7月8日星期三
TFT LCD 接口时序计算
1.VSYNC: 帧频率 一秒钟处理的帧的数目 (Frame Frequency)
2.HSYNC: 行频率 一秒钟处理的行的数目
3.DOTCLK: 像素频率 一秒钟处理的像素数目
同时,还有如下接口参数:
VBP: vertical back porch 垂直方向后端没使用的行数
VFP: vertical front porch 垂直方向前端没使用的行数
HBP: horizonal back porch 水平方向后端没使用的像素数目
HFP: horizonal front porch 水平方向前端没使用的像素数目
DOTCLK = FrameRate(VSYNC) * 行总数 *行中的像素总数
行总数 = LCD 高 + VBP + VFP
行中的像素总数= LCD宽 + HBP + HFP
(注:有些LCD,还需要在行总数中加上VSYNC宽度,在行中像素总数中加上HSYNC宽度)
以LMS430HF02这款LCD为例
帧频率是60帧/秒
LCD高度是272行
LCD宽度是480个像素
VBP= 12.0 # line
VFP= 4.0 # line
HBP= 45.0 # pixel
HFP= 8.0 # pixel
DOTCLK = VSYNC* (lcd_width + hbp + hfp) * (lcd_height+ vbp + vfp)
/1000000 = 9.21024Mhz
和LCD datasheet中提供的接口时序说明基本一致。
2009年7月1日星期三
裁剪libc
How to reduce libc size
From NetBSD Wiki
Jump to: navigation, search
Contents
[hide]
* 1 Introduction
* 2 Build options
o 2.1 Default -O2, file size 1164025
o 2.2 -O1, file size 1159845
+ 2.2.1 Linker strip, file size 1065624
o 2.3 -Os, file size 1094281
+ 2.3.1 Manual strip, file size 1004180
+ 2.3.2 Linker strip, file size 1000060
* 3 Feature removal
o 3.1 SCCS version strings, file size 953136
o 3.2 Hesiod name service, file size 942468
o 3.3 Yellow Pages (YP), file size 917368
o 3.4 IPv6 support, file size 909272
o 3.5 Stack smashing protection (SSP), file size 894764
o 3.6 Remote procedure call (RPC), file size 806036
o 3.7 Execution profiling control, file size 801720
o 3.8 Citrus I18N, file size 767560
o 3.9 MD2, RMD160, SHA1, SHA2, MD4 and MD5 cryptographic
hash functions, file size 723780
o 3.10 Misc, Native Language Support (NLS), Regular
Expression and Stack Smashing Protection, file size 691884
* 4 Ideas
o 4.1 Compiler options
+ 4.1.1 Thumb instruction set, file size 585440
o 4.2 Feature removals
+ 4.2.1 Database support from lib/libc/db
+ 4.2.2 Regular memory allocator instead of JEMALLOC
+ 4.2.3 Reduce resolver size in lib/libc/resolver
+ 4.2.4 Use libhack
* 5 Alternatives
o 5.1 Crunchgen
* 6 References
Introduction
The NetBSD installation is not big, but it can be made smaller. Here
are a few tricks to make the base of user space, the C standard
library libc, a bit smaller for dynamically linked systems. These
trials were done on a cross compiled NetBSD current ARMv6 branch.
First the user space is built with default options. Then the cross
compiler script $TOOLDIR/bin/nbmake-evbarm was used to clean and
rebuild the libc with special options. The new libc binary was then
copied to the target file system and a smoke test of booting the ARM
development board was done. If /sbin/init and /bin/sh managed with the
new libc, the test was a success while everything else was a failure.
The result is a crippled libc and /lib/libc.so.12.159 file size
reduction from 1164 to 692 kilobytes. Run time memory usage is harder
to predict since it depends on what parts of in memory libc are
actually used by the processes, but at least text and data sections
reported by the size utility give some idea.
Build options
Default -O2, file size 1164025
-O2 optimization is used by default and the libc file size after a
./build.sh -U -m evbarm build is:
-r--r--r-- 1 test test 1164025 2008-04-18 08:23
obj/destdir.evbarm/lib/libc.so.12.159
Sections reported by size utility:
text data bss dec hex filename
931608 25728 64332 1021668 f96e4 obj/libc.so.12.159
-O1, file size 1159845
If the libc is build with CFLAGS=-O1, the ELF shared object file size is:
-rw-r--r-- 1 test test 1159845 Apr 19 09:20 lib/libc.so.12.159
Sections reported by size utility:
text data bss dec hex filename
927436 25728 64332 1017496 f8698 obj/libc.so.12.159
Linker strip, file size 1065624
If the -O1 build is stripped and size optimized by the linker with
LDFLAGS=-Wl,-O1\ -Wl,-s, the file size reduces to:
-rwxr-xr-x 1 test test 1065624 2008-04-19 13:28 obj/libc.so.12.159
Sections reported by size utility:
text data bss dec hex filename
923316 25728 64332 1013376 f7680 obj/libc.so.12.159
-Os, file size 1094281
The gcc compiler can optimize binaries for size with CFLAGS=-Os:
-rwxr-xr-x 1 test test 1094281 2008-04-19 10:56 obj/libc.so.12.159
Sections reported by size utility:
text data bss dec hex filename
861864 25736 64332 951932 e867c obj/libc.so.12.159
Manual strip, file size 1004180
The binary can then be stripped manually:
$ $TOOLDIR/bin/arm--netbsdelf-strip -s obj/libc.so.12.159
$ ls -l obj/libc.so.12.159
-rwxr-xr-x 1 test test 1004180 2008-04-19 11:02 obj/libc.so.12.159
Sections reported by size utility:
text data bss dec hex filename
861864 25736 64332 951932 e867c obj/libc.so.12.159
Linker strip, file size 1000060
The -Os compiled binary is smaller with linker based strip and
optimization where LDFLAGS=-Wl,-O1\ -Wl,-s than with a manual strip:
-rwxr-xr-x 1 test test 1000060 2008-04-19 12:07 obj/libc.so.12.159
Sections reported by size utility:
text data bss dec hex filename
857744 25736 64332 947812 e7664 obj/libc.so.12.159
Feature removal
In addition to compiler flags CFLAGS=-Os LDFLAGS=-Wl,-O1\ -Wl,-s,
special feature flags can be used to strip features out of libc and
reduce its size. Some feature flags, as documented by BUILDING and
share/mk/bsd.README, are supported for the whole user space.
SCCS version strings, file size 953136
SCCS version strings are normally embedded into object file, but they
be removed by following changes in lib/libc/Makefile:
--- lib/libc/Makefile.inc 3 Jun 2007 17:36:08 -0000 1.3
+++ lib/libc/Makefile.inc 19 Apr 2008 11:01:23 -0000
@@ -24,7 +24,8 @@
.include <bsd.own.mk>
WARNS=4
-CPPFLAGS+= -D_LIBC -DLIBC_SCCS -DSYSLIBC_SCCS -D_REENTRANT
+#CPPFLAGS+= -D_LIBC -DLIBC_SCCS -DSYSLIBC_SCCS -D_REENTRANT
+CPPFLAGS+= -D_LIBC -D_REENTRANT
.if (${USE_HESIOD} != "no")
CPPFLAGS+= -DHESIOD
The resulting libc binary finally goes below the one megabyte mark:
-rwxr-xr-x 1 test test 953136 2008-04-19 13:54 obj/libc.so.12.159
Sections reported by size utility:
text data bss dec hex filename
857744 25736 64332 947812 e7664 obj/libc.so.12.159
Hesiod name service, file size 942468
Hesiod, a DNS based database service, support can be removed from libc
with USE_HESIOD=no MKHESIOD=no build variables and result is:
-rwxr-xr-x 1 test test 942468 2008-04-19 14:16 obj/libc.so.12.159
Sections reported by size utility:
text data bss dec hex filename
847625 25252 62180 935057 e4491 obj/libc.so.12.159
Yellow Pages (YP), file size 917368
Yellow Pages (YP) or Network Information Service (NIS) directory
service support can be removed with USE_YP=no MKYP=no variables:
-rwxr-xr-x 1 test test 917368 2008-04-19 14:29 obj/libc.so.12.159
Sections reported by size utility:
text data bss dec hex filename
824328 24488 58944 907760 dd9f0 obj/libc.so.12.159
IPv6 support, file size 909272
IPv6 support can be removed with USE_INET6=no:
-rwxr-xr-x 1 test test 909272 2008-04-19 14:48 obj/libc.so.12.159
Sections reported by size utility:
text data bss dec hex filename
816537 24368 58944 899849 dbb09 obj/libc.so.12.159
Stack smashing protection (SSP), file size 894764
SSP buffer overflow protection from the GCC compiler can be disabled
with USE_SSP=no and the libc binary size goes below 900k:
-rwxr-xr-x 1 test test 894764 2008-04-19 15:02 obj/libc.so.12.159
Sections reported by size utility:
text data bss dec hex filename
802029 24368 58944 885341 d825d obj/libc.so.12.159
Remote procedure call (RPC), file size 806036
RPC support can be disabled with MKRPC=no variable and a patch like this:
--- lib/libc/Makefile 9 Jan 2008 01:33:52 -0000 1.131.4.1
+++ lib/libc/Makefile 23 Apr 2008 13:04:42 -0000
@@ -74,7 +80,10 @@
.endif
.include "${.CURDIR}/regex/Makefile.inc"
.include "${.CURDIR}/resolv/Makefile.inc"
+MKRPC?= yes
+.if (${MKRPC} != "no")
.include "${.CURDIR}/rpc/Makefile.inc"
+.endif
.include "${.CURDIR}/ssp/Makefile.inc"
.include "${.CURDIR}/stdio/Makefile.inc"
.include "${.CURDIR}/stdlib/Makefile.inc"
As a result the libc size goes down to 806 kilobytes:
-rw-r--r-- 1 test test 806036 2008-04-23 16:00 lib/libc.so.12.159
Sections reported by size utility:
text data bss dec hex filename
717964 22624 58500 799088 c3170 obj/libc.so.12.159
Execution profiling control, file size 801720
Profiling control can be removed from libc with MKGMON=no and a patch like:
--- lib/libc/Makefile 9 Jan 2008 01:33:52 -0000 1.131.4.1
+++ lib/libc/Makefile 24 Apr 2008 08:07:08 -0000
@@ -58,7 +58,10 @@
.include "${.CURDIR}/dlfcn/Makefile.inc"
.include "${.CURDIR}/gdtoa/Makefile.inc"
.include "${.CURDIR}/gen/Makefile.inc"
+MKGMON?= yes
+.if (${MKGMON} != "no")
.include "${.CURDIR}/gmon/Makefile.inc"
+.endif
.include "${.CURDIR}/hash/Makefile.inc"
.include "${.CURDIR}/iconv/Makefile.inc"
.include "${.CURDIR}/inet/Makefile.inc"
And libc size goes down around 4 kilobytes:
-rwxr-xr-x 1 test test 801720 2008-04-24 10:57 obj/libc.so.12.159
Sections reported by size utility:
text data bss dec hex filename
713959 22500 58436 794895 c210f obj/libc.so.12.159
Citrus I18N, file size 767560
Citrus I18N support can be removed with MKCITRUS=no,
lib/libc/locale/setlocale.c patch and a makefile patch:
--- Makefile 9 Jan 2008 01:33:52 -0000 1.131.4.1
+++ Makefile 25 Apr 2008 07:51:20 -0000
@@ -53,12 +53,18 @@
.include "${.CURDIR}/../../common/lib/libc/Makefile.inc"
.include "${.CURDIR}/db/Makefile.inc"
+MKCITRUS?= yes
+.if (${MKCITRUS} != "no")
.include "${.CURDIR}/citrus/Makefile.inc"
+.endif
.include "${.CURDIR}/compat-43/Makefile.inc"
.include "${.CURDIR}/dlfcn/Makefile.inc"
.include "${.CURDIR}/gdtoa/Makefile.inc"
The libc binary is now below 800 kilobytes:
-rwxr-xr-x 1 test test 767560 2008-04-25 10:01 obj/libc.so.12.159
Sections reported by size utility:
text data bss dec hex filename
685150 18696 56968 760814 b9bee obj/libc.so.12.159
MD2, RMD160, SHA1, SHA2, MD4 and MD5 cryptographic hash functions,
file size 723780
All cryptographic hash functions can be removed from the libc with
MKMD2=no MKRMD160=no MKSHA1=no MKSHA2=no MKMD=no and
lib/libc/hash/Makefile.inf and lib/libc/Makefile patches:
--- lib/libc/hash/Makefile.inc 27 Oct 2006 18:29:21 -0000 1.11
+++ lib/libc/hash/Makefile.inc 30 Apr 2008 09:10:21 -0000
@@ -4,8 +4,20 @@
# hash functions
.PATH: ${ARCHDIR}/hash ${.CURDIR}/hash
+MKMD2?= yes
+.if (${MKMD2} != "no")
.include "${.CURDIR}/hash/md2/Makefile.inc"
+.endif
+MKRMD160?= yes
+.if (${MKRMD160} != "no")
.include "${.CURDIR}/hash/rmd160/Makefile.inc"
+.endif
+MKSHA1?= yes
+.if (${MKSHA1} != "no")
.include "${.CURDIR}/hash/sha1/Makefile.inc"
+.endif
+MKSHA2?= yes
+.if (${MKSHA2} != "no")
.include "${.CURDIR}/hash/sha2/Makefile.inc"
+.endif
--- lib/libc/Makefile 9 Jan 2008 01:33:52 -0000 1.131.4.1
+++ lib/libc/Makefile 30 Apr 2008 09:11:25 -0000
.include "${.CURDIR}/inet/Makefile.inc"
.include "${.CURDIR}/isc/Makefile.inc"
.include "${.CURDIR}/locale/Makefile.inc"
+MKMD?= yes
+.if (${MKMD} != "no")
.include "${.CURDIR}/md/Makefile.inc"
+.endif
.include "${.CURDIR}/misc/Makefile.inc"
.include "${.CURDIR}/net/Makefile.inc"
.include "${.CURDIR}/nameser/Makefile.inc"
libc size reduces to:
-rwxr-xr-x 1 test test 723780 2008-04-30 12:03 obj/libc.so.12.159
Sections reported by size utility:
text data bss dec hex filename
642476 18456 56968 717900 af44c obj/libc.so.12.159
Misc, Native Language Support (NLS), Regular Expression and Stack
Smashing Protection, file size 691884
Indeed, misc object, NLS, regular expression (IEEE Std 1003.2-1992
("POSIX.2") regular expressions) and Stack Smashing Protection (SSP)
support library are easily removed from the build process with
MKMISC=no MKNLS=no MKREGEX=no MKSSP=no and an obvious patch to
lib/libc/Makefile:
.include "${.CURDIR}/md/Makefile.inc"
+.endif
+MKMISC?= yes
+.if (${MKMISC} != "no")
.include "${.CURDIR}/misc/Makefile.inc"
+.endif
.include "${.CURDIR}/net/Makefile.inc"
.include "${.CURDIR}/nameser/Makefile.inc"
+MKNLS?= yes
+.if (${MKNLS} != "no")
.include "${.CURDIR}/nls/Makefile.inc"
+.endif
.if (${MACHINE_ARCH} != "alpha") && (${MACHINE_ARCH} != "sparc64")
.include "${.CURDIR}/quad/Makefile.inc"
.endif
+MKREGEX?= yes
+.if (${MKREGEX} != "no")
.include "${.CURDIR}/regex/Makefile.inc"
+.endif
.include "${.CURDIR}/resolv/Makefile.inc"
...
.include "${.CURDIR}/rpc/Makefile.inc"
+.endif
+MKSSP?= yes
+.if (${MKSSP} != "no")
.include "${.CURDIR}/ssp/Makefile.inc"
+.endif
.include "${.CURDIR}/stdio/Makefile.inc"
.include "${.CURDIR}/stdlib/Makefile.inc"
.include "${.CURDIR}/string/Makefile.inc"
Boot with sbin/init still works as does bin/sh, but user friendly
programs like bin/ps and bin/ls now fail due to missing symbols:
# ls -l lib/libc.so.12.159
/lib/libc.so.12: Undefined PLT symbol "__fgets_chk" (symnum = 156)
# ls lib/libc.so.12.159
lib/libc.so.12.159
# ps aux
/lib/libc.so.12: Undefined PLT symbol "__strcat_chk" (symnum = 207)
# ps
ps: warning: /var/run/dev.db: /lib/libc.so.12: Undefined PLT symbol "_catopen" )
File size now:
-rwxr-xr-x 1 test test 691884 2008-04-30 14:18 obj/libc.so.12.159
Segment sizes reported by size utility:
text data bss dec hex filename
614238 17284 56928 688450 a8142 obj/libc.so.12.159
Ideas
While a few compiler and feature options were a tried out, a number of
new ideas were found. Some of these were quickly tried out, but they
resulted in the build or smoke/boot test failures.
Compiler options
Thumb instruction set, file size 585440
Compile to 16 bit THUMB instruction set instead of normal 32 bit
* Whole user space needs to be build with -mthumb-interwork
* CPUFLAGS build variable should contain -mthumb and -mthumb-interwork
* If some files (like atomic_init_testset.c) need arm32 code due
to embedded ARM assembly or other tool chain issues, the CPUFLAGS
build variable can be overridden: Per file build options override
* libc from matt-armv6 branch builds with -mthumb but fails to run
with SIGILL: Thumb compilation discussion on port-arm
After a successfull compile with atomic_init_testset.o compiled with
-mthumb-interwork only, the file size is:
-rwxr-xr-x 1 mira mira 585440 2008-05-12 11:20 obj/libc.so.12.159
size utility reports:
text data bss dec hex filename
507462 17616 56928 582006 8e176 obj/libc.so.12.159
Feature removals
Database support from lib/libc/db
* sbin/init and possibly others depend on Berkeley DB support
* a custom init and bin/sh propably work without it
Regular memory allocator instead of JEMALLOC
* USE_JEMALLOC: (share/mk/bsd.README) If "no", disables building
the "jemalloc" allocator designed for improved performance with
threaded applications.
o seems to require rebuild of user space, but even after
that init dies with:
warning: no /dev/console
panic: init died (signal 0, exit 12)
Stopped in pid 1.1 (init) at netbsd:cpu_Debugger+0x4: bx r14
Reduce resolver size in lib/libc/resolver
* remove IPv6 support
* remove debug features
Use libhack
* Use size optimized distrib/utils/libhack with/instead of libc
Alternatives
Crunchgen
crunchgen can be used to create statically (at compile time) linked
executables, which include only those object files, which are really
used by the executable.
* Use crunchgen or related build infra to build a dynamic library
from only those object files that are actually required by the
applications
References
* The BUILDING and share/mk/bsd.README files in addition to libc
specific makefiles and sources contain information on the different
build and feature options.
* gcc and ld manual pages
* Shrinking NetBSD - deep final distribution re-linker, discussion
on tech-userlevel
* Reducing libc size, discussion on tech-userlevel
arm交叉编译bash和python
目标机器是EABI,armv4t
一.bash
下载代码
http://core.ring.gr.jp/pub/GNU/bash/bash-3.2.48.tar.gz
配置
CC=arm-linux-gcc CFLAGS=-mabi=aapcs-linux ./configure --host=arm-unknown-linux --target=arm-unknow-linux --build=i686-unknown-linux
编译
make
确认库和二进制程序
readelf -h bash 确认abi版本和目标机器
readelf -d bash 确认使用的共享库
如果是静态编译,就不用确认共享库了。
二.python
下载代码
python-2.6.2
配置和bash一样。但,如果出现交叉编译无法执行程序的错误时,把configure文件中对应部分注释掉。
通过后,make编译。