title: jni function calls some libc function which gdb does not know about
body: <p>I have a simple JNI function which I use to read data from file into <code>byte[]</code> from C code <code>UnixUtil.unsafeReadToByteArray</code> which is implemented as:</p>
  
  <pre><code>JNIEXPORT jlong JNICALL Java_net_xxxxxxx_UnixUtil_unsafeReadToByteArray
    (JNIEnv *e, jclass jc, jint fd, jbyteArray array, jlong offset, jlong count){
    signed char *array_native_ptr = (*e) -&gt; GetByteArrayElements(e, array, NULL);
    ssize_t bytes_read = read(fd, array_native_ptr + offset, (size_t) count);
    (*e) -&gt; ReleaseByteArrayElements(e, array, array_native_ptr, 0);
    return bytes_read;
  }
  </code></pre>
  
  <p>Profiling a java application running the function showed up some unclear result. Here is the top:</p>
  
  <p><a href="https://i.stack.imgur.com/FEMAk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FEMAk.png" alt="enter image description here"></a></p>
  
  <p>One of the hottest thing turned out to be some instruction by address <code>0x18eb1f</code> which is from <code>libc-2.27.so</code>. I wanted to understand what it was but gdb does not know about it</p>
  
  <pre><code>(gdb) disas 0x18eb1f
  No function contains specified address
  </code></pre>
  
  <p>Objdump'ing libc to grep the address I found that</p>
  
  <pre><code>18eb0b:       72 0f                   jb     18eb1c &lt;__nss_group_lookup@GLIBC_2.2.5+0x24ddc&gt;
  [...]
  18eb1c:       48 89 d1                mov    %rdx,%rcx
  18eb1f:       f3 a4                   rep movsb %ds:(%rsi),%es:(%rdi)
  </code></pre>
  
  <p>Which looks like it is a part of <code>__nss_group_lookup</code> while <code>__nss_group_lookup</code> seems not to contain the address:</p>
  
  <pre><code>(gdb) disas __nss_group_lookup
  Dump of assembler code for function __nss_passwd_lookup:
     0x0000000000169d40 &lt;+0&gt;:     mov    rax,QWORD PTR [rip+0x281121]        # 0x3eae68
     0x0000000000169d47 &lt;+7&gt;:     mov    DWORD PTR fs:[rax],0x26
     0x0000000000169d4e &lt;+14&gt;:    mov    eax,0xffffffff
     0x0000000000169d53 &lt;+19&gt;:    ret    
  End of assembler dump. making the things more unclear then it was before.
  </code></pre>
  
  <p>making the things more unclear then before.</p>
  
  <p><strong><em>Question:</em></strong> Can you give any hint where to look at to understand why is the instruction belonging to <code>__nss_group_lookup</code> is the hottest while calling to <code>jni_GetByteArrayElements</code>/<code>jni_ReleaseByteArrayElements</code> and what it actually is.</p>
  
  <p>My expectation was since <code>jni_GetByteArrayElements</code>/<code>jni_ReleaseByteArrayElements</code> copies the <code>byte[]</code> from Java heap to C heap via <code>memcpy</code> it would be the hottest one.</p>