title: How Does C Compiled to ASM Know Where to Branch to for External Functions?
body: <p>How does C compiled to ARM ASM know where to branch to for external functions?</p>
  <p>For example, here is a simple C program:</p>
  <pre class="lang-c prettyprint-override"><code>#include &lt;stdio.h&gt;
  
  int main() {
     printf(&quot;Hello World!&quot;);
     return 0;
  }
  </code></pre>
  <p>and its corresponding ARM ASM program:</p>
  <pre><code>    .arch armv6
      .eabi_attribute 28, 1
      .eabi_attribute 20, 1
      .eabi_attribute 21, 1
      .eabi_attribute 23, 3
      .eabi_attribute 24, 1
      .eabi_attribute 25, 1
      .eabi_attribute 26, 2
      .eabi_attribute 30, 6
      .eabi_attribute 34, 1
      .eabi_attribute 18, 4
      .file   &quot;main.c&quot;
      .text
      .section    .rodata
      .align  2
  .LC0:
      .ascii  &quot;Hello World!\000&quot;
      .text
      .align  2
      .global main
      .arch armv6
      .syntax unified
      .arm
      .fpu vfp
      .type   main, %function
  main:
      @ args = 0, pretend = 0, frame = 0
      @ frame_needed = 1, uses_anonymous_args = 0
      push    {fp, lr}
      add fp, sp, #4
      ldr r0, .L3
      bl  printf
      mov r3, #0
      mov r0, r3
      pop {fp, pc}
  .L4:
      .align  2
  .L3:
      .word   .LC0
      .size   main, .-main
      .ident  &quot;GCC: (Raspbian 10.2.1-6+rpi1) 10.2.1 20210110&quot;
      .section    .note.GNU-stack,&quot;&quot;,%progbits
  </code></pre>
  <p>I dont see a &quot;printf&quot; tag anywhere so i am assuming that it links outside of the program. but how does it know where to search? it wouldnt look everywhere, because there might be duplicate tags, but there are also libraries that are placed (in the computers perspective) at random, though i also dont see anywhere where it defines a library location.</p>
  <p>so where does it link, for more than just the standard C library?<br />
  and how can i compile it to not rely on those external dependencies?<br />
  or know where the libraries are so i know which files i can delete?</p>
  <p>i am currently operating linux on a raspberry pi 400</p>