My Notes

Linux: behavior of symbolic link and argv[0]; busybox and multiarch_wrapper

~# 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:
Newer Posts Older Posts Home
Subscribe to: Posts (Atom)

Links...

  • My Home
  • My Github
  • My Research
  • My Notes
  • My Poems
  • My Bookshelf
  • Disclaimer

Blog Archive

  • ▼  2018 (4)
    • ►  November (1)
    • ►  October (1)
    • ►  February (1)
    • ▼  January (1)
      • Linux: behavior of symbolic link and argv[0]; busy...
  • ►  2017 (13)
    • ►  November (1)
    • ►  October (1)
    • ►  September (1)
    • ►  June (4)
    • ►  May (3)
    • ►  March (3)
  • ►  2015 (3)
    • ►  April (2)
    • ►  February (1)
  • ►  2014 (53)
    • ►  November (2)
    • ►  October (4)
    • ►  September (6)
    • ►  August (41)
Simple theme. Powered by Blogger.