~# cat a.c
#include <stdio.h>
int main(int argc, char** argv)
{
printf("%s\n", argv[0]);
}
~# gcc a.c
~# ln -s a.out kk
~# ./kk
./kk
~#
Program prints argv[0]. But we did kk -> a.out.
Notice that whe we execute ./kk,
argv[0] is not ./a.out, but ./kk !
This idea is used in busybox and
to call different architecture dependent binaries
depending on USE_ARCH environment variable.
http://www.embeddedlinux.org.cn/EmbeddedLinuxPrimer/0136130550/ch11lev1sec3.html
http://www.clfs.org/view/CLFS-3.0.0-SYSVINIT/x86_64/final-system/multiarch_wrapper.html
No comments:
Post a Comment