title: Where would I find specific function addresses in libc object files?
body: <p>I am trying to find the address of a function in libc.</p>
  
  <p>I know I can do something like this in C:</p>
  
  <pre><code>printf("%x", (int) system);
  </code></pre>
  
  <p>But I don't know if that gives me the base address of the system function in libc. I assume it gives some sort of indirect pointer from within the program?</p>
  
  <p>I am running gdb and did:</p>
  
  <pre><code>info files
  </code></pre>
  
  <p>while running the program, but it gave me many segments and I am not sure where to look, other than the ones that have libc.so in them?</p>
  
  <p>Edit:</p>
  
  <p>This is what I get in gdb, and I am wondering where in here I would be able to find something like "system", "printf", "exit", etc. I checked rodata and was able to find system there, but I don't know if that's the function itself:</p>
  
  <pre><code>    0x08048154 - 0x08048167 is .interp
      0x08048168 - 0x08048188 is .note.ABI-tag
      0x08048188 - 0x080481ac is .note.gnu.build-id
      0x080481ac - 0x080481d0 is .gnu.hash
      0x080481d0 - 0x08048290 is .dynsym
      0x08048290 - 0x08048326 is .dynstr
      0x08048326 - 0x0804833e is .gnu.version
      0x08048340 - 0x08048380 is .gnu.version_r
      0x08048380 - 0x08048388 is .rel.dyn
      0x08048388 - 0x080483d8 is .rel.plt
      0x080483d8 - 0x080483fb is .init
      0x08048400 - 0x080484b0 is .plt
      0x080484b0 - 0x08048892 is .text
      0x08048894 - 0x080488a8 is .fini
      0x080488a8 - 0x08048994 is .rodata
      0x08048994 - 0x080489c8 is .eh_frame_hdr
      0x080489c8 - 0x08048a98 is .eh_frame
      0x08049f08 - 0x08049f0c is .init_array
      0x08049f0c - 0x08049f10 is .fini_array
      0x08049f10 - 0x08049f14 is .jcr
  ---Type &lt;return&gt; to continue, or q &lt;return&gt; to quit---
      0x08049f14 - 0x08049ffc is .dynamic
      0x08049ffc - 0x0804a000 is .got
      0x0804a000 - 0x0804a034 is .got.plt
      0x0804a034 - 0x0804a03c is .data
      0x0804a03c - 0x0804a054 is .bss
      0xb7fde114 - 0xb7fde138 is .note.gnu.build-id in /lib/ld-linux.so.2
      0xb7fde138 - 0xb7fde1f8 is .hash in /lib/ld-linux.so.2
      0xb7fde1f8 - 0xb7fde2dc is .gnu.hash in /lib/ld-linux.so.2
      0xb7fde2dc - 0xb7fde4ac is .dynsym in /lib/ld-linux.so.2
      0xb7fde4ac - 0xb7fde642 is .dynstr in /lib/ld-linux.so.2
      0xb7fde642 - 0xb7fde67c is .gnu.version in /lib/ld-linux.so.2
      0xb7fde67c - 0xb7fde744 is .gnu.version_d in /lib/ld-linux.so.2
      0xb7fde744 - 0xb7fde7b4 is .rel.dyn in /lib/ld-linux.so.2
      0xb7fde7b4 - 0xb7fde7e4 is .rel.plt in /lib/ld-linux.so.2
      0xb7fde7f0 - 0xb7fde860 is .plt in /lib/ld-linux.so.2
      0xb7fde860 - 0xb7ff67ac is .text in /lib/ld-linux.so.2
      0xb7ff67c0 - 0xb7ffa7a0 is .rodata in /lib/ld-linux.so.2
      0xb7ffa7a0 - 0xb7ffae24 is .eh_frame_hdr in /lib/ld-linux.so.2
      0xb7ffae24 - 0xb7ffd71c is .eh_frame in /lib/ld-linux.so.2
      0xb7ffecc0 - 0xb7ffef34 is .data.rel.ro in /lib/ld-linux.so.2
      0xb7ffef34 - 0xb7ffefec is .dynamic in /lib/ld-linux.so.2
      0xb7ffefec - 0xb7ffeff8 is .got in /lib/ld-linux.so.2
      0xb7fff000 - 0xb7fff024 is .got.plt in /lib/ld-linux.so.2
  ---Type &lt;return&gt; to continue, or q &lt;return&gt; to quit---
      0xb7fff040 - 0xb7fff878 is .data in /lib/ld-linux.so.2
      0xb7fff878 - 0xb7fff938 is .bss in /lib/ld-linux.so.2
      0xb7e16174 - 0xb7e16198 is .note.gnu.build-id in /lib/i386-linux-gnu/libc.so.6
      0xb7e16198 - 0xb7e161b8 is .note.ABI-tag in /lib/i386-linux-gnu/libc.so.6
      0xb7e161b8 - 0xb7e19ec8 is .gnu.hash in /lib/i386-linux-gnu/libc.so.6
      0xb7e19ec8 - 0xb7e23438 is .dynsym in /lib/i386-linux-gnu/libc.so.6
      0xb7e23438 - 0xb7e2915e is .dynstr in /lib/i386-linux-gnu/libc.so.6
      0xb7e2915e - 0xb7e2a40c is .gnu.version in /lib/i386-linux-gnu/libc.so.6
      0xb7e2a40c - 0xb7e2a898 is .gnu.version_d in /lib/i386-linux-gnu/libc.so.6
      0xb7e2a898 - 0xb7e2a8d8 is .gnu.version_r in /lib/i386-linux-gnu/libc.so.6
      0xb7e2a8d8 - 0xb7e2d2e8 is .rel.dyn in /lib/i386-linux-gnu/libc.so.6
      0xb7e2d2e8 - 0xb7e2d348 is .rel.plt in /lib/i386-linux-gnu/libc.so.6
      0xb7e2d350 - 0xb7e2d420 is .plt in /lib/i386-linux-gnu/libc.so.6
      0xb7e2d420 - 0xb7f5eb6e is .text in /lib/i386-linux-gnu/libc.so.6
      0xb7f5eb70 - 0xb7f5fafb is __libc_freeres_fn in /lib/i386-linux-gnu/libc.so.6
      0xb7f5fb00 - 0xb7f5fcfe is __libc_thread_freeres_fn in /lib/i386-linux-gnu/libc.so.6
  ---Type &lt;return&gt; to continue, or q &lt;return&gt; to quit---
      0xb7f5fd00 - 0xb7f81754 is .rodata in /lib/i386-linux-gnu/libc.so.6
      0xb7f81754 - 0xb7f81767 is .interp in /lib/i386-linux-gnu/libc.so.6
      0xb7f81768 - 0xb7f88c0c is .eh_frame_hdr in /lib/i386-linux-gnu/libc.so.6
      0xb7f88c0c - 0xb7fb9f68 is .eh_frame in /lib/i386-linux-gnu/libc.so.6
      0xb7fb9f68 - 0xb7fba3c6 is .gcc_except_table in /lib/i386-linux-gnu/libc.so.6
      0xb7fba3c8 - 0xb7fbd928 is .hash in /lib/i386-linux-gnu/libc.so.6
      0xb7fbe1d4 - 0xb7fbe1dc is .tdata in /lib/i386-linux-gnu/libc.so.6
      0xb7fbe1dc - 0xb7fbe220 is .tbss in /lib/i386-linux-gnu/libc.so.6
      0xb7fbe1dc - 0xb7fbe1e8 is .init_array in /lib/i386-linux-gnu/libc.so.6
      0xb7fbe1e8 - 0xb7fbe260 is __libc_subfreeres in /lib/i386-linux-gnu/libc.so.6
      0xb7fbe260 - 0xb7fbe264 is __libc_atexit in /lib/i386-linux-gnu/libc.so.6
      0xb7fbe264 - 0xb7fbe274 is __libc_thread_subfreeres in /lib/i386-linux-gnu/libc.so.6
      0xb7fbe280 - 0xb7fbfda8 is .data.rel.ro in /lib/i386-linux-gnu/libc.so.6
      0xb7fbfda8 - 0xb7fbfe98 is .dynamic in /lib/i386-linux-gnu/libc.so.6
      0xb7fbfe98 - 0xb7fbfff4 is .got in /lib/i386-linux-gnu/libc.so.6
      0xb7fc0000 - 0xb7fc003c is .got.plt in /lib/i386-linux-gnu/libc.so.6
      0xb7fc0040 - 0xb7fc0ebc is .data in /lib/i386-linux-gnu/libc.so.6
  </code></pre>