1

This is a question similar as warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking.

In runtime, getaddrinfo("localhost") will open /etc/resolv.conf, this is strange! I'v even found that gcc statically linked executable file will contain hardcoding string such as /etc/resolv.conf, is this terrible?

localhost:tmp macq$ strings node.armv5.static |grep /etc
        // Test: ./node test/fixtures/echo.js < /etc/passwd
/etc/egd-pool
/etc/entropy
/etc/ssl/private
/etc/ssl
/etc/ssl/certs
/etc/ssl/cert.pem
/etc/hosts
/etc/resolv.conf
/etc/nsswitch.conf
/etc/host.conf
/etc/svc.conf
/etc/localtime
/etc/gai.conf
/etc/ld.so.cache
/etc/ld.so.nohwcap
/etc/suid-debug
/etc/mtab

I just want to know the source of this warning and the logic of getaddrinfo.

I think it is from libgcc, but i'v checked source of gcc 4.4, 4.5 totally, not found such error string pattern, event not found getaddrinfo implementation. I could not find source of ld(colloect2).

Where is the source of getaddrinfo in gcc? where is the source of libnss_files.so?

Edit: Thank you all guys. I'v changed the title now, Who can tell me the source code of implementation of things like getaddrinfo, they seems not in libc.

Community
  • 1
  • 1
osexp2000
  • 2,910
  • 30
  • 29
  • 1
    This has nothing to do with gcc or libgcc. It is about libc and static linking. – n. m. could be an AI Aug 03 '14 at 05:36
  • resolv.conf is the config for the resolver. Why is it strange that that is referenced in code that does name resolution? What exactly is your problem with this? – Mat Aug 03 '14 at 06:04
  • android have no /etc/resolv.conf, so can not run. – osexp2000 Aug 03 '14 at 06:15
  • Thank you. I think it did caused by libc of gcc, Code compiled by gcc have these warning and encountered error at runtime because no /etc/resolv.conf in android or other OS. I'v disassembled static executable and found exactly gcc's code did such logic. But i want to know where is the source of these implementation. – osexp2000 Aug 03 '14 at 06:19
  • The source of file names like that is caused by what is in the run time library. getaddrinfo has to find out how the system resolves DNS calls. In other words, since the code can be compiled and run on different machines with different DNS configurations, getaddrinfo cannot know ahead of time, so it relies on known files. – jim mcnamara Aug 03 '14 at 21:22
  • Thank you. You are right. I am curious where can i get the source of implementation of things like getaddrinfo, they seems not in libc. – osexp2000 Aug 04 '14 at 01:16

0 Answers0