Why some linker-made assembly code is at GOT, instead of PLT?

114 views Asked by At

Some library function is shown like below after linking.

0x0804842e <+35>:   call   0x80482e0 <printf@plt>


So, I understood the usage of @plt on disassembly.

However, yesterday, I some some weird code slice.
Below is part of libstdbuf.s, which is inclued in Coreutils:

.L31:
    .loc 1 142 0
    testl   %edi, %edi
    je  .L32
    .loc 1 143 0
    movl    stdin@GOT(%ebx), %eax   # <========= here
    movl    %edi, %edx

As you can see, code accesses to stdin@GOT.

Hmm... I've never seen blabla@GOT syntax before..



Question:

  1. What exactly stdin@GOT(%ebx), %eax line do?

  2. Is this linker-generated code? If yes, why is it at GOT, instead of PLT?

  3. And.. How can I know stdin@GOT address information?
    ( unlike general global symbols, the address isn't shown on symbol table. See below)

.

jiwon@jiwon$ objdump -t -T ./libstdbuf.so | grep stdin
  00000000       O *UND*    00000000              stdin@@GLIBC_2.0
  00000000      DO *UND*    00000000  GLIBC_2.0   stdin
0

There are 0 answers